11'use strict' ;
22
33const {
4- ArrayPrototypePush,
54 RegExpPrototypeExec,
65 decodeURIComponent,
76} = primordials ;
@@ -12,8 +11,6 @@ const { validateAttributes, emitImportAssertionWarning } = require('internal/mod
1211const { getOptionValue } = require ( 'internal/options' ) ;
1312const { readFileSync } = require ( 'fs' ) ;
1413
15- const experimentalNetworkImports =
16- getOptionValue ( '--experimental-network-imports' ) ;
1714const defaultType =
1815 getOptionValue ( '--experimental-default-type' ) ;
1916
@@ -47,19 +44,8 @@ async function getSource(url, context) {
4744 }
4845 const { 1 : base64 , 2 : body } = match ;
4946 source = BufferFrom ( decodeURIComponent ( body ) , base64 ? 'base64' : 'utf8' ) ;
50- } else if ( experimentalNetworkImports && (
51- protocol === 'https:' ||
52- protocol === 'http:'
53- ) ) {
54- const { fetchModule } = require ( 'internal/modules/esm/fetch_module' ) ;
55- const res = await fetchModule ( url , context ) ;
56- source = await res . body ;
57- responseURL = res . resolvedHREF ;
58- } else {
47+ } else {
5948 const supportedSchemes = [ 'file' , 'data' ] ;
60- if ( experimentalNetworkImports ) {
61- ArrayPrototypePush ( supportedSchemes , 'http' , 'https' ) ;
62- }
6349 throw new ERR_UNSUPPORTED_ESM_URL_SCHEME ( url , supportedSchemes ) ;
6450 }
6551 return { __proto__ : null , responseURL, source } ;
@@ -117,7 +103,7 @@ async function defaultLoad(url, context = kEmptyObject) {
117103
118104 const urlInstance = new URL ( url ) ;
119105
120- throwIfUnsupportedURLScheme ( urlInstance , experimentalNetworkImports ) ;
106+ throwIfUnsupportedURLScheme ( urlInstance ) ;
121107
122108 if ( urlInstance . protocol === 'node:' ) {
123109 source = null ;
@@ -214,9 +200,8 @@ function defaultLoadSync(url, context = kEmptyObject) {
214200 * throws an error if the protocol is not one of the protocols
215201 * that can be loaded in the default loader
216202 * @param {URL } parsed
217- * @param {boolean } experimentalNetworkImports
218203 */
219- function throwIfUnsupportedURLScheme ( parsed , experimentalNetworkImports ) {
204+ function throwIfUnsupportedURLScheme ( parsed ) {
220205 // Avoid accessing the `protocol` property due to the lazy getters.
221206 const protocol = parsed ?. protocol ;
222207 if (
@@ -225,17 +210,11 @@ function throwIfUnsupportedURLScheme(parsed, experimentalNetworkImports) {
225210 protocol !== 'data:' &&
226211 protocol !== 'node:' &&
227212 (
228- ! experimentalNetworkImports ||
229- (
230- protocol !== 'https:' &&
231- protocol !== 'http:'
232- )
213+ protocol !== 'https:' &&
214+ protocol !== 'http:'
233215 )
234216 ) {
235217 const schemes = [ 'file' , 'data' , 'node' ] ;
236- if ( experimentalNetworkImports ) {
237- ArrayPrototypePush ( schemes , 'https' , 'http' ) ;
238- }
239218 throw new ERR_UNSUPPORTED_ESM_URL_SCHEME ( parsed , schemes ) ;
240219 }
241220}
0 commit comments