| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent cc7bf1f commit cf9ddcd
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -357,6 +357,22 @@ process.emitWarning = emitWarning; | |||
| 357 | 357 | // Note: only after this point are the timers effective | |
| 358 | 358 | } | |
| 359 | 359 | ||
| 360 | + { | ||
| 361 | + const { | ||
| 362 | + setSourceMapsEnabled, | ||
| 363 | + maybeCacheGeneratedSourceMap, | ||
| 364 | + } = require('internal/source_map/source_map_cache'); | ||
| 365 | + const { | ||
| 366 | + setMaybeCacheGeneratedSourceMap, | ||
| 367 | + } = internalBinding('errors'); | ||
| 368 | + | ||
| 369 | + process.setSourceMapsEnabled = setSourceMapsEnabled; | ||
| 370 | + // The C++ land calls back to maybeCacheGeneratedSourceMap() | ||
| 371 | + // when code is generated by user with eval() or new Function() | ||
| 372 | + // to cache the source maps from the evaluated code, if any. | ||
| 373 | + setMaybeCacheGeneratedSourceMap(maybeCacheGeneratedSourceMap); | ||
| 374 | + } | ||
| 375 | + | ||
| 360 | 376 | function setupProcessObject() { | |
| 361 | 377 | const EventEmitter = require('events'); | |
| 362 | 378 | const origProcProto = ObjectGetPrototypeOf(process); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -305,8 +305,6 @@ if (internalBinding('config').hasInspector) { | |||
| 305 | 305 | internalBinding('wasm_web_api'); | |
| 306 | 306 | // Needed to detect whether it's on main thread. | |
| 307 | 307 | internalBinding('worker'); | |
| 308 | - // Needed to setup source maps. | ||
| 309 | - require('internal/source_map/source_map_cache'); | ||
| 310 | 308 | // Needed by most execution modes. | |
| 311 | 309 | require('internal/modules/run_main'); | |
| 312 | 310 | // Needed to refresh DNS configurations. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -564,11 +564,10 @@ function initializeESMLoader() { | |||
| 564 | 564 | } | |
| 565 | 565 | ||
| 566 | 566 | function initializeSourceMapsHandlers() { | |
| 567 | - const { setSourceMapsEnabled, getSourceMapsEnabled } = | ||
| 568 | - require('internal/source_map/source_map_cache'); | ||
| 569 | - process.setSourceMapsEnabled = setSourceMapsEnabled; | ||
| 570 | - // Initialize the environment flag of source maps. | ||
| 571 | - getSourceMapsEnabled(); | ||
| 567 | + const { | ||
| 568 | + setSourceMapsEnabled, | ||
| 569 | + } = require('internal/source_map/source_map_cache'); | ||
| 570 | + setSourceMapsEnabled(getOptionValue('--enable-source-maps')); | ||
| 572 | 571 | } | |
| 573 | 572 | ||
| 574 | 573 | function initializeFrozenIntrinsics() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,10 +23,12 @@ const { Buffer } = require('buffer'); | |||
| 23 | 23 | let debug = require('internal/util/debuglog').debuglog('source_map', (fn) => { | |
| 24 | 24 | debug = fn; | |
| 25 | 25 | }); | |
| 26 | - const { getOptionValue } = require('internal/options'); | ||
| 27 | 26 | ||
| 28 | 27 | const { validateBoolean } = require('internal/validators'); | |
| 29 | - const { setMaybeCacheGeneratedSourceMap } = internalBinding('errors'); | ||
| 28 | + const { | ||
| 29 | + setSourceMapsEnabled: setSourceMapsNative, | ||
| 30 | + setPrepareStackTraceCallback, | ||
| 31 | + } = internalBinding('errors'); | ||
| 30 | 32 | const { getLazy } = require('internal/util'); | |
| 31 | 33 | ||
| 32 | 34 | // Since the CJS module cache is mutable, which leads to memory leaks when | |
@@ -49,22 +51,16 @@ const { fileURLToPath, pathToFileURL, URL } = require('internal/url'); | |||
| 49 | 51 | ||
| 50 | 52 | let SourceMap; | |
| 51 | 53 | ||
| 52 | - let sourceMapsEnabled; | ||
| 54 | + // This is configured with --enable-source-maps during pre-execution. | ||
| 55 | + let sourceMapsEnabled = false; | ||
| 53 | 56 | function getSourceMapsEnabled() { | |
| 54 | - if (sourceMapsEnabled === undefined) { | ||
| 55 | - setSourceMapsEnabled(getOptionValue('--enable-source-maps')); | ||
| 56 | - } | ||
| 57 | 57 | return sourceMapsEnabled; | |
| 58 | 58 | } | |
| 59 | 59 | ||
| 60 | 60 | function setSourceMapsEnabled(val) { | |
| 61 | 61 | validateBoolean(val, 'val'); | |
| 62 | 62 | ||
| 63 | - const { | ||
| 64 | - setSourceMapsEnabled, | ||
| 65 | - setPrepareStackTraceCallback, | ||
| 66 | - } = internalBinding('errors'); | ||
| 67 | - setSourceMapsEnabled(val); | ||
| 63 | + setSourceMapsNative(val); | ||
| 68 | 64 | if (val) { | |
| 69 | 65 | const { | |
| 70 | 66 | prepareStackTrace, | |
@@ -191,7 +187,6 @@ function maybeCacheGeneratedSourceMap(content) { | |||
| 191 | 187 | debug(err); | |
| 192 | 188 | } | |
| 193 | 189 | } | |
| 194 | - setMaybeCacheGeneratedSourceMap(maybeCacheGeneratedSourceMap); | ||
| 195 | 190 | ||
| 196 | 191 | function dataFromUrl(sourceURL, sourceMappingURL) { | |
| 197 | 192 | try { | |
@@ -334,5 +329,6 @@ module.exports = { | |||
| 334 | 329 | getSourceMapsEnabled, | |
| 335 | 330 | setSourceMapsEnabled, | |
| 336 | 331 | maybeCacheSourceMap, | |
| 332 | + maybeCacheGeneratedSourceMap, | ||
| 337 | 333 | sourceMapCacheToObject, | |
| 338 | 334 | }; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments