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 process.env import skewing env inlining offsets #819

Merged
merged 3 commits into from
Aug 30, 2021

Conversation

developit
Copy link
Member

This fixes #818. The issue was happening because code is passed to MagicString, which assumes all offsets are relative to that string. However, code was being modified to prepend an import statement before it gets scanned by the regex, which caused all offsets for .overwrite() to be relative to the modified code instead of the one that was passed to MagicString.

This fixes #818. The issue was happening because `code` is passed to MagicString, which assumes all offsets are relative to that string. However, `code` was being modified to prepend an import statement before it gets scanned by the regex, which caused all offsets for `.overwrite()` to be relative to the modified `code` instead of the one that was passed to MagicString.
@changeset-bot
Copy link

changeset-bot bot commented Aug 30, 2021

🦋 Changeset detected

Latest commit: cb3c011

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
wmr Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Aug 30, 2021

Size Change: -17 B (0%)

Total Size: 804 kB

Filename Size Change
packages/wmr/wmr.cjs 766 kB -17 B (0%)
ℹ️ View Unchanged
Filename Size
examples/demo/dist/about/index.html 713 B
examples/demo/dist/alias-outside/index.html 693 B
examples/demo/dist/assets/Calendar.********.css 702 B
examples/demo/dist/assets/style.********.css 624 B
examples/demo/dist/chunks/alias-outside.********.js 139 B
examples/demo/dist/chunks/class-fields.********.js 214 B
examples/demo/dist/chunks/compat.********.js 15.3 kB
examples/demo/dist/chunks/hoofd.module.********.js 1.48 kB
examples/demo/dist/chunks/index.********.js 201 B
examples/demo/dist/chunks/json.********.js 239 B
examples/demo/dist/chunks/meta-tags.********.js 300 B
examples/demo/dist/chunks/prerender.********.js 2.44 kB
examples/demo/dist/class-fields/index.html 705 B
examples/demo/dist/compat/index.html 1.6 kB
examples/demo/dist/env/index.html 780 B
examples/demo/dist/error/index.html 709 B
examples/demo/dist/files/index.html 742 B
examples/demo/dist/index.********.js 7.66 kB
examples/demo/dist/index.html 772 B
examples/demo/dist/json/index.html 712 B
examples/demo/dist/lazy-and-late/index.html 715 B
examples/demo/dist/meta-tags/index.html 780 B

compressed-size-action

Copy link
Member

@andrewiggins andrewiggins left a comment

Choose a reason for hiding this comment

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

Verified it fixes the issue for me locally!

Copy link
Member

@marvinhagemeister marvinhagemeister left a comment

Choose a reason for hiding this comment

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

Good catch with the offsets 🙌

@marvinhagemeister marvinhagemeister merged commit b4ffc91 into main Aug 30, 2021
@marvinhagemeister marvinhagemeister deleted the bugfix-process-inlining branch August 30, 2021 20:11
@github-actions github-actions bot mentioned this pull request Aug 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SyntaxError when loading script with process.env
3 participants