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
@@ -39,7 +36,7 @@ const DATA_URL_PATTERN = /^[^/]+\/[^,;]+(?:[^,]*?)(;base64)?,([\s\S]*)$/;
3936 */
4037async function getSource ( url , context ) {
4138 const { protocol, href } = url ;
42- let responseURL = href ;
39+ const responseURL = href ;
4340 let source ;
4441 if ( protocol === 'file:' ) {
4542 const { readFile : readFileAsync } = require ( 'internal/fs/promises' ) . exports ;
@@ -51,19 +48,8 @@ async function getSource(url, context) {
5148 }
5249 const { 1 : base64 , 2 : body } = match ;
5350 source = BufferFrom ( decodeURIComponent ( body ) , base64 ? 'base64' : 'utf8' ) ;
54- } else if ( experimentalNetworkImports && (
55- protocol === 'https:' ||
56- protocol === 'http:'
57- ) ) {
58- const { fetchModule } = require ( 'internal/modules/esm/fetch_module' ) ;
59- const res = await fetchModule ( url , context ) ;
60- source = await res . body ;
61- responseURL = res . resolvedHREF ;
6251 } else {
6352 const supportedSchemes = [ 'file' , 'data' ] ;
64- if ( experimentalNetworkImports ) {
65- ArrayPrototypePush ( supportedSchemes , 'http' , 'https' ) ;
66- }
6753 throw new ERR_UNSUPPORTED_ESM_URL_SCHEME ( url , supportedSchemes ) ;
6854 }
6955 return { __proto__ : null , responseURL, source } ;
@@ -121,7 +107,7 @@ async function defaultLoad(url, context = kEmptyObject) {
121107
122108 const urlInstance = new URL ( url ) ;
123109
124- throwIfUnsupportedURLScheme ( urlInstance , experimentalNetworkImports ) ;
110+ throwIfUnsupportedURLScheme ( urlInstance ) ;
125111
126112 if ( urlInstance . protocol === 'node:' ) {
127113 source = null ;
@@ -224,9 +210,8 @@ function defaultLoadSync(url, context = kEmptyObject) {
224210 * throws an error if the protocol is not one of the protocols
225211 * that can be loaded in the default loader
226212 * @param {URL } parsed
227- * @param {boolean } experimentalNetworkImports
228213 */
229- function throwIfUnsupportedURLScheme ( parsed , experimentalNetworkImports ) {
214+ function throwIfUnsupportedURLScheme ( parsed ) {
230215 // Avoid accessing the `protocol` property due to the lazy getters.
231216 const protocol = parsed ?. protocol ;
232217 if (
@@ -235,17 +220,11 @@ function throwIfUnsupportedURLScheme(parsed, experimentalNetworkImports) {
235220 protocol !== 'data:' &&
236221 protocol !== 'node:' &&
237222 (
238- ! experimentalNetworkImports ||
239- (
240- protocol !== 'https:' &&
241- protocol !== 'http:'
242- )
223+ protocol !== 'https:' &&
224+ protocol !== 'http:'
243225 )
244226 ) {
245227 const schemes = [ 'file' , 'data' , 'node' ] ;
246- if ( experimentalNetworkImports ) {
247- ArrayPrototypePush ( schemes , 'https' , 'http' ) ;
248- }
249228 throw new ERR_UNSUPPORTED_ESM_URL_SCHEME ( parsed , schemes ) ;
250229 }
251230}
0 commit comments