-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add node module output format #4027
Conversation
d67e885
to
52afb2f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even though the changes are very small, personally I can't review this as I have no clue about Node.
Best case scenario I can take a look at it later when I have more time to learn whats needed here, but even then I would keep it experimental until a maintainer who knows whats going on here can review this.
Thanks for checking, I'll annotate some of the changes later to make it easier to review. |
4685879
to
d23a4b8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've split up the changes into separate commits, so it should be more obvious what changes what. The core changes are in 4d63628. In general, the new target mostly uses the bundler
target paths, plus the existing node
import logic as noted below.
f2b6c12
to
89e28bb
Compare
My earlier question was resolved after gaining some more familiarity with the codebase, I've updated my comments where I was being unclear. @daxpedda I think you should be able to review this in this state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I'm happy to move this forward with the following changes:
- Name the option
experimental-nodejs-module
.- I don't feel entirely comfortable otherwise, considering my lack of knowledge with this tech.
- After some digging I do believe we want to produce
.mjs
files, so until we figure that out we shouldn't stabilize the option.
- Make sure its being tested in CI.
The CI is a bit of a mess and I have no guidance on where to add it, unfortunately you will have to dig into it yourself.
I'm fine with experimental as long as it's merged. 🙂
That will require a few more changes than 4d63628 if I've seen right, so far I was trying to change as little as possible. If I go through and generalize the extension already, I'll also add a command line option for overwriting the default. Just to make clear, currently there are the following targets:
Changing it for this target would add another row:
While I don't disagree that a In either case, since this remains experimental for now we can do that in a follow-up PR.
I didn't find any relevant tests on first glance and was hoping for more info, but I'll take digging in. 😄 |
Is there a reason file extensions should be consistent across targets?
Agreed. Your work and input so far is really appreciated, it has been very valuable and you put a lot of effort into making this as easy to review as possible. Thank you! |
Principle of least surprise is the main one, but I don't have reasons beyond that.
Technically yes, but only to some degree. If you want to distribute your wasm-bindgen generated files on NPM you always have to package it with a I'll think about it more until the follow-up. I actually don't mind using ¹With exceptions, Webpack states it autodetects the format, some other bundlers might do the same. |
Modules have not been experimental since Node v12, see https://nodejs.org/docs/latest-v12.x/api/esm.html#esm_modules_ecmascript_modules
See github.com/orgs/nodejs/discussions/23694
18fdcad
to
3eafd91
Compare
It looks like for use-cases without a Test is running now, I added a |
6e2b397
to
78d3338
Compare
78d3338
to
fff8d25
Compare
fff8d25
to
91b2be6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, thank you!
It took a bit of back and forth but we got there, thanks for the review and guidance! |
I think it might be necessary to mention #3790 |
Thanks for linking that issue, that's a feature I want too. I wanted to experiment with some approaches during the week. |
This PR adds a node module output target. Node stabilized node modules with release 12, a lot of the JS ecosystem moved towards publishing modules, and the other targets apart from
nodejs
all generate modules.There were already code-paths for this target, but it wasn't hooked up or finished. I changed the naming away from "experimental" and finished the implementation.
Support for the format would also need to be added to
wasm-pack
after this is merged.