vm: add support for import assertions in dynamic imports#40249
vm: add support for import assertions in dynamic imports#40249aduh95 wants to merge 2 commits intonodejs:masterfrom
Conversation
|
Ping @nodejs/vm @nodejs/modules for reviews. |
bmeck
left a comment
There was a problem hiding this comment.
Assert enforcement of spec for "type": "json" isn't in place but this is still experimental and I honestly don't have a clean way to enforce it even if we wanted to. We could treat this as a power/debugging tool which often lies outside of the spec? Seems fine for now but should revisit decision before unflagging.
|
In #40250 (comment) I asked if this could wait until that PR lands, or if this could land as part of that PR. There’s an unresolved discussion there about when and whether import assertions should be passed around between internal functions, which is what this PR adds; so it seems premature to land this until we’ve settled that question. |
|
@GeoffreyBooth I've opened this PR to separate the changes in
That being said, of course I'm OK waiting if there are concerns, but if there are none, I'd rather have it landed, and a future PR can change the implementation again if it turns out being necessary. |
guybedford
left a comment
There was a problem hiding this comment.
Seems like a nice simple change, and since VM doesn't relate to cache keying questions at all I don't see any reason not to land this.
src/module_wrap.cc
Outdated
| Local<Object> assertions = | ||
| Object::New(isolate, v8::Null(env->isolate()), nullptr, nullptr, 0); | ||
| for (int i = 0; i < import_assertions->Length(); i += 2) { | ||
| assertions | ||
| ->Set(env->context(), | ||
| Local<String>::Cast(import_assertions->Get(env->context(), i)), | ||
| Local<Value>::Cast(import_assertions->Get(env->context(), i + 1))) | ||
| .ToChecked(); | ||
| } |
There was a problem hiding this comment.
if possible it might be good to dedupe this code with the static import path so they stay consistent
9c2964f to
adf6993
Compare
GeoffreyBooth
left a comment
There was a problem hiding this comment.
I discussed with @aduh95; my concern about the function signature was whether the assertions would become part of the cache key. He tells me that he thinks that won’t be the case, in this PR at least. So I think this should be fine to land.
|
Landed in 879ff77...08ffbd1 |
PR-URL: #40249 Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
PR-URL: #40249 Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Notable Changes: Experimental ESM Loader Hooks API: Node.js ESM Loader hooks have been consolidated to represent the steps involved needed to facilitate future loader chaining: 1. `resolve`: `resolve` [+ `getFormat`] 2. `load`: `getFormat` + `getSource` + `transformSource` For consistency, `getGlobalPreloadCode` has been renamed to `globalPreload`. A loader exporting obsolete hook(s) will trigger a single deprecation warning (per loader) listing the errant hooks. Contributed by Jacob Smith, Geoffrey Booth, and Bradley Farias - #37468 Other Notable Changes: deps: * upgrade npm to 8.1.0 (npm team) #40463 doc: * deprecate (doc-only) http abort related (dr-js) #36670 vm: * (SEMVER-MINOR) add support for import assertions in dynamic imports (Antoine du Hamel) #40249 PR-URL: #40504
Notable Changes: Experimental ESM Loader Hooks API: Node.js ESM Loader hooks have been consolidated to represent the steps involved needed to facilitate future loader chaining: 1. `resolve`: `resolve` [+ `getFormat`] 2. `load`: `getFormat` + `getSource` + `transformSource` For consistency, `getGlobalPreloadCode` has been renamed to `globalPreload`. A loader exporting obsolete hook(s) will trigger a single deprecation warning (per loader) listing the errant hooks. Contributed by Jacob Smith, Geoffrey Booth, and Bradley Farias - #37468 Other Notable Changes: deps: * upgrade npm to 8.1.0 (npm team) #40463 doc: * deprecate (doc-only) http abort related (dr-js) #36670 vm: * (SEMVER-MINOR) add support for import assertions in dynamic imports (Antoine du Hamel) #40249 PR-URL: #40504
|
Running Node 16.13.2, I see the following when I try to specify an import assertion on a dynamic I think Node 16.3.2 includes this commit, but I'm guessing there's another one that's necessary in order for this to work? Thanks in advance for any response, and sorry for pinging the PR like this. |
|
You need to use the |
No description provided.