Skip to content

feature request: support conditional exports (package.json exports field) #492

Description

@ctjlewis

Love the style support, but would really helpful for conditional exports to also be legible to postcss-import:

{
  ...,
  "exports": {
    ".": "./dist/index.js",
    "./*": "./dist/lib/*/index.js",
    "./styles": "./dist/styles/index.css",
    "./styles/*": "./dist/styles/*/index.css",
    "./package.json": "./package.json"
  },
  ...,
}

The main reason I suggest this is because I cannot specify an @import "my-package/styles" statement in a way that is supported by both esbuild (supports standardized package.json exports, but not nonstandard style) and postcss-import (where situation is reversed). my-package/styles is the only thing that works for esbuild, but my-package is the only thing that works for postcss-import.

I would recommend following the Node doctrine of "if exports exists, it overrides anything else" (i.e. style field). Also thank you for maintaining this project, it is a core part of modern development workflows IMO, only reason I suggest the enhancement.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions