Skip to content

[v4] Explore adding package.json#exports for CSS and Sass #24

Description

@fvsch

The package.json exports field can map import paths to package files.
It also allows for conditions depending on what requested the import:
https://nodejs.org/api/packages.html#conditional-exports

The standard ones are for JS modules (ESM/CJS), and it mentions “community” conditions like types and browser.

Webpack docs also mention style and sass, but it's unclear if that's actually supported in webpack, let alone in other bundlers:
https://webpack.js.org/guides/package-exports/#conditions

The style condition has some prior usage in some npm packages:
https://jaketrent.com/post/package-json-style-attribute/

If anything, it might be good to explicitly list files that should be accessible, for example:

{
  "exports": {
    "./dist/*.css": "./dist/*.css"
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions