Skip to content

Support package.json exports "Alternatives" #5052

Description

@puehringer

What problem does this feature solve?

webpack supports Alternatives in package.json#exports fields: https://webpack.js.org/guides/package-exports/#alternatives

This allows us to import from one path, if possible, and fallback to another path if required. Currently in rspack, this will fail with a Failed to resolve in case the first occurance (./dist/index.js) does not exist. It works in webpack however.

  "exports": {
    ".": {
      "types": [
        "./dist/index.d.ts",
        "./src/index.ts"
      ],
      "import": [
        "./dist/index.js",
        "./src/index.ts"
      ]
    }
  }

What does the proposed API of configuration look like?

No API required.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions