node/lib/internal/modules
Joyee Cheung 98ce551fc0
module: use file: URL as sourceURL for type-stripped CommonJS
The CommonJS loader was passing the bare filesystem path as the
`//# sourceURL` comment of type-stripped TypeScript, this leads to
two problems:

1. It reports hasSourceURL = false if the path contains any
   whitespaces as this breaks V8's magic comment parser.
2. The inspector would incorrectly report a file path verbatim as
  the script's URL.

Pass the module's file: URL as the sourceURL so the reported URL
is consistent across loaders and won't lead to an issue in
inspector clients that actually except a real URL for the
scripts.

Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63705
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-06-25 16:07:35 +02:00
..
cjs module: use file: URL as sourceURL for type-stripped CommonJS 2026-06-25 16:07:35 +02:00
esm module: load ESM helpers eagerly in the snapshot 2026-06-18 21:12:36 +01:00
customization_hooks.js module: handle null source from async loader hooks in sync hooks 2025-11-07 18:11:30 +01:00
helpers.js module: run require.resolve through module.registerHooks() 2026-04-10 14:52:16 +02:00
package_json_reader.js src: cache missing package.json files in the C++ package config cache 2026-01-27 22:52:30 +01:00
run_main.js module: mark type stripping as stable 2025-11-18 15:29:15 +01:00
typescript.js module: use file: URL as sourceURL for type-stripped CommonJS 2026-06-25 16:07:35 +02:00