summaryrefslogtreecommitdiff
path: root/lib/internal/source_map/source_map_cache.js
Commit message (Collapse)AuthorAgeFilesLines
* lib: add trailing commas to more internal filesAntoine du Hamel2023-02-261-3/+3
| | | | | | | PR-URL: https://github.com/nodejs/node/pull/46811 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Debadree Chatterjee <debadree333@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
* lib: remove unnecessary ObjectGetValueSafeChengzhong Wu2023-01-301-18/+8
| | | | | | | | PR-URL: https://github.com/nodejs/node/pull/46335 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
* lib: cache parsed source maps to reduce memory footprintChengzhong Wu2023-01-221-8/+18
| | | | | | | | | | This also improves performance to map the stack trace when the `Error.stack` is accessed. PR-URL: https://github.com/nodejs/node/pull/46225 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
* tools: add `prefer-proto` ruleJordan Harband2023-01-101-2/+1
| | | | | | | | | | | | | | | | fixup: add support for `Object.create(null)` fixup: extend to any 1-argument Object.create call fixup: add tests PR-URL: https://github.com/nodejs/node/pull/46083 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
* lib: lazy-load deps in source_map_cache.jsJoyee Cheung2022-12-161-8/+12
| | | | | | | | So that the file can be snapshotted. PR-URL: https://github.com/nodejs/node/pull/45849 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
* modules: move modules/cjs/helpers.js to modules/helpers.jsJoyee Cheung2022-12-161-1/+1
| | | | | | | | | The helpers are actually shared by the two loaders, so move them under modules/ directly. PR-URL: https://github.com/nodejs/node/pull/45849 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
* bootstrap: lazy load non-essential modulesJoyee Cheung2022-12-091-1/+1
| | | | | | | | | | | | | | | | | | | | | It turns out that even with startup snapshots, there is a non-trivial overhead for loading internal modules. This patch makes the loading of the non-essential modules lazy again. Caveat: we have to make some of the globals lazily-loaded too, so the WPT runner is updated to test what the state of the global scope is after the globals are accessed (and replaced with the loaded value). PR-URL: https://github.com/nodejs/node/pull/45659 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com> Reviewed-By: Tierney Cyren <hello@bnb.im>
* src,lib: retrieve parsed source map url from v8legendecas2022-10-231-42/+56
| | | | | | | | | | | | | V8 already parses the source map magic comments. Currently, only scripts and functions expose the parsed source map URLs. It is unnecessary to parse the source map magic comments again when the parsed information is available. PR-URL: https://github.com/nodejs/node/pull/44798 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Jan Krems <jan.krems@gmail.com>
* lib: don't match `sourceMappingURL` in stringsAlan Agius2022-09-261-11/+22
| | | | | | | | | | | | Prior to this change `sourceMappingURL` in string where being matched by the RegExp which caused sourcemaps not be loaded when using the `--enable-source-maps` flag. This commit changes the RegExp to match the last occurrence. Fixes: https://github.com/nodejs/node/issues/44654 PR-URL: https://github.com/nodejs/node/pull/44658 Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
* lib: codify findSourceMap return value when not foundChengzhong Wu2022-08-271-1/+1
| | | | | | | | | Return `undefined` when no source map is found for the given filename on `findSourceMap`. PR-URL: https://github.com/nodejs/node/pull/44397 Fixes: https://github.com/nodejs/node/issues/44391 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
* src,lib: print source map error source on demandlegendecas2022-07-281-37/+54
| | | | | | | | | | | | | | | | | The source context is not prepended to the value of the `stack` property when the source map is not enabled. Rather than prepending the error source context to the value of the `stack` property unconditionally, this patch aligns the behavior and only prints the source context when the error is not handled by userland (e.g. fatal errors). Also, this patch fixes that when source-map support is enabled, the error source context is not pointing to where the error was thrown. PR-URL: https://github.com/nodejs/node/pull/43875 Fixes: https://github.com/nodejs/node/issues/43186 Fixes: https://github.com/nodejs/node/issues/41541 Reviewed-By: Ben Coe <bencoe@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
* lib,src: add source map support for global evallegendecas2022-07-111-14/+55
| | | | | | | | | | Dynamic sources with FunctionConstructor is not supported yet as V8 prepends lines to the sources which makes the stack line number incorrect. PR-URL: https://github.com/nodejs/node/pull/43428 Refs: https://github.com/nodejs/node/issues/43047 Reviewed-By: Ben Coe <bencoe@gmail.com>
* lib: refactor to avoid unsafe regex primordialsAntoine du Hamel2022-06-271-6/+6
| | | | | PR-URL: https://github.com/nodejs/node/pull/43475 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
* errors: do not access .stack in debugBenjamin E. Coe2022-02-251-4/+4
| | | | | | | | | Refs: #41541 PR-URL: https://github.com/nodejs/node/pull/42096 Refs: https://github.com/nodejs/node/issues/41541 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Mestery <mestery@protonmail.com>
* process: add api to enable source-maps programmaticallylegendecas2021-07-151-12/+27
| | | | | | | | | Add `process.setSourceMapsEnabled` to enable source-maps programmatically. PR-URL: https://github.com/nodejs/node/pull/39085 Reviewed-By: Ben Coe <bencoe@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* errors: don't rekey on primitive typebcoe2021-06-211-9/+0
| | | | | | | | | | | | | | If an error is thrown before a module is loaded, we attempt to cache source map against error object, rather than module object. We can't do this if the error is a primitive type Fixes #38945 PR-URL: https://github.com/nodejs/node/pull/39025 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
* lib: refactor source_map to avoid unsafe array iterationAntoine du Hamel2021-01-131-1/+1
| | | | | | | PR-URL: https://github.com/nodejs/node/pull/36734 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Pooja D P <Pooja.D.P@ibm.com>
* lib: make safe primordials safe to iterateAntoine du Hamel2020-12-151-10/+1
| | | | | | PR-URL: https://github.com/nodejs/node/pull/36391 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* module: refactor to use iterable-weak-mapbcoe2020-11-061-50/+38
| | | | | | | | | | | Using an iterable WeakMap (a data-structure that uses WeakRef and WeakMap), we are able to: stop relying on Module._cache to serialize source maps; stop requiring an error object when calling findSourceMap(). PR-URL: https://github.com/nodejs/node/pull/35915 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
* errors: do not call resolve on URLs with schemesbcoe2020-11-021-19/+12
| | | | | | | | | | | | | We were incorrectly trying to run path.resolve on absolute sources URLs. This was breaking webpack:// URLs in stack trace output. Refs: https://github.com/nodejs/node/issues/35325 PR-URL: https://github.com/nodejs/node/pull/35903 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
* lib: improve debuglog() performanceBrian White2020-05-301-1/+3
| | | | | PR-URL: https://github.com/nodejs/node/pull/32260 Reviewed-By: James M Snell <jasnell@gmail.com>
* errors: print original exception contextbcoe2020-05-241-5/+22
| | | | | | | | | | | When --enable-source-maps is set, the error context displayed above the stack trace now shows original source rather than transpiled. PR-URL: https://github.com/nodejs/node/pull/33491 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
* tools: enable no-else-return lint ruleLuigi Pinca2020-05-161-4/+2
| | | | | | | | | Refs: https://github.com/nodejs/node/pull/32644 Refs: https://github.com/nodejs/node/pull/32662 PR-URL: https://github.com/nodejs/node/pull/32667 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
* module: add API for interacting with source mapsbcoe2020-01-141-1/+11
| | | | | | | | PR-URL: https://github.com/nodejs/node/pull/31132 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* lib: replace Map global by the primordialsSebastien Ahkrin2020-01-041-0/+1
| | | | | | | | | | | PR-URL: https://github.com/nodejs/node/pull/31155 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
* lib: replace WeakMap global by the primordialsSebastien Ahkrin2020-01-041-0/+1
| | | | | | | | | | | PR-URL: https://github.com/nodejs/node/pull/31158 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
* lib: flatten access to primordialsMichaël Zasso2019-11-251-19/+14
| | | | | | | | | | | | | | Store all primordials as properties of the primordials object. Static functions are prefixed by the constructor's name and prototype methods are prefixed by the constructor's name followed by "Prototype". For example: primordials.Object.keys becomes primordials.ObjectKeys. PR-URL: https://github.com/nodejs/node/pull/30610 Refs: https://github.com/nodejs/node/issues/29766 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
* process: make source map getter resistant against prototype tamperingAnna Henningsen2019-11-051-12/+51
| | | | | | | | | | | | Since this code runs during process and Worker shutdown, it should not call user-provided code and thereby e.g. provide a way to break out of `worker.terminate()`. PR-URL: https://github.com/nodejs/node/pull/30228 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ben Coe <bencoe@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* process: add lineLength to source-map-cachebcoe2019-10-131-51/+24
| | | | | | | | | | Without the line lengths of in-memory transpiled source, it's not possible to convert from byte ofsets to line/column offsets. PR-URL: https://github.com/nodejs/node/pull/29863 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* process: add source-map support to stack tracesbcoe2019-10-051-0/+237
PR-URL: https://github.com/nodejs/node/pull/29564 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>