-
Notifications
You must be signed in to change notification settings - Fork 563
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
Rollup config breaks some third-party libraries #3071
Comments
I'm worndering if it is double transform with wranger deploy. Can you spot same issue in |
Hello -- thanks for the quick response! I'm not sure exactly what you mean...
|
I don't think it's a double transform issue, though -- this would arise from a single transform. The package contains a line of code that's something like
When Rollup applies its search-and-replace, the resulting source code is
This causes a syntax error when the build process actually tries to parse the module. |
Nitro output for
Do you see this issue in a file inside (consider before deploy, wrangler always does another transform step) |
I don't see the issue in I see the issue in the full log output; sorry, here that is:
|
I tried |
Oh, weird -- I do see output in |
Your issue stands correct and I checked locally, it happens for any builds without having external ( Your solution is also nice. Sadly we cannot either change or drop this change as it breaks other places that depend on this tree-shaking method. If you like to contribute to docs perhaps additing a section to end of cloudflare.md it is more than welcome 🙏🏼 |
OK -- thank you for looking into it.
I'm happy to make a small docs PR (probably tomorrow at this point). However, is there any further explanation for what this tree-shaking accomplishes that I can link to or describe? Is it that it's somehow allowing a compiler to exclude branches that are client-only or server-only, and that compiler refuses to make assumptions about the |
Yes exactly it is to guide compiler to remove such branches. Both to eliminate code and remove incompatible code paths. |
This is indeed a bug. Replacing arbitrary code like this globally and without considering the AST will inevitably lead to incredibly difficult to debug problems. This bug is also triggered in combination with In our case, this configuration causes |
Environment
Reproduction
adorack/nitro-error@fe1f99f
Steps to reproduce:
npm run build
Describe the bug
typeof window
with"undefined"
:nitro/src/rollup/config.ts
Line 254 in 3b31e9d
cloudflare-module
, PapaParse ends up with incorrectly nested double quotes, and Nitro fails to build with the error:ERROR Expected ',', got 'undefined'
.I first encountered this in Nuxt, and I'm able to work around this particular issue by applying this setting in the Nuxt config:
I'm not clear on why Nitro tries to apply this optimization.
Additional context
No response
Logs
The text was updated successfully, but these errors were encountered: