Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Change warning to be specific to --experimental-loader
  • Loading branch information
GeoffreyBooth authored and aduh95 committed Sep 16, 2023
commit 69371c996241138f21c8a793ae62bd9966cc0cec
8 changes: 8 additions & 0 deletions lib/internal/modules/esm/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ class CustomizedModuleLoader {
}
}

let emittedLoaderFlagWarning = false;
/**
* A loader instance is used as the main entry point for loading ES modules. Currently, this is a singleton; there is
* only one used for loading the main module and everything in its dependency graph, though separate instances of this
Expand All @@ -514,6 +515,13 @@ function createModuleLoader(useCustomLoadersIfPresent = true) {
!require('internal/modules/esm/utils').isLoaderWorker()) {
const userLoaderPaths = getOptionValue('--experimental-loader');
if (userLoaderPaths.length > 0) {
if (!emittedLoaderFlagWarning) {
process.emitWarning(
'`--experimental-loader` may be removed in the future; instead use `--import` to reference a file that calls `register()`',
Comment thread
GeoffreyBooth marked this conversation as resolved.
Outdated
'ExperimentalWarning',
);
emittedLoaderFlagWarning = true;
}
customizations = new CustomizedModuleLoader();
}
}
Expand Down
4 changes: 4 additions & 0 deletions test/es-module/test-esm-experimental-warnings.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ describe('ESM: warn for obsolete hooks provided', { concurrency: true }, () => {
describe('experimental warnings for enabled experimental feature', () => {
for (
const [experiment, arg] of [
Comment thread
GeoffreyBooth marked this conversation as resolved.
Outdated
[
/`--experimental-loader` may be removed in the future/,
`--experimental-loader=${fileurl("https://github.com/nodejs/node/pull/49633/commits/'es-module-loaders',%20'hooks-custom.mjs'")}`
Comment thread
GeoffreyBooth marked this conversation as resolved.
Outdated
],
[/Network Imports/, '--experimental-network-imports'],
]
) {
Expand Down