Skip to content

fix(build): avoid replacing unexpected words - #3671

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

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

Conversation

@9romise

@9romise 9romise commented Oct 23, 2025

Copy link
Copy Markdown
Contributor

🔗 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

vercel Bot commented Oct 23, 2025

Copy link
Copy Markdown

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

A member of the Team first needs to authorize it.

@pi0

pi0 commented Oct 23, 2025

Copy link
Copy Markdown
Member

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

@pkg-pr-new

pkg-pr-new Bot commented Oct 23, 2025

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 6a29344

@9romise

9romise commented Oct 23, 2025

Copy link
Copy Markdown
Contributor Author

Sure, I'll add it later.

@pi0 pi0 left a comment

Copy link
Copy Markdown
Member

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

2 participants