-
-
Notifications
You must be signed in to change notification settings - Fork 592
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
Support pkg.exports.node field when building for Node.js #695
Comments
Have you seen #693? |
In the examples mentioned, I do not see the |
@shellscape thanks for the pointer. I must have missed that issue when searching before raising this report. After reading through it I'm still unsure if it really solves this issue out of the box. @lukastaegert I was referring to a) The node.js documentation at https://nodejs.org/api/packages.html#packages_conditional_exports which states: Node.js supports the following conditions out of the box:
b) The Webpack documentation at https://webpack.js.org/guides/package-exports/#target-environment which states:
Now when looking at https://rollupjs.org/guide/en/#quick-start the example "For Node.js"
somewhat suggests that the resulting bundle is supposed to run in Node.js. That's why I made the assumption that when bundling for CJS I would automatically get the Node.js-style I do agree that So maybe now that |
Definitely, and no matter how we go from here, there should be clear examples in the documentation that show-case the main use-cases (i.e. bundling for Node and bundling for the web). |
@ctavan can you double check this against the latest version? |
@shellscape I've updated the Replit to use If I try to execute the resulting bundle with Node.js I get:
Rollup still seems to pick up the browser build instead of the node build. |
This can now be configured when using the |
FTR: I realized it must read |
Expected Behavior
@rollup/[email protected]
added support forpkg.exports
entrypoints through #540.However it seems like the
node
keyword is currently not respected which causes trouble when bundling for Node.js environments.The specific
pkg.exports
definition that doesn't work as expected is https://github.com/uuidjs/uuid/blob/334ef62c330d92f8ca376d09087e8ee9abc5cc12/package.json#L21-L31:Since apparently the
node
keyword is ignored, rollup picks up thedefault
key, which in this case is a browser build.Node.js supports the
node
keyword and this is supported in webpack@5 as wellIt has been reported as a bug to uuidjs/uuid#544
Actual Behavior
When
browser: false
, respect thenode
keyword, just like Node.js and webpack do.Additional Information
/cc @guybedford @LarsDenBakker @TrySound @lukastaegert since you were involved in earlier discussions around
pkg.exports
anduuid
as a widely used canary, see rollup/rollup#3514 & webpack/webpack#11014 😉Edit: Here's the reference where @guybedford proposed the pattern used in
uuid
'spkg.exports
field: uuidjs/uuid#468 (comment)The text was updated successfully, but these errors were encountered: