33const {
44 ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING ,
55} = require ( 'internal/errors' ) . codes ;
6- const assert = require ( 'internal/assert' ) ;
76const { Loader } = require ( 'internal/modules/esm/loader' ) ;
87const {
98 hasUncaughtExceptionCaptureCallback,
@@ -26,13 +25,6 @@ exports.initializeImportMetaObject = function(wrap, meta) {
2625} ;
2726
2827exports . 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- }
3628 const { callbackMap } = internalBinding ( 'module_wrap' ) ;
3729 if ( callbackMap . has ( wrap ) ) {
3830 const { importModuleDynamically } = callbackMap . get ( wrap ) ;
@@ -47,15 +39,7 @@ exports.importModuleDynamicallyCallback = async function(wrap, specifier) {
4739let ESMLoader = new Loader ( ) ;
4840exports . ESMLoader = ESMLoader ;
4941
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 ( ) {
5943 if ( ! userLoader )
6044 return ;
6145 let cwd ;
@@ -78,9 +62,9 @@ async function initializeLoader(emitWarning) {
7862 } ) ( ) ;
7963}
8064
81- exports . loadESM = async function loadESM ( callback , emitWarning = true ) {
65+ exports . loadESM = async function loadESM ( callback ) {
8266 try {
83- await initializeLoader ( emitWarning ) ;
67+ await initializeLoader ( ) ;
8468 await callback ( ESMLoader ) ;
8569 } catch ( err ) {
8670 if ( hasUncaughtExceptionCaptureCallback ( ) ) {
0 commit comments