Skip to content

Commit

Permalink
fixup! drop --experimental-network-imports
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelGSS committed Jul 24, 2024
1 parent 2bbb4e9 commit fd75cb4
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 402 deletions.
2 changes: 1 addition & 1 deletion doc/api/module.md
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ behaviors.
#### Import from HTTPS
In current Node.js, specifiers starting with `https://` are experimental (see
[HTTPS and HTTP imports][]).
\[HTTPS and HTTP imports]\[]).

The hook below registers hooks to enable rudimentary support for such
specifiers. While this may seem like a significant improvement to Node.js core
Expand Down
31 changes: 5 additions & 26 deletions lib/internal/modules/esm/load.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const {
ArrayPrototypePush,
RegExpPrototypeExec,
decodeURIComponent,
} = primordials;
Expand All @@ -12,8 +11,6 @@ const { validateAttributes, emitImportAssertionWarning } = require('internal/mod
const { getOptionValue } = require('internal/options');
const { readFileSync } = require('fs');

const experimentalNetworkImports =
getOptionValue('--experimental-network-imports');
const defaultType =
getOptionValue('--experimental-default-type');

Expand Down Expand Up @@ -47,19 +44,8 @@ async function getSource(url, context) {
}
const { 1: base64, 2: body } = match;
source = BufferFrom(decodeURIComponent(body), base64 ? 'base64' : 'utf8');
} else if (experimentalNetworkImports && (
protocol === 'https:' ||
protocol === 'http:'
)) {
const { fetchModule } = require('internal/modules/esm/fetch_module');
const res = await fetchModule(url, context);
source = await res.body;
responseURL = res.resolvedHREF;
} else {
} else {

Check failure on line 47 in lib/internal/modules/esm/load.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Multiple spaces found before 'else'
const supportedSchemes = ['file', 'data'];
if (experimentalNetworkImports) {
ArrayPrototypePush(supportedSchemes, 'http', 'https');
}
throw new ERR_UNSUPPORTED_ESM_URL_SCHEME(url, supportedSchemes);
}
return { __proto__: null, responseURL, source };
Expand Down Expand Up @@ -117,7 +103,7 @@ async function defaultLoad(url, context = kEmptyObject) {

const urlInstance = new URL(url);

throwIfUnsupportedURLScheme(urlInstance, experimentalNetworkImports);
throwIfUnsupportedURLScheme(urlInstance);

if (urlInstance.protocol === 'node:') {
source = null;
Expand Down Expand Up @@ -214,9 +200,8 @@ function defaultLoadSync(url, context = kEmptyObject) {
* throws an error if the protocol is not one of the protocols
* that can be loaded in the default loader
* @param {URL} parsed
* @param {boolean} experimentalNetworkImports
*/
function throwIfUnsupportedURLScheme(parsed, experimentalNetworkImports) {
function throwIfUnsupportedURLScheme(parsed) {
// Avoid accessing the `protocol` property due to the lazy getters.
const protocol = parsed?.protocol;
if (
Expand All @@ -225,17 +210,11 @@ function throwIfUnsupportedURLScheme(parsed, experimentalNetworkImports) {
protocol !== 'data:' &&
protocol !== 'node:' &&
(
!experimentalNetworkImports ||
(
protocol !== 'https:' &&
protocol !== 'http:'
)
protocol !== 'https:' &&
protocol !== 'http:'
)
) {
const schemes = ['file', 'data', 'node'];
if (experimentalNetworkImports) {
ArrayPrototypePush(schemes, 'https', 'http');
}
throw new ERR_UNSUPPORTED_ESM_URL_SCHEME(parsed, schemes);
}
}
Expand Down
3 changes: 0 additions & 3 deletions lib/internal/modules/esm/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,6 @@ class ModuleLoader {
#customizations;

constructor(customizations) {
if (getOptionValue('--experimental-network-imports')) {
emitExperimentalWarning('Network Imports');
}
this.setCustomizations(customizations);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/internal/modules/esm/resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@ function defaultResolve(specifier, context = {}) {
// Avoid accessing the `protocol` property due to the lazy getters.
protocol = parsed.protocol;

if (protocol === 'data:' ) {
if (protocol === 'data:') {
return { __proto__: null, url: parsed.href };
}
}
Expand Down
1 change: 0 additions & 1 deletion test/es-module/test-esm-experimental-warnings.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ describe('ESM: warn for obsolete hooks provided', { concurrency: !process.env.TE
'--experimental-loader',
fileURL('es-module-loaders', 'hooks-custom.mjs'),
],
[/Network Imports/, '--experimental-network-imports'],
]
) {
it(`should print for ${experiment.toString().replaceAll('/', '')}`, async () => {
Expand Down
48 changes: 0 additions & 48 deletions test/es-module/test-http-imports-cli.mjs

This file was deleted.

Loading

0 comments on commit fd75cb4

Please sign in to comment.