Skip to content

Commit ffb80d0

Browse files
committed
Improve warning
1 parent 200d15e commit ffb80d0

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/internal/modules/esm/loader.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
require('internal/modules/cjs/loader');
55

66
const {
7+
ArrayPrototypeJoin,
8+
ArrayPrototypeMap,
79
FunctionPrototypeCall,
10+
JSONStringify,
811
ObjectSetPrototypeOf,
912
SafeWeakMap,
1013
} = primordials;
@@ -516,7 +519,11 @@ function createModuleLoader(useCustomLoadersIfPresent = true) {
516519
if (userLoaderPaths.length > 0) {
517520
if (!emittedLoaderFlagWarning) {
518521
process.emitWarning(
519-
'`--experimental-loader` may be removed in the future; instead use `--import` to reference a file that calls `register()`',
522+
'`--experimental-loader` may be removed in the future; instead use `register()`:\n' +
523+
`--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; ${ArrayPrototypeJoin(
524+
ArrayPrototypeMap(userLoaderPaths, (loader) => `register(${JSONStringify(encodeURI(loader))}, pathToFileURL("./"))`),
525+
"; ",
526+
)};'`,
520527
'ExperimentalWarning',
521528
);
522529
emittedLoaderFlagWarning = true;

0 commit comments

Comments
 (0)