1
1
import { Loader , ModuleNamespace , REGISTRY } from './loader-polyfill.js' ;
2
2
import { resolveIfNotPlain } from './resolve.js' ;
3
- import { addToError , global , createSymbol , baseURI } from './common.js' ;
3
+ import { addToError , global , createSymbol , baseURI , toStringTag } from './common.js' ;
4
4
5
5
export default RegisterLoader ;
6
6
@@ -204,7 +204,7 @@ function instantiate (loader, load, link, registry, state) {
204
204
. then ( function ( instantiation ) {
205
205
// direct module return from instantiate -> we're done
206
206
if ( instantiation !== undefined ) {
207
- if ( ! ( instantiation instanceof ModuleNamespace ) )
207
+ if ( ! ( instantiation instanceof ModuleNamespace || instantiation [ toStringTag ] === 'module' ) )
208
208
throw new TypeError ( 'Instantiate did not return a valid Module object.' ) ;
209
209
210
210
delete state . records [ load . key ] ;
@@ -379,7 +379,7 @@ function instantiateDeps (loader, load, link, registry, state) {
379
379
if ( setter ) {
380
380
var instantiation = dependencyInstantiations [ i ] ;
381
381
382
- if ( instantiation instanceof ModuleNamespace ) {
382
+ if ( instantiation instanceof ModuleNamespace || instantiation [ toStringTag ] === 'module' ) {
383
383
setter ( instantiation ) ;
384
384
}
385
385
else {
@@ -428,7 +428,7 @@ function deepInstantiateDeps (loader, load, link, registry, state) {
428
428
var depPromises = [ ] ;
429
429
for ( let i = 0 ; i < link . dependencies . length ; i ++ ) {
430
430
var depLoad = link . dependencyInstantiations [ i ] ;
431
- if ( ! ( depLoad instanceof ModuleNamespace ) )
431
+ if ( ! ( depLoad instanceof ModuleNamespace || depLoad [ toStringTag ] === 'module' ) )
432
432
depPromises . push ( addDeps ( depLoad , depLoad . linkRecord ) ) ;
433
433
}
434
434
return Promise . all ( depPromises ) ;
@@ -524,7 +524,7 @@ function makeDynamicRequire (loader, key, dependencies, dependencyInstantiations
524
524
var depLoad = dependencyInstantiations [ i ] ;
525
525
var module ;
526
526
527
- if ( depLoad instanceof ModuleNamespace )
527
+ if ( depLoad instanceof ModuleNamespace || depLoad [ toStringTag ] === 'module' )
528
528
module = depLoad ;
529
529
else
530
530
module = ensureEvaluate ( loader , depLoad , depLoad . linkRecord , registry , state , seen ) ;
@@ -550,7 +550,7 @@ function doEvaluate (loader, load, link, registry, state, seen) {
550
550
for ( var i = 0 ; i < link . dependencies . length ; i ++ ) {
551
551
depLoad = link . dependencyInstantiations [ i ] ;
552
552
553
- if ( depLoad instanceof ModuleNamespace )
553
+ if ( depLoad instanceof ModuleNamespace || depLoad [ toStringTag ] === 'module' )
554
554
continue ;
555
555
556
556
// custom Module returned from instantiate
0 commit comments