File tree 2 files changed +30
-0
lines changed
2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,21 @@ v8::MaybeLocal<v8::Module> resolveCallback(v8::Local<v8::Context> context,
22
22
auto & js = jsg::Lock::from (context->GetIsolate ());
23
23
v8::MaybeLocal<v8::Module> result;
24
24
25
+ // TODO(new-module-registry): The specification for import assertions strongly
26
+ // recommends that embedders reject import attributes and types they do not
27
+ // understand/implement. This is because import attributes can alter the
28
+ // interpretation of a module and are considered to be part of the unique
29
+ // key for caching a module.
30
+ // Throwing an error for things we do not understand is the safest thing to do.
31
+ // However, historically we have not followed this guideline in the spec and
32
+ // it's not clear if enforcing that constraint would be breaking so let's
33
+ // first try to determine if anyone is making use of import assertions.
34
+ // If we're lucky, we won't receive any hits on this and we can start
35
+ // enforcing the rule without a compat flag.
36
+ if (import_assertions->Length () > 0 ) {
37
+ LOG_NOSENTRY (WARNING, " Import attributes specified (and ignored) on static import" );
38
+ }
39
+
25
40
js.tryCatch ([&] {
26
41
auto registry = getModulesForResolveCallback (js.v8Isolate );
27
42
KJ_REQUIRE (registry != nullptr , " didn't expect resolveCallback() now" );
Original file line number Diff line number Diff line change @@ -645,6 +645,21 @@ v8::MaybeLocal<v8::Promise> dynamicImportCallback(v8::Local<v8::Context> context
645
645
auto registry = ModuleRegistry::from (js);
646
646
auto & wrapper = TypeWrapper::from (js.v8Isolate );
647
647
648
+ // TODO(new-module-registry): The specification for import assertions strongly
649
+ // recommends that embedders reject import attributes and types they do not
650
+ // understand/implement. This is because import attributes can alter the
651
+ // interpretation of a module and are considered to be part of the unique
652
+ // key for caching a module.
653
+ // Throwing an error for things we do not understand is the safest thing to do.
654
+ // However, historically we have not followed this guideline in the spec and
655
+ // it's not clear if enforcing that constraint would be breaking so let's
656
+ // first try to determine if anyone is making use of import assertions.
657
+ // If we're lucky, we won't receive any hits on this and we can start
658
+ // enforcing the rule without a compat flag.
659
+ if (import_assertions->Length () > 0 ) {
660
+ LOG_NOSENTRY (WARNING, " Import attributes specified (and ignored) on dynamic import" );
661
+ }
662
+
648
663
// TODO(cleanup): This could probably be simplified using jsg::Promise
649
664
const auto makeRejected = [&](auto reason) {
650
665
v8::Local<v8::Promise::Resolver> resolver;
You can’t perform that action at this time.
0 commit comments