Skip to content

Commit fd75cb4

Browse files
committed
fixup! drop --experimental-network-imports
1 parent 2bbb4e9 commit fd75cb4

File tree

8 files changed

+7
-402
lines changed

8 files changed

+7
-402
lines changed

doc/api/module.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ behaviors.
717717
#### Import from HTTPS
718718
719719
In current Node.js, specifiers starting with `https://` are experimental (see
720-
[HTTPS and HTTP imports][]).
720+
\[HTTPS and HTTP imports]\[]).
721721

722722
The hook below registers hooks to enable rudimentary support for such
723723
specifiers. While this may seem like a significant improvement to Node.js core

lib/internal/modules/esm/load.js

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

33
const {
4-
ArrayPrototypePush,
54
RegExpPrototypeExec,
65
decodeURIComponent,
76
} = primordials;
@@ -12,8 +11,6 @@ const { validateAttributes, emitImportAssertionWarning } = require('internal/mod
1211
const { getOptionValue } = require('internal/options');
1312
const { readFileSync } = require('fs');
1413

15-
const experimentalNetworkImports =
16-
getOptionValue('--experimental-network-imports');
1714
const 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
}

lib/internal/modules/esm/loader.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,6 @@ class ModuleLoader {
145145
#customizations;
146146

147147
constructor(customizations) {
148-
if (getOptionValue('--experimental-network-imports')) {
149-
emitExperimentalWarning('Network Imports');
150-
}
151148
this.setCustomizations(customizations);
152149
}
153150

lib/internal/modules/esm/resolve.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ function defaultResolve(specifier, context = {}) {
10101010
// Avoid accessing the `protocol` property due to the lazy getters.
10111011
protocol = parsed.protocol;
10121012

1013-
if (protocol === 'data:' ) {
1013+
if (protocol === 'data:') {
10141014
return { __proto__: null, url: parsed.href };
10151015
}
10161016
}

test/es-module/test-esm-experimental-warnings.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ describe('ESM: warn for obsolete hooks provided', { concurrency: !process.env.TE
3030
'--experimental-loader',
3131
fileURL('es-module-loaders', 'hooks-custom.mjs'),
3232
],
33-
[/Network Imports/, '--experimental-network-imports'],
3433
]
3534
) {
3635
it(`should print for ${experiment.toString().replaceAll('/', '')}`, async () => {

test/es-module/test-http-imports-cli.mjs

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)