3
3
const {
4
4
ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING ,
5
5
} = require ( 'internal/errors' ) . codes ;
6
- const assert = require ( 'internal/assert' ) ;
7
6
const { Loader } = require ( 'internal/modules/esm/loader' ) ;
8
7
const {
9
8
hasUncaughtExceptionCaptureCallback,
@@ -26,13 +25,6 @@ exports.initializeImportMetaObject = function(wrap, meta) {
26
25
} ;
27
26
28
27
exports . importModuleDynamicallyCallback = async function ( wrap , specifier ) {
29
- assert ( calledInitialize === true || ! userLoader ) ;
30
- if ( ! calledInitialize ) {
31
- process . emitWarning (
32
- 'The ESM module loader is experimental.' ,
33
- 'ExperimentalWarning' , undefined ) ;
34
- calledInitialize = true ;
35
- }
36
28
const { callbackMap } = internalBinding ( 'module_wrap' ) ;
37
29
if ( callbackMap . has ( wrap ) ) {
38
30
const { importModuleDynamically } = callbackMap . get ( wrap ) ;
@@ -47,15 +39,7 @@ exports.importModuleDynamicallyCallback = async function(wrap, specifier) {
47
39
let ESMLoader = new Loader ( ) ;
48
40
exports . ESMLoader = ESMLoader ;
49
41
50
- let calledInitialize = false ;
51
- async function initializeLoader ( emitWarning ) {
52
- assert ( calledInitialize === false ) ;
53
- if ( emitWarning ) {
54
- process . emitWarning (
55
- 'The ESM module loader is experimental.' ,
56
- 'ExperimentalWarning' , undefined ) ;
57
- }
58
- calledInitialize = true ;
42
+ async function initializeLoader ( ) {
59
43
if ( ! userLoader )
60
44
return ;
61
45
let cwd ;
@@ -78,9 +62,9 @@ async function initializeLoader(emitWarning) {
78
62
} ) ( ) ;
79
63
}
80
64
81
- exports . loadESM = async function loadESM ( callback , emitWarning = true ) {
65
+ exports . loadESM = async function loadESM ( callback ) {
82
66
try {
83
- await initializeLoader ( emitWarning ) ;
67
+ await initializeLoader ( ) ;
84
68
await callback ( ESMLoader ) ;
85
69
} catch ( err ) {
86
70
if ( hasUncaughtExceptionCaptureCallback ( ) ) {
0 commit comments