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

Module: Import assertions improvements #40785

Closed

Conversation

GeoffreyBooth
Copy link
Member

@GeoffreyBooth GeoffreyBooth commented Nov 11, 2021

Please use #40790 for “product” or “feature” discussion, so that the discussion on this PR thread can stay focused on technical feedback.

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

@GeoffreyBooth GeoffreyBooth added module Issues and PRs related to the module subsystem. esm Issues and PRs related to the ECMAScript Modules implementation. loaders Issues and PRs related to ES module loaders labels Nov 11, 2021
@GeoffreyBooth GeoffreyBooth self-assigned this Nov 11, 2021
@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Nov 11, 2021
doc/api/esm.md Outdated Show resolved Hide resolved
test/es-module/test-esm-assertionless-javascript-import.js Outdated Show resolved Hide resolved
test/es-module/test-esm-assertionless-javascript-import.js Outdated Show resolved Hide resolved
Copy link
Member

@bmeck bmeck left a 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

@bmeck
Copy link
Member

bmeck commented Nov 15, 2021

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.

Copy link
Contributor

@MylesBorins MylesBorins left a 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
Copy link
Contributor

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?

Copy link
Member Author

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.

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

Copy link
Contributor

@guybedford guybedford left a 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:

  1. 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.
  2. 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.

@nodejs-github-bot

This comment has been minimized.

@GeoffreyBooth GeoffreyBooth removed the needs-ci PRs that need a full CI run. label Nov 16, 2021
Copy link
Contributor

@aduh95 aduh95 left a 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.

test/es-module/test-esm-assertionless-javascript-import.js Outdated Show resolved Hide resolved
doc/api/esm.md Outdated Show resolved Hide resolved
@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot
Copy link
Collaborator

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/.ncu
https://github.com/nodejs/node/actions/runs/1497846338

@aduh95 aduh95 added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. and removed commit-queue-failed An error occurred while landing this pull request using GitHub Actions. labels Nov 24, 2021
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Nov 24, 2021
@nodejs-github-bot
Copy link
Collaborator

Landed in 7633c86...6dfbf04

nodejs-github-bot pushed a commit that referenced this pull request Nov 24, 2021
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>
nodejs-github-bot pushed a commit that referenced this pull request Nov 24, 2021
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>
@ljharb ljharb deleted the more-import-assertion-types branch November 24, 2021 15:52
targos pushed a commit that referenced this pull request Nov 26, 2021
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>
targos pushed a commit that referenced this pull request Nov 26, 2021
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>
aduh95 pushed a commit to aduh95/node that referenced this pull request Jan 30, 2022
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>
aduh95 pushed a commit to aduh95/node that referenced this pull request Jan 30, 2022
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>
aduh95 pushed a commit to aduh95/node that referenced this pull request Jan 31, 2022
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>
aduh95 pushed a commit to aduh95/node that referenced this pull request Jan 31, 2022
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>
danielleadams pushed a commit that referenced this pull request Feb 1, 2022
PR-URL: #40785
Backport-PR-URL: #41776
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>
danielleadams pushed a commit that referenced this pull request Feb 1, 2022
PR-URL: #40785
Backport-PR-URL: #41776
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>
@danielleadams danielleadams mentioned this pull request Feb 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. esm Issues and PRs related to the ECMAScript Modules implementation. loaders Issues and PRs related to ES module loaders module Issues and PRs related to the module subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants