-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Minifier removes function wrapper causing variables to become globals since 1.3.71 #8909
Comments
kdy1
added a commit
that referenced
this issue
May 7, 2024
**Description:** Tests are modified because I enabled script detection for the fixture test suite. **Related issue:** - Closes #8909
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Describe the bug
The minifier removes self-executing function wrappers in non-module input, causing variables inside to become globals. This can result in bugs when multiple script tags are executed on a page since the minified variable names can clash between different files.
Input code
Config
Playground link (or link to the minimal reproduction)
https://play.swc.rs/?version=1.3.71&code=H4sIAAAAAAAAA9NIK81LLsnMz9PQVKjmUlAoSyxSKEktLlGwVUCWqQVKpeQH5%2BemlmRk5qVrgJRoWqMKuuYUp8IkajU1gCQAmD4krF0AAAA%3D&config=H4sIAAAAAAAAA2WNwQrDMAxD7%2FmK4PMOI8f9jcncktKkwXZhpfTf52ZdV9hNekLS6ryHQSI8%2FGrSTEUW4tMbkaUovowAxYwSOVWF2zcdZI86HIUa2j4JKHJP2loS7iEcDcippG657scpVyYRY8ozncsZSz%2FSH52ec6OXS3fc%2Fsb3itvcG2Ucu4LfAAAA
SWC Info output
Expected behavior
Since the code is wrapped in a self-executing function, and the
minify.module
option isfalse
, the function should be preserved and the variables inside it should not become global. This was the case with 1.3.70 and earlier, but not since 1.3.71.Actual behavior
The variables inside the top-level self executing function become globals, potentially clashing with other variables on the page if multiple script tags are loaded.
Version
1.3.71 and later
Additional context
This affects non-esm bundles produced by Parcel. The above configuration is the default that Parcel uses.
The text was updated successfully, but these errors were encountered: