@@ -11,7 +11,6 @@ const {
11
11
ERR_INVALID_RETURN_PROPERTY ,
12
12
ERR_INVALID_RETURN_PROPERTY_VALUE ,
13
13
ERR_INVALID_RETURN_VALUE ,
14
- ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK ,
15
14
ERR_UNKNOWN_MODULE_FORMAT
16
15
} = require ( 'internal/errors' ) . codes ;
17
16
const { URL , pathToFileURL } = require ( 'internal/url' ) ;
@@ -28,14 +27,10 @@ const { defaultGetSource } = require(
28
27
'internal/modules/esm/get_source' ) ;
29
28
const { defaultTransformSource } = require (
30
29
'internal/modules/esm/transform_source' ) ;
31
- const createDynamicModule = require (
32
- 'internal/modules/esm/create_dynamic_module' ) ;
33
30
const { translators } = require (
34
31
'internal/modules/esm/translators' ) ;
35
32
const { getOptionValue } = require ( 'internal/options' ) ;
36
33
37
- const debug = require ( 'internal/util/debuglog' ) . debuglog ( 'esm' ) ;
38
-
39
34
/* A Loader instance is used as the main entry point for loading ES modules.
40
35
* Currently, this is a singleton -- there is only one used for loading
41
36
* the main module and everything in its dependency graph. */
@@ -68,23 +63,13 @@ class Loader {
68
63
// This hook is called after the module is resolved but before a translator
69
64
// is chosen to load it; the format returned by this function is the name
70
65
// of a translator.
71
- // If `.format` on the returned value is 'dynamic', .dynamicInstantiate
72
- // will be used as described below.
73
66
this . _getFormat = defaultGetFormat ;
74
67
// This hook is called just before the source code of an ES module file
75
68
// is loaded.
76
69
this . _getSource = defaultGetSource ;
77
70
// This hook is called just after the source code of an ES module file
78
71
// is loaded, but before anything is done with the string.
79
72
this . _transformSource = defaultTransformSource ;
80
- // This hook is only called when getFormat is 'dynamic' and
81
- // has the signature
82
- // (url : string) -> Promise<{ exports: { ... }, execute: function }>
83
- // Where `exports` is an object whose property names define the exported
84
- // names of the generated module. `execute` is a function that receives
85
- // an object with the same keys as `exports`, whose values are get/set
86
- // functions for the actual exported values.
87
- this . _dynamicInstantiate = undefined ;
88
73
// The index for assigning unique URLs to anonymous module evaluation
89
74
this . evalIndex = 0 ;
90
75
}
@@ -138,7 +123,6 @@ class Loader {
138
123
}
139
124
140
125
if ( this . _resolve === defaultResolve &&
141
- format !== 'dynamic' &&
142
126
! url . startsWith ( 'file:' ) &&
143
127
! url . startsWith ( 'data:' )
144
128
) {
@@ -193,8 +177,8 @@ class Loader {
193
177
if ( resolve !== undefined )
194
178
this . _resolve = FunctionPrototypeBind ( resolve , null ) ;
195
179
if ( dynamicInstantiate !== undefined ) {
196
- this . _dynamicInstantiate =
197
- FunctionPrototypeBind ( dynamicInstantiate , null ) ;
180
+ process . emitWarning (
181
+ 'The dynamicInstantiate loader hook has been removed.' ) ;
198
182
}
199
183
if ( getFormat !== undefined ) {
200
184
this . _getFormat = FunctionPrototypeBind ( getFormat , null ) ;
@@ -248,25 +232,10 @@ class Loader {
248
232
if ( job !== undefined )
249
233
return job ;
250
234
251
- let loaderInstance ;
252
- if ( format === 'dynamic' ) {
253
- if ( typeof this . _dynamicInstantiate !== 'function' )
254
- throw new ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK ( ) ;
255
-
256
- loaderInstance = async ( url ) => {
257
- debug ( `Translating dynamic ${ url } ` ) ;
258
- const { exports, execute } = await this . _dynamicInstantiate ( url ) ;
259
- return createDynamicModule ( [ ] , exports , url , ( reflect ) => {
260
- debug ( `Loading dynamic ${ url } ` ) ;
261
- execute ( reflect . exports ) ;
262
- } ) . module ;
263
- } ;
264
- } else {
265
- if ( ! translators . has ( format ) )
266
- throw new ERR_UNKNOWN_MODULE_FORMAT ( format ) ;
235
+ if ( ! translators . has ( format ) )
236
+ throw new ERR_UNKNOWN_MODULE_FORMAT ( format ) ;
267
237
268
- loaderInstance = translators . get ( format ) ;
269
- }
238
+ const loaderInstance = translators . get ( format ) ;
270
239
271
240
const inspectBrk = parentURL === undefined &&
272
241
format === 'module' && getOptionValue ( '--inspect-brk' ) ;
0 commit comments