Skip to content

fix(build): avoid replacing unexpected words#3671

Merged
pi0 merged 3 commits intonitrojs:mainfrom
9romise:fix-replace
Oct 23, 2025
Merged

fix(build): avoid replacing unexpected words#3671
pi0 merged 3 commits intonitrojs:mainfrom
9romise:fix-replace

Conversation

@9romise
Copy link
Contributor

@9romise 9romise commented Oct 23, 2025

🔗 Linked issue

vueuse/vueuse#5114

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

The default delimiters in @rollup/plugin-replace incorrectly matches variable names containing $, as shown in the linked issue where typeof window$1 was transformed into "undefined"$1, causing the subsequent error.
This PR narrows down the matching scope to prevent accidental matches with unexpected variables.

Before:
\btypeof window\b(?!\.) - https://regex101.com/r/1gkfNj/1

After:
\btypeof window(?![\w.$]) - https://regex101.com/r/cyyShK/1

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@9romise 9romise requested a review from pi0 as a code owner October 23, 2025 08:10
@vercel
Copy link

vercel bot commented Oct 23, 2025

@9romise is attempting to deploy a commit to the Nitro Team on Vercel.

A member of the Team first needs to authorize it.

@pi0
Copy link
Member

pi0 commented Oct 23, 2025

@9romise can you please help adding a regression test to test/fixture/routes with problematic pattern?

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 23, 2025

Open in StackBlitz

npm i https://pkg.pr.new/nitrojs/nitro@3671

commit: 6a29344

@9romise
Copy link
Contributor Author

9romise commented Oct 23, 2025

Sure, I'll add it later.

Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

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

Thanks 👍🏼

@pi0 pi0 merged commit d977253 into nitrojs:main Oct 23, 2025
5 of 6 checks passed
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.

2 participants