-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
fix(vite): prevent assignment for rolldown's replacement plugin #33526
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
Conversation
|
|
WalkthroughThe change modifies the ReplacePlugin in Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Rationale: This is a localised, single-file modification that adds consistent parameter passing across conditional branches. The change is straightforward—adding a configuration option to a function call—with no complex logic or architectural implications. The repetition of the same option across both branches reduces cognitive load for verification. Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)**/*.{ts,tsx}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
🧠 Learnings (1)📚 Learning: 2025-04-18T18:33:41.753ZApplied to files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🔇 Additional comments (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
@nuxt/kit
nuxt
@nuxt/rspack-builder
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
CodSpeed Performance ReportMerging #33526 will not alter performanceComparing Summary
Footnotes |
|
thank you 🙏 |
|
@TheAlexLichter Out of interest I tried this fix via patching Edit: The following explanation is probably wrong since I assume the plugin works on source code (=text) level so replacing a string with a string is fine.I had a quick look at the source code and I think the issue is the following: The following object is passed to the replacePlugin config: {
'import.meta.dev': true,
'import.meta.test': false,
'import.meta.server': true,
'import.meta.client': false,
'import.meta.browser': false
}The replacePlugin function looks like this: function replacePlugin(values = {}, options = {}) {
let hasNonStringValues = false;
Object.keys(values).forEach((key) => {
const value = values[key];
if (typeof value !== "string") {
console.log(value);
hasNonStringValues = true;
values[key] = String(value);
}
});
if (hasNonStringValues) logger.warn("Some values provided to `replacePlugin` are not strings. They will be converted to strings, but for better performance consider converting them manually.");
return new BuiltinPlugin("builtin:replace", {
...options,
values
});
}In there all values of the object are converted to strings via |
In fact, the Rollup plugin does that already under the hood (converting values to strings), but without notifying you. |
Yes, my bad. I initially thought that maybe something like |
🔗 Linked issue
Resolves #33418
📚 Description
When using
rolldown-vite, the replacement plugin was used but thepreventAssignmentoption wasn't passed, leading to issues loading the app. This should be fixed with this PR.