-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
lib,src: extract sourceMappingURL from module #51690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
82c549e
test: add tests for map url extract behavior
unbyte b202149
feat: get source mapping url from v8
unbyte 6a5ada0
fix: add back extract source map url using regex
unbyte 2acc949
test: add trailing newlines
unbyte 97b5556
fix: extract sourceURL from esm code text
unbyte 2f6ffe8
chore: add fixme comment
unbyte b446b4c
chore: fix lint issue
unbyte File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| import { spawnPromisified } from '../common/index.mjs'; | ||
| import * as fixtures from '../common/fixtures.mjs'; | ||
| import assert from 'node:assert'; | ||
| import { execPath } from 'node:process'; | ||
| import { describe, it } from 'node:test'; | ||
|
|
||
| describe('esm source-map', { concurrency: true }, () => { | ||
| // Issue: https://github.com/nodejs/node/issues/51522 | ||
|
|
||
| [ | ||
| [ | ||
| 'in middle from esm', | ||
| 'source-map/extract-url/esm-url-in-middle.mjs', | ||
| true, | ||
| ], | ||
| [ | ||
| 'inside string from esm', | ||
| 'source-map/extract-url/esm-url-in-string.mjs', | ||
| false, | ||
| ], | ||
| ].forEach(([name, path, shouldExtract]) => { | ||
| it((shouldExtract ? 'should extract source map url' : 'should not extract source map url') + name, async () => { | ||
| const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ | ||
| '--no-warnings', | ||
| '--enable-source-maps', | ||
| fixtures.path(path), | ||
| ]); | ||
|
|
||
| assert.strictEqual(stdout, ''); | ||
| if (shouldExtract) { | ||
| assert.match(stderr, /index\.ts/); | ||
| } else { | ||
| assert.doesNotMatch(stderr, /index\.ts/); | ||
| } | ||
| assert.strictEqual(code, 1); | ||
| assert.strictEqual(signal, null); | ||
| }); | ||
| }); | ||
|
|
||
| [ | ||
| [ | ||
| 'in middle from esm imported by esm', | ||
| `import ${JSON.stringify(fixtures.fileURL('source-map/extract-url/esm-url-in-middle.mjs'))}`, | ||
| true, | ||
| ], | ||
| [ | ||
| 'in middle from cjs imported by esm', | ||
| `import ${JSON.stringify(fixtures.fileURL('source-map/extract-url/cjs-url-in-middle.js'))}`, | ||
| true, | ||
| ], | ||
| [ | ||
| 'in middle from cjs required by esm', | ||
| "import { createRequire } from 'module';" + | ||
| 'const require = createRequire(import.meta.url);' + | ||
| `require(${JSON.stringify(fixtures.path('source-map/extract-url/cjs-url-in-middle.js'))})`, | ||
| true, | ||
| ], | ||
|
|
||
| [ | ||
| 'inside string from esm imported by esm', | ||
| `import ${JSON.stringify(fixtures.fileURL('source-map/extract-url/esm-url-in-string.mjs'))}`, | ||
| false, | ||
| ], | ||
| [ | ||
| 'inside string from cjs imported by esm', | ||
| `import ${JSON.stringify(fixtures.fileURL('source-map/extract-url/cjs-url-in-string.js'))}`, | ||
| false, | ||
| ], | ||
| [ | ||
| 'inside string from cjs required by esm', | ||
| "import { createRequire } from 'module';" + | ||
| 'const require = createRequire(import.meta.url);' + | ||
| `require(${JSON.stringify(fixtures.path('source-map/extract-url/cjs-url-in-string.js'))})`, | ||
| false, | ||
| ], | ||
| ].forEach(([name, evalCode, shouldExtract]) => { | ||
| it((shouldExtract ? 'should extract source map url' : 'should not extract source map url') + name, async () => { | ||
| const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ | ||
| '--no-warnings', | ||
| '--enable-source-maps', | ||
| '--input-type=module', | ||
| '--eval', | ||
| evalCode, | ||
| ]); | ||
|
|
||
| assert.strictEqual(stdout, ''); | ||
| if (shouldExtract) { | ||
| assert.match(stderr, /index\.ts/); | ||
| } else { | ||
| assert.doesNotMatch(stderr, /index\.ts/); | ||
| } | ||
| assert.strictEqual(code, 1); | ||
| assert.strictEqual(signal, null); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
|
|
||
| throw new Error("Hello world!"); | ||
| //# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vcHJvamVjdC9pbmRleC50cyJdLAogICJzb3VyY2VzQ29udGVudCI6IFsidGhyb3cgbmV3IEVycm9yKFwiSGVsbG8gd29ybGQhXCIpXG4iXSwKICAibWFwcGluZ3MiOiAiO0FBQUEsTUFBTSxJQUFJLE1BQU0sY0FBYzsiLAogICJuYW1lcyI6IFtdCn0K | ||
| console.log(1); | ||
| // | ||
|
unbyte marked this conversation as resolved.
Outdated
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
|
|
||
| throw new Error("Hello world!");` | ||
| //# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vcHJvamVjdC9pbmRleC50cyJdLAogICJzb3VyY2VzQ29udGVudCI6IFsidGhyb3cgbmV3IEVycm9yKFwiSGVsbG8gd29ybGQhXCIpXG4iXSwKICAibWFwcGluZ3MiOiAiO0FBQUEsTUFBTSxJQUFJLE1BQU0sY0FBYzsiLAogICJuYW1lcyI6IFtdCn0K | ||
| console.log(1); | ||
| //` | ||
|
unbyte marked this conversation as resolved.
Outdated
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
|
|
||
| throw new Error("Hello world!"); | ||
| //# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vcHJvamVjdC9pbmRleC50cyJdLAogICJzb3VyY2VzQ29udGVudCI6IFsidGhyb3cgbmV3IEVycm9yKFwiSGVsbG8gd29ybGQhXCIpXG4iXSwKICAibWFwcGluZ3MiOiAiO0FBQUEsTUFBTSxJQUFJLE1BQU0sY0FBYzsiLAogICJuYW1lcyI6IFtdCn0K | ||
| console.log(1); | ||
| // | ||
|
unbyte marked this conversation as resolved.
Outdated
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
|
|
||
| throw new Error("Hello world!");` | ||
| //# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vcHJvamVjdC9pbmRleC50cyJdLAogICJzb3VyY2VzQ29udGVudCI6IFsidGhyb3cgbmV3IEVycm9yKFwiSGVsbG8gd29ybGQhXCIpXG4iXSwKICAibWFwcGluZ3MiOiAiO0FBQUEsTUFBTSxJQUFJLE1BQU0sY0FBYzsiLAogICJuYW1lcyI6IFtdCn0K | ||
| console.log(1); | ||
| //` | ||
|
unbyte marked this conversation as resolved.
Outdated
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.