-
-
Notifications
You must be signed in to change notification settings - Fork 108
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
Conversation
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 detectedLatest commit: cb3c011 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Size Change: -17 B (0%) Total Size: 804 kB
ℹ️ View Unchanged
|
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.
Verified it fixes the issue for me locally!
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.
Good catch with the offsets 🙌
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 modifiedcode
instead of the one that was passed to MagicString.