Skip to content

sourceMappingURL in string literal will cause source-maps not to load when using --enable-source-maps #44654

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
alan-agius4 opened this issue Sep 15, 2022 · 0 comments
Labels
source maps Issues and PRs related to source map support.

Comments

@alan-agius4
Copy link
Contributor

alan-agius4 commented Sep 15, 2022

Version

16.16.0

Platform

Linux 5.18.16-1rodete1-amd64 #1 SMP PREEMPT_DYNAMIC Debian 5.18.16-1rodete1 (2022-08-24) x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

server.js

"use strict";
let content = '';
content = '/*# sourceMappingURL=' + content + ' */';
throw new Error('This should point to TypeScript file.');
//# sourceMappingURL=server.js.map

server.js.map

{
  "version": 3,
  "file": "server.js",
  "sourceRoot": "",
  "sources": [
    "../../server.ts"
  ],
  "names": [],
  "mappings": ";AAAA,IAAI,OAAO,GAAG,EAAE,CAAC;AACjB,OAAO,GAAG,uBAAuB,GAAG,OAAO,GAAG,KAAK,CAAC;AAEpD,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC"
}
$ node --enable-source-maps server.js
Error: This should point to TypeScript file.
    at Object.<anonymous> (/server.js:4:7)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior?

Stacktrace points to the orginal source file when using --enable-source-maps option.

What do you see instead?

Sourcemaps are not loaded when the files contains /*# sourceMappingURL= as string literal and as such the stacktrace points to JavaScript output instead of the TypeScript source.

Additional information

No response

alan-agius4 added a commit to alan-agius4/node that referenced this issue Sep 15, 2022
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: nodejs#44654
alan-agius4 added a commit to alan-agius4/node that referenced this issue Sep 15, 2022
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: nodejs#44654
alan-agius4 added a commit to alan-agius4/node that referenced this issue Sep 15, 2022
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: nodejs#44654
alan-agius4 added a commit to alan-agius4/node that referenced this issue Sep 15, 2022
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: nodejs#44654
alan-agius4 added a commit to alan-agius4/node that referenced this issue Sep 15, 2022
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: nodejs#44654
@cola119 cola119 added the source maps Issues and PRs related to source map support. label Sep 15, 2022
alan-agius4 added a commit to alan-agius4/node that referenced this issue Sep 15, 2022
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: nodejs#44654
alan-agius4 added a commit to alan-agius4/node that referenced this issue Sep 15, 2022
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: nodejs#44654
alan-agius4 added a commit to alan-agius4/node that referenced this issue Sep 16, 2022
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: nodejs#44654
alan-agius4 added a commit to alan-agius4/node that referenced this issue Sep 16, 2022
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: nodejs#44654
RafaelGSS pushed a commit that referenced this issue Sep 26, 2022
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: #44654
PR-URL: #44658
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
RafaelGSS pushed a commit that referenced this issue Sep 26, 2022
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: #44654
PR-URL: #44658
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
RafaelGSS pushed a commit that referenced this issue Sep 26, 2022
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: #44654
PR-URL: #44658
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
alan-agius4 added a commit to alan-agius4/universal that referenced this issue Oct 7, 2022
…rver

Note: this requires Node.js 18.10 or later due to nodejs/node#44654

Closes angular#2813
alan-agius4 added a commit to angular/universal that referenced this issue Oct 7, 2022
…rver

Note: this requires Node.js 18.10 or later due to nodejs/node#44654

Closes #2813
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
source maps Issues and PRs related to source map support.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants