-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Module: Import assertions improvements #40785
Module: Import assertions improvements #40785
Conversation
5838a72
to
48c581a
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.
Implementation LGTM, discussion is ongoing though
Since the discussion seems to be narrowed to around how to deal w/ imports that lack the assertion, and it seems it would move from early error -> working at runtime. I think we should probably land this PR and continue discussion elsewhere unless there are clear concerns about moving those early errors into working at runtime code from this implementation in this PR. I tried to read the discussion again but don't see anything that stands out to me as absolutely concerned with the implementation here. |
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.
RSLGTM
doc/api/esm.md
Outdated
@@ -582,6 +608,9 @@ node --experimental-wasm-modules index.mjs | |||
|
|||
would provide the exports interface for the instantiation of `module.wasm`. | |||
|
|||
The `assert { type: 'webassembly' }` syntax is mandatory; see |
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.
should we link out to the ongoing discussion in HTML spec?
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’m not sure what the best link would be. There’s WebAssembly/esm-integration#42 or tc39/proposal-import-attributes#19 or others. It also feels a little messy to link to a discussion thread as opposed to a decision outcome. But if you have a link in particular you recommend, though, I’m happy to add it.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
Blocking as per my comments in #40790 (comment). to summarize:
- Separating
"type": "javascript"
and"type": "webassembly"
risks conflating a model of security privilege with the execution model, when JS and Wasm currently share execution privileges by virtue of being able to import and execute any function. Making this distinction I believe would result in unnecessary interop frictions on import boundaries. - Whether
"type": "webassembly"
will be optional, required or even supported at all is entirely unclear and should be determined based on discussion with those in the browser and Web Assembly communities through the Web Assembly ESM Integration effort, not by Node.js jumping ahead with implementation.
I'm in contact with @GeoffreyBooth with regards to next steps on this topic.
This comment has been minimized.
This comment has been minimized.
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 with one nit and assuming Guy concern can be resolved.
48c581a
to
4ff88dc
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Commit Queue failed- Loading data for nodejs/node/pull/40785 ✔ Done loading data for nodejs/node/pull/40785 ----------------------------------- PR info ------------------------------------ Title Module: Import assertions improvements (#40785) ⚠ Could not retrieve the email or name of the PR author's from user's GitHub profile! Branch GeoffreyBooth:more-import-assertion-types -> nodejs:master Labels module, esm, author ready, loaders Commits 2 - doc: fix spelling of 'WebAssembly' - module: import assertions improvements Committers 1 - Geoffrey Booth PR-URL: https://github.com/nodejs/node/pull/40785 Reviewed-By: James M Snell Reviewed-By: Bradley Farias Reviewed-By: Myles Borins Reviewed-By: Guy Bedford Reviewed-By: Antoine du Hamel ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/40785 Reviewed-By: James M Snell Reviewed-By: Bradley Farias Reviewed-By: Myles Borins Reviewed-By: Guy Bedford Reviewed-By: Antoine du Hamel -------------------------------------------------------------------------------- ⚠ Commits were pushed since the last review: ⚠ - doc: fix spelling of 'WebAssembly' ⚠ - module: import assertions improvements ℹ This PR was created on Thu, 11 Nov 2021 05:02:37 GMT ✔ Approvals: 5 ✔ - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/40785#pullrequestreview-805386076 ✔ - Bradley Farias (@bmeck): https://github.com/nodejs/node/pull/40785#pullrequestreview-811832395 ✔ - Myles Borins (@MylesBorins) (TSC): https://github.com/nodejs/node/pull/40785#pullrequestreview-806600800 ✔ - Guy Bedford (@guybedford): https://github.com/nodejs/node/pull/40785#pullrequestreview-811839664 ✔ - Antoine du Hamel (@aduh95) (TSC): https://github.com/nodejs/node/pull/40785#pullrequestreview-807849260 ✔ Last GitHub Actions successful ℹ Last Full PR CI on 2021-11-24T04:02:39Z: https://ci.nodejs.org/job/node-test-pull-request/41066/ - Querying data for job/node-test-pull-request/41066/ ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncuhttps://github.com/nodejs/node/actions/runs/1497846338 |
Landed in 7633c86...6dfbf04 |
PR-URL: #40785 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL: #40785 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL: #40785 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL: #40785 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL: nodejs#40785 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL: nodejs#40785 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL: nodejs#40785 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL: nodejs#40785 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This PR implements #40790 (comment), making the following changes to Node’s support for import assertions:
An experimental warning is now printed for all imports with explicitly declared assertion types (currently only JSON).
In the module map, the string
'javascript'
is used instead of a symbol to represent the “default” or implied type, to align with the HTML spec.To align with Chrome and with Prevent modules from being imported with a type: 'javascript' assertion whatwg/html#7350,
assert { type: 'javascript' }
throws an error. (This was the behavior before, but now it’s made explicit since we use'javascript'
internally.)Please see #40790 for the motivation behind these changes, and please use that thread for discussion of the desired functionality. I’d like to limit the discussion on this PR thread to technical concerns. Thanks! cc @nodejs/modules @nodejs/loaders