-
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
esm: add --experimental-import-non-javascript-without-assertion
flag
#40210
esm: add --experimental-import-non-javascript-without-assertion
flag
#40210
Conversation
Restricts import of JSON modules to the assertion form only, unless the `--experimental-import-non-javascript-without-assertion` CLI flag is provided.
1fffc54
to
7da6afc
Compare
An attempt was made to impor without an assertion a module that requires a | ||
specific import assertion to be loaded. |
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.
An attempt was made to impor without an assertion a module that requires a | |
specific import assertion to be loaded. | |
An attempt was made to import a module without an assertion that requires | |
a specific import assertion to be loaded. |
@@ -54,6 +54,10 @@ executed in specific contexts. | |||
<!-- YAML | |||
added: v0.3.1 | |||
changes: | |||
- version: REPLACEME | |||
pr-url: https://github.com/nodejs/node/pull/39921 | |||
description: Added suppoort of import assertions to the |
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.
description: Added suppoort of import assertions to the | |
description: Added support of import assertions to the |
Typo.
changes: | ||
- version: REPLACEME | ||
pr-url: https://github.com/nodejs/node/pull/39921 | ||
description: Added suppoort of import assertions to the |
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.
description: Added suppoort of import assertions to the | |
description: Added support of import assertions to the |
Typo.
@@ -852,6 +867,10 @@ const vm = require('vm'); | |||
<!-- YAML | |||
added: v10.10.0 | |||
changes: | |||
- version: REPLACEME | |||
pr-url: https://github.com/nodejs/node/pull/39921 | |||
description: Added suppoort of import assertions to the |
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.
description: Added suppoort of import assertions to the | |
description: Added support of import assertions to the |
Typo.
@@ -1068,6 +1089,10 @@ vm.measureMemory({ mode: 'detailed', execution: 'eager' }) | |||
<!-- YAML | |||
added: v0.3.1 | |||
changes: | |||
- version: REPLACEME | |||
pr-url: https://github.com/nodejs/node/pull/39921 | |||
description: Added suppoort of import assertions to the |
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.
description: Added suppoort of import assertions to the | |
description: Added support of import assertions to the |
Typo.
@@ -1145,6 +1172,10 @@ console.log(contextObject); | |||
<!-- YAML | |||
added: v0.3.1 | |||
changes: | |||
- version: REPLACEME | |||
pr-url: https://github.com/nodejs/node/pull/39921 | |||
description: Added suppoort of import assertions to the |
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.
description: Added suppoort of import assertions to the | |
description: Added support of import assertions to the |
Typo.
@@ -1247,6 +1280,10 @@ console.log(contextObject); | |||
<!-- YAML | |||
added: v0.3.1 | |||
changes: | |||
- version: REPLACEME | |||
pr-url: https://github.com/nodejs/node/pull/39921 | |||
description: Added suppoort of import assertions to the |
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.
description: Added suppoort of import assertions to the | |
description: Added support of import assertions to the |
Typo.
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.
As I wrote in #39921 (comment), I don’t support adding the ability for an import
statement to optionally have an assertion or not. Even though it’s behind a flag, this is complexity that loaders will need to support as soon as it’s in the Node codebase. Until it becomes clear that supporting both forms for the same file type is required by spec or use case, I don’t want to incur the complexity and maintenance burden of supporting this. This was also the path forward agreed at yesterday’s TSC meeting.
I would be happy to support a PR that adds an assertion syntax requirement for JSON modules, with nothing more.
I think we need to discuss at some point what are the technical challenges of supporting both syntaxes and (how) can they be overcome?. If we find out that there are unsolvable technical road blocks, then this PR can be closed, the current experimental JSON support can be removed and a good chunk of #39921 can be re-written. It would also be certainly useful info for TC39 in case future proposal are raised to bring assertionless syntax to other formats. What I take out of the TSC meeting that we needed to ship/unflag first the syntax with assertions, and discuss unflagging the assertionless syntax later. I didn't understand that we meant removing the assertionless implementation completely – and I don't think we should unless there is a technical blocker (but I won't block a PR doing that to be clear). Sure if you plan on having a alternative PR, I'm fine waiting for it to be opened before having the discussion, or sooner if it fits better the loaders agenda. |
Any chance we could shorten that up? |
That's not my recollection of the TSC meeting. I also don't see the point in doing an analysis of the difficulty of supporting two syntaxes. It's obviously more complex than only supporting one per type, and that's enough. I don't find the use case compelling enough to justify supporting such complexity. |
It’s not an analysis of the difficulty, but the feasibility: it’s clear that some folks want to have this feature, so this discussion need to happen at some point. My thinking if it is possible to support both syntaxes, it would be counterproductive to remove it when the PR to make it work is already available, but feel free to disagree on that. If the conclusion of said discussion is: “it’s not it’s actually possible to support both for X reason”, it would help unblock the crispation around JSON module unflagging I think. |
Removing |
Closing as #40250 is the version under active development. |
Restricts import of JSON modules to the assertion form only, unless the
--experimental-import-non-javascript-without-assertion
CLI flag is provided.The first two commits are from #39921, which should land before this one.
This PR aims to help unblock #37375 by allowing unflagging only the assertion-required JSON imports first, leaving the unflagging of assertionless form for a later time.