Skip to content

Commit 70b1a64

Browse files
committed
Change warning to be specific to --experimental-loader
1 parent 4bcad10 commit 70b1a64

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/internal/modules/esm/loader.js

+8
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ class CustomizedModuleLoader {
498498
}
499499
}
500500

501+
let emittedLoaderFlagWarning = false;
501502
/**
502503
* A loader instance is used as the main entry point for loading ES modules. Currently, this is a singleton; there is
503504
* only one used for loading the main module and everything in its dependency graph, though separate instances of this
@@ -513,6 +514,13 @@ function createModuleLoader(useCustomLoadersIfPresent = true) {
513514
!require('internal/modules/esm/utils').isLoaderWorker()) {
514515
const userLoaderPaths = getOptionValue('--experimental-loader');
515516
if (userLoaderPaths.length > 0) {
517+
if (!emittedLoaderFlagWarning) {
518+
process.emitWarning(
519+
'`--experimental-loader` may be removed in the future; instead use `--import` to reference a file that calls `register()`',
520+
'ExperimentalWarning',
521+
);
522+
emittedLoaderFlagWarning = true;
523+
}
516524
customizations = new CustomizedModuleLoader();
517525
}
518526
}

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

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ describe('ESM: warn for obsolete hooks provided', { concurrency: true }, () => {
2525
describe('experimental warnings for enabled experimental feature', () => {
2626
for (
2727
const [experiment, arg] of [
28+
[
29+
/`--experimental-loader` may be removed in the future/,
30+
`--experimental-loader=${fileURL('es-module-loaders', 'hooks-custom.mjs')}`
31+
],
2832
[/Network Imports/, '--experimental-network-imports'],
2933
]
3034
) {

0 commit comments

Comments
 (0)