Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use "exports" as alternative to "/node" and "/native" import paths #1531

Closed
1 task done
kettanaito opened this issue Feb 3, 2023 · 1 comment
Closed
1 task done
Labels
Milestone

Comments

@kettanaito
Copy link
Member

Scope

Adds a new behavior

Compatibility

  • This is a breaking change

Feature description

We can utilize the exports field of package.json to automatically expose the correct exports based on the environment where msw is being imported in. This would allow us to drop import path like msw/node and msw/native, making the library more predictable across environments.

{
  "exports": {
    "./": {
      "browser": "./lib/browser/...",
      "node": "./lib/browser/..."
    }
  }
}

This is a very basic example as each export would also have to point to its own "types" so the "browser" and "node" fields must be expanded with the "type" key as well as the export type key.

It also makes sense to ship this change with backward-compatibility so people on old bundlers could still use MSW as before: via msw/node and msw/native direct imports. We may consider dropping those imports after some time.

@kettanaito kettanaito added this to the 2.0.0 milestone Feb 3, 2023
@kettanaito
Copy link
Member Author

This has been implemented in #1404.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant