Skip to content
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(runtime): fix sourcemap with prepareStackTrace #16220

Merged
merged 7 commits into from Mar 21, 2024

Conversation

hi-ogawa
Copy link
Collaborator

@hi-ogawa hi-ogawa commented Mar 21, 2024

Description

As explained in #16178 (comment), "replace bias" transform which is used for runtime.js build was causing a bug.

In this PR, I removed this transform since it doesn't seem particularly worth squeezing out these three lines of code on Vite side. I think it's always possible for end-users to minify the final build further if they wish to do so.

# replace true (current main)
$ wc packages/vite/dist/node/runtime.js
 1027  4828 44423 packages/vite/dist/node/runtime.js

# replace false
$ wc packages/vite/dist/node/runtime.js
 1027  4826 44403 packages/vite/dist/node/runtime.js

# no transform (this PR)
$ wc packages/vite/dist/node/runtime.js
 1032  4873 44729 packages/vite/dist/node/runtime.js

# no transform + terser
$ terser packages/vite/dist/node/runtime.js --toplevel -m | wc
      1     721   23029
diff view of "false" vs "no transform"

image

I don't know but if this known constant folding has some perf impact, then maybe it's okay to put to false. Let me know if anyone knows about the perf aspect of things.


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines, especially the Pull Request Guidelines.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Update the corresponding documentation if needed.
  • Ideally, include relevant tests that fail without this PR but pass with it.

Copy link

stackblitz bot commented Mar 21, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@hi-ogawa hi-ogawa changed the title test: add more runtime stacktrace tests fix(runtime): fix sourcemap with prepareStackTrace Mar 21, 2024
@hi-ogawa hi-ogawa marked this pull request as ready for review March 21, 2024 08:50
@sapphi-red sapphi-red added p3-minor-bug An edge case that only affects very specific usage (priority) regression The issue only appears after a new release feat: sourcemap Sourcemap support labels Mar 21, 2024
Copy link
Member

@sapphi-red sapphi-red left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@patak-dev patak-dev merged commit dad7f4f into vitejs:main Mar 21, 2024
19 checks passed
@hi-ogawa hi-ogawa deleted the fix-runtime-prepareStackTrace branch March 21, 2024 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: sourcemap Sourcemap support p3-minor-bug An edge case that only affects very specific usage (priority) regression The issue only appears after a new release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Subtle change in Vite runtime stacktrace with prepareStackTrace since 5.1.5
3 participants