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
Inlined dependency shaken differently when hoisted #946
Comments
So I narrowed it down further, the issue is that spreading a function return into an object means that object will not be shaken out, even if those functions are marked as pure. This only happens when the module is hoisted, however.
var problematicFunction = () => ({ 3: '3' });
var myObject = {
example: {
1: '1',
.../* @__PURE__ */ problematicFunction(),
}
}
export const Foo = 'foo';
import { Foo } from 'my-pkg';
console.log(Foo);
function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
var problematicFunction = () => ({
3: '3'
});
({
example: _extends({
1: '1'
}, /* @__PURE__ */problematicFunction())
});
const Foo = 'foo';
console.log(Foo); If you instead install the module into Not sure what would cause this, whether it's rollup itself or some plugin. |
It turns out it was the custom babel exclusion that wasn't using a regex pattern: Line 572 in b51b855
Didn't expect running through babel to break shaking, but that seems to correct it. |
Summary
Bit of a weird one, but I'm seeing different results from Microbundle based on whether a dependency is hoisted or not. The module is resolved without issue in both cases.
As far as I can tell this is not specific to any one dependency.
Reproduction
$ yarn install && yarn copy-to-root && yarn example build
$ yarn copy-to-subpackage && yarn example build
(so hoisted version won't be used)This just uses a dummy package
my-pkg
sat in the root of the project.The text was updated successfully, but these errors were encountered: