-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
fix: fix sourcemap when using object as define
value
#15805
Merged
patak-dev
merged 17 commits into
vitejs:main
from
hi-ogawa:fix-esbuild-define-transform-sourcemap
Apr 3, 2024
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
1edb0a2
fix: fix sourcemap when esbuild define transform includes "<define:.…
hi-ogawa 309ab6b
chore: tweak test
hi-ogawa 0fcb9a5
chore: lockfile
hi-ogawa 2a03660
test: tweak
hi-ogawa 97d24c5
test: add to playground/js-sourcemap
hi-ogawa 0a71849
chore: comment
hi-ogawa ba8b364
chore: snapshot
hi-ogawa 187b2ae
fix: for ssr dev
hi-ogawa 37275a8
test: add ssr dev test
hi-ogawa 24e8079
chore: remove
hi-ogawa 068cd93
test: run test
hi-ogawa 9f26744
chore: remove unused
hi-ogawa 1f823ea
chore: lockfile
hi-ogawa e6e9b9a
chore: lint
hi-ogawa 8ed7c65
chore: revert comment
hi-ogawa e613c06
Merge branch 'main' into fix-esbuild-define-transform-sourcemap
hi-ogawa 9055471
chore: type any?
hi-ogawa 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 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 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 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 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,38 @@ | ||
import assert from 'node:assert' | ||
import { fileURLToPath } from 'node:url' | ||
import { createServer } from 'vite' | ||
|
||
async function runTest() { | ||
const server = await createServer({ | ||
root: fileURLToPath(new URL('.', import.meta.url)), | ||
configFile: false, | ||
optimizeDeps: { | ||
noDiscovery: true, | ||
}, | ||
server: { | ||
middlewareMode: true, | ||
hmr: false, | ||
}, | ||
define: { | ||
__testDefineObject: '{ "hello": "test" }', | ||
}, | ||
}) | ||
const mod = await server.ssrLoadModule('/with-define-object-ssr.ts') | ||
const error = await getError(() => mod.error()) | ||
server.ssrFixStacktrace(error) | ||
assert.match(error.stack, /at errorInner (.*with-define-object-ssr.ts:7:9)/) | ||
await server.close() | ||
} | ||
|
||
async function getError(f) { | ||
let error | ||
try { | ||
await f() | ||
} catch (e) { | ||
error = e | ||
} | ||
assert.ok(error) | ||
return error | ||
} | ||
|
||
runTest() |
This file contains 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 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,8 @@ | ||
export function error() { | ||
errorInner() | ||
} | ||
|
||
function errorInner() { | ||
// @ts-expect-error "define" | ||
throw new Error('with-define-object: ' + JSON.stringify(__testDefineObject)) | ||
} |
This file contains 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,12 @@ | ||
// test complicated stack since broken sourcemap | ||
// might still look correct with a simple case | ||
function main() { | ||
mainInner() | ||
} | ||
|
||
function mainInner() { | ||
// @ts-expect-error "define" | ||
console.trace('with-define-object', __testDefineObject) | ||
} | ||
|
||
main() |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wasn't the case before, but now it looks like this is type error. I used
as any
for now.