Skip to content

Module: Import assertions improvements

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 https://github.com/nodejs/node/discussions/40790#discussioncomment-1673795, 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 https://github.com/whatwg/html/pull/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

Merge request reports

Loading