diff --git a/doc/api/vm.md b/doc/api/vm.md index f99f4966db82b6..91f77cfc044a9f 100644 --- a/doc/api/vm.md +++ b/doc/api/vm.md @@ -344,6 +344,41 @@ console.log(globalVar); // 1000 ``` +### `script.sourceMapURL` + + + +* {string|undefined} + +When the script is compiled from a source that contains a source map magic +comment, this property will be set to the URL of the source map. + +```mjs +import vm from 'node:vm'; + +const script = new vm.Script(` +function myFunc() {} +//# sourceMappingURL=sourcemap.json +`); + +console.log(script.sourceMapURL); +// Prints: sourcemap.json +``` + +```cjs +const vm = require('node:vm'); + +const script = new vm.Script(` +function myFunc() {} +//# sourceMappingURL=sourcemap.json +`); + +console.log(script.sourceMapURL); +// Prints: sourcemap.json +``` + ## Class: `vm.Module`