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

@open-wc/building-rollup fails to recognize the package.json exports field #2461

Closed
eKoopmans opened this issue Jun 21, 2022 · 1 comment
Closed

Comments

@eKoopmans
Copy link

eKoopmans commented Jun 21, 2022

Expected behavior

Rollup (using config from @open-wc/building-rollup) should be able to build projects that include dependencies using subpath exports, and more generally the exports field.

Actual Behavior

When a project attempts to import from a dependency that uses subpath exports:

  • if the subpath exactly matches the actual location in the repo (e.g. "./src/submodule.js": "./src/submodule.js"), it works fine
  • otherwise, the dependency is not found:

    Error: 'example/file.js' is imported by src/index.js, but could not be resolved – treating it as an external dependency

This indicates the exports field in package.json is being ignored entirely.

Additional context

The solution is to upgrade @rollup/plugin-node-resolve to its latest version.

We are using @open-wc/building-rollup v1.10.0, but the issue is still present in v2. It's caused by using an old version of @rollup/plugin-node-resolve, which is set to ^7.1.1. We have resolved the issue on our end by explicitly adding the latest @rollup/plugin-node-resolve (v13.3.0) to our Rollup config, and setting nodeResolve: false in building-rollup.

Some discussion on Rollup's support of the exports field: rollup/plugins#208.

@web-padawan
Copy link
Contributor

Updated @rollup/plugin-node-resolve to v13 in #2192 and released in @open-wc/building-rollup 2.2.0. Closing.

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

No branches or pull requests

2 participants