-
-
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
Scope hoisting less effective since rewrite #7481
Comments
I have identified one problem where pure comments of IIFE are stripped during the build: // index.js
import { strToU8 } from './other.js';
console.log((strToU8('hello world')));
// other.js
var u32 = Uint32Array;
var flm = /*#__PURE__*/ hMap(flt, 9, 0);
var deo = /*#__PURE__*/ new u32([
65540, 131080, 131088
]);
export function strToU8(a) {
return "converted";
}
var Unzip = /*#__PURE__*/ (function () {
console.log("UNUSED")
}());
export { Unzip }; results in (() => {
var $da3800f92a93f12a$var$u32 = Uint32Array;
var $da3800f92a93f12a$var$flm = /*#__PURE__*/ hMap(flt, 9, 0);
var $da3800f92a93f12a$var$deo = /*#__PURE__*/ new $da3800f92a93f12a$var$u32([
65540,
131080,
131088
]);
function $da3800f92a93f12a$export$366b39a6daa8ed7a(a) {
return "converted";
}
var $da3800f92a93f12a$export$9b7485f84cbaaa56 = function() { // <------- !!!
console.log("UNUSED");
}();
console.log($da3800f92a93f12a$export$366b39a6daa8ed7a('hello world'));
})();
//# sourceMappingURL=index.js.map See the linked swc issue, we'll see if there are more problems once that particular one is fixed. |
Thanks for researching the problem! For future reference, how did you get the bundled but pre- |
|
If I comment that |
Since swc-project/swc#3115 has been resolved if you add |
swc needs to be bumped and that pass has be added |
🐛 bug report
Scope hoisting is dramatically less effective since #6230. This seems to be because
#__PURE__
annotations don't work properly anymore.🎛 Configuration (.babelrc, package.json, cli command)
I'm testing with zero configuration. Here's
package.json
:🤔 Expected Behavior
The scope hoisting rewrite should not adversely affect scope hoisting for any case.
😯 Current Behavior
Scope hoisting is dramatically less effective in every version since ba57b65 (#6230).
💁 Possible Solution
The behavior is similar to what happens when you remove all
#__PURE__
annotations fromfflate
. Maybe all comments are now being stripped before terser processes the code?🔦 Context
Without the ability to utilize
/*#__PURE__*/
comments, every function call is considered a side effect, which makes it impossible to tree-shake out IIFEs and variables used in exported closures that are initialized to the result of a function call.💻 Code Sample
Here's my
index.html
:Here's
index.js
:To build, I use
parcel build index.html
. When usingparcel@2.0.0-nightly.654
(gitHead
= fdbcbd6):Running the same command using
parcel@2.0.0-nightly.655
(gitHead
= ba57b65):🌍 Your Environment
2.0.0-nightly.655
The text was updated successfully, but these errors were encountered: