-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[Parcel 2] build breaks inline script tag for external library #6213
Comments
Inline scripts are processed just like "normal" scripts: https://v2.parceljs.org/languages/html/#inline-script-and-style-tags Related: #357 (And it's incredible that Google "forces" you to inline 10kb of render-blocking JS...) |
similar to #1087, here you proposed
Yes, but in a world rules by Adblock this is necessary for ad driven websites. Google is not the first one to require this but there is nothing we can do about it. This is super crucial for Adblock detection code and EU cookie consent management scripts. Unfortunately this is a huge blocker and the only way around it is to write a script that runs after parcel that adds the <script> tag again 😢 I even tried |
The problem is that we treat A workaround would be changing #5398 should fix that |
Thanks for that! :)
Edit: |
not sure if related but a more simple failure point with inline script tags: //module.js
export const tag = `<script></script>` //index.html
<script type=module>import {tag} from './module.js'</script> The import gets injected by the dev server and Chrome 90.0.4430.93 (and Edge) fails at the injected //simplifiedBundle.html
<script type=module>const tag = `<script></script>`</script> Possibly a browser bug? |
The browser is behaving correctly. Can you open a new issue for that? Maybe Parcel can automatically escape that. |
I think this should be fixed as of #6247 in the latest nightly since scripts without |
🐛 bug report
Some external libraries require the use of inline script tags. An example is Googles consent framework/funding choices.
When parcel builds the file it applies html minification and also parses the js code and does "something" with it that breaks the script.
This will look like:
When using parcel to build the html (same happens with
serve
) the inline script tag gets transformed which leads to it throwing an exception becausesomethingThatProbablyWasWindow.atob
is not available.I also had problems with minified files in general while migrating a legacy application, but it was hard to isolate and I just removed all
.min
suffixes and everything worked just fine.🎛 Configuration (.babelrc, package.json, cli command)
package.json:
parcel build test.html
I also tested
parcel build --no-optimize index.html
🤔 Expected Behavior
Script should not throw and the library should work.
The inline script should be included as is. Same as opening the test.html in the browser.
😯 Current Behavior
💁 Possible Solution
Provide some method or flag on the
<script />
tag to avoid any transformations🔦 Context
I am trying to migrate a legacy application (no bundler) to Parcel 2.
Everything works except the latest commit that introduced the library now blocks the new bundler setup from being released :(
💻 Code Sample
Minimal HTML:
🌍 Your Environment
The text was updated successfully, but these errors were encountered: