@@ -1024,6 +1024,86 @@ import('fs').then((esmFS) => {
10241024});
10251025` ` `
10261026
1027+ ## Source Map V3 Support
1028+ <!-- YAML
1029+ added: REPLACEME
1030+ -->
1031+
1032+ > Stability: 1 - Experimental
1033+
1034+ Helpers for for interacting with the source map cache. This cache is
1035+ populated when source map parsing is enabled and
1036+ [source map include directives][] are found in a modules' footer.
1037+
1038+ To enable source map parsing, Node.js must be run with the flag
1039+ [` -- enable- source- maps` ][], or with code coverage enabled by setting
1040+ [` NODE_V8_COVERAGE = dir` ][].
1041+
1042+ ` ` ` js
1043+ const { findSourceMap , SourceMap } = require (' module' );
1044+ ` ` `
1045+
1046+ ### ` module .findSourceMap (path[, error])`
1047+ <!-- YAML
1048+ added: REPLACEME
1049+ -->
1050+
1051+ * ` path` {string}
1052+ * ` error` {Error}
1053+ * Returns: {module.SourceMap}
1054+
1055+ ` path` is the resolved path for the file for which a corresponding source map
1056+ should be fetched.
1057+
1058+ The ` error` instance should be passed as the second parameter to ` findSourceMap`
1059+ in exceptional flows, e.g., when an overridden
1060+ [` Error .prepareStackTrace (error, trace)` ][] is invoked. Modules are not added to
1061+ the module cache until they are successfully loaded, in these cases source maps
1062+ will be associated with the ` error` instance along with the ` path` .
1063+
1064+ ### Class: ` module .SourceMap `
1065+ <!-- YAML
1066+ added: REPLACEME
1067+ -->
1068+
1069+ #### ` new SourceMap (payload)`
1070+
1071+ * ` payload` {Object}
1072+
1073+ Creates a new ` sourceMap` instance.
1074+
1075+ ` payload` is an object with keys matching the [Source Map V3 format][]:
1076+
1077+ * ` file` : {string}
1078+ * ` version` : {number}
1079+ * ` sources` : {string[]}
1080+ * ` sourcesContent` : {string[]}
1081+ * ` names` : {string[]}
1082+ * ` mappings` : {string}
1083+ * ` sourceRoot` : {string}
1084+
1085+ #### ` sourceMap .payload `
1086+
1087+ * Returns: {Object}
1088+
1089+ Getter for the payload used to construct the [` SourceMap` ][] instance.
1090+
1091+ #### ` sourceMap .findEntry (lineNumber, columnNumber)`
1092+
1093+ * ` lineNumber` {number}
1094+ * ` columnNumber` {number}
1095+ * Returns: {Object}
1096+
1097+ Given a line number and column number in the generated source file, returns
1098+ an object representing the position in the original file. The object returned
1099+ consists of the following keys:
1100+
1101+ * generatedLine: {number}
1102+ * generatedColumn: {number}
1103+ * originalSource: {string}
1104+ * originalLine: {number}
1105+ * originalColumn: {number}
1106+
10271107[GLOBAL_FOLDERS]: #modules_loading_from_the_global_folders
10281108[` Error ` ]: errors.html#errors_class_error
10291109[` __dirname ` ]: #modules_dirname
@@ -1037,3 +1117,9 @@ import('fs').then((esmFS) => {
10371117[module resolution]: #modules_all_together
10381118[module wrapper]: #modules_the_module_wrapper
10391119[native addons]: addons.html
1120+ [source map include directives]: https://sourcemaps.info/spec.html#h.lmz475t4mvbx
1121+ [` -- enable- source- maps` ]: cli.html#cli_enable_source_maps
1122+ [` NODE_V8_COVERAGE = dir` ]: cli.html#cli_node_v8_coverage_dir
1123+ [` Error .prepareStackTrace (error, trace)` ]: https://v8.dev/docs/stack-trace-api#customizing-stack-traces
1124+ [` SourceMap` ]: modules.html#modules_class_module_sourcemap
1125+ [Source Map V3 format]: https://sourcemaps.info/spec.html#h.mofvlxcwqzej
0 commit comments