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

False Missing Export on export * from #3928

Closed
shellscape opened this issue Jan 18, 2021 · 3 comments · Fixed by #3894
Closed

False Missing Export on export * from #3928

shellscape opened this issue Jan 18, 2021 · 3 comments · Fixed by #3894

Comments

@shellscape
Copy link
Contributor

  • Rollup Version: 2.36.2
  • Operating System (or Browser): Mac OS
  • Node Version (if applicable): 4.15.3
  • Link to reproduction (IMPORTANT, read below):

Expected Behavior

I'm attempting to bundle @graphql-mesh/utils which performs this import: https://github.com/Urigo/graphql-mesh/blob/4303d22a27690b0d0df6d4804aac2d233c6856a1/packages/utils/src/read-file-or-url.ts#L1

From the the fetchache package: https://github.com/ardatan/fetchache/blob/09f0d39fe8a3e5f7d76e60dfe8aed08b77badfd8/src/index.ts#L63

The index.esm.js file checks out, as it does an export * from 'cross-fetch'. That should work well.

Actual Behavior

With both commonjs and node-resolve plugins, we get:

src/main → stdout...
[!] Error: 'Request' is not exported by node_modules/fetchache/index.esm.js, imported by src/main.js
https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module
src/main.js (1:9)
1: import { Request } from 'fetchache';
            ^
2: 
3: console.log(Request)
Error: 'Request' is not exported by node_modules/fetchache/index.esm.js, imported by src/main.js
    at error (/home/runner/rollup-repro/node_modules/rollup/dist/shared/rollup.js:5265:30)
...

Which is not true, as Request is actually exported via export * from 'cross-fetch'. I downloaded the package tarball to confirm, and the same can be seen by inspecting the file in node_modules.

Commenting out commonjs yields:

src/main → stdout...
[!] Error: 'fetch' is not exported by node_modules/cross-fetch/dist/node-ponyfill.js, imported by node_modules/fetchache/index.esm.js
https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module
node_modules/fetchache/index.esm.js (2:9)
1: import CachePolicy from 'http-cache-semantics';
2: import { fetch, Response, Request } from 'cross-fetch';
            ^
3: export * from 'cross-fetch';
Error: 'fetch' is not exported by node_modules/cross-fetch/dist/node-ponyfill.js, imported by node_modules/fetchache/index.esm.js
    at error (/home/runner/rollup-repro/node_modules/rollup/dist/shared/rollup.js:5265:30)

Which is even weirder. There's definitely something funky going on with either module resolution, or Rollup not picking up on exports that are there.

@lukastaegert
Copy link
Member

lukastaegert commented Jan 18, 2021

Looks like this issue: #3894 (note that cross-fetch is commonjs)

@lukastaegert
Copy link
Member

It is not merged because there was no agreement yet how to handle multiple namespace reexports from files with synthetic named exports (i.e. commonjs files).

@shellscape
Copy link
Contributor Author

@lukastaegert Sure does. I didn't connect the dots there. Is there a "better than nothing" path that we can take (maybe with warnings) that's better than no path at all? Without a path forward, I'm not sure how to get this bundle working aside from requesting changes from the package author.

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

Successfully merging a pull request may close this issue.

2 participants