Skip to content
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

sideBundle not working with treeshaking #1051

Open
pYr0x opened this issue Jul 24, 2018 · 3 comments
Open

sideBundle not working with treeshaking #1051

pYr0x opened this issue Jul 24, 2018 · 3 comments

Comments

@pYr0x
Copy link
Contributor

pYr0x commented Jul 24, 2018

see this demo app https://github.com/pYr0x/sidebundle

if treeshaking is off, vendor gets bundles out
if true, vendor is not bundled

@matthewp
Copy link
Member

This one might be a little tricky, we have multiple levels of side-effectual modules. I want to avoid preventing rollup from doing its dead code eliminate by having a blanket rule of keeping code when there are no side-effects just it is imported like import "foo"; but this might require that. Still investigating.

@matthewp
Copy link
Member

So, what's happening in this case is that the dependencies defined in cc/vendor:

import "popper.js";
import "bootstrap/js/src/dropdown";

Get promoted to to cc/main during tree-shaking:

/*cc@1.0.0#main*/
define('cc@1.0.0#main', [
    'popper.js@1.14.3#dist/umd/popper',
    'bootstrap@4.1.3#js/src/dropdown',
    'jquery@3.3.1#dist/jquery',
    'bootstrap@4.1.3#js/src/util'
], function () {
    'use strict';
});

This is an internal decision to rollup, which we can't really control. Even if we could I'm not sure that we should, just for this use case. Promoting dependencies to parent modules is good in most situations as it means the removal of a module (cc/vendor in this case).

Unfortunately this doesn't play well with the sideBundle feature. So I'm not sure what to do about this. sideBundle's sort of a weird feature, it lets you control how splitting works and that's not something steal-tools ever really did before.

@matthewp matthewp removed the p1 label Jul 26, 2018
@pYr0x
Copy link
Contributor Author

pYr0x commented Jul 26, 2018

the actual intention was to create a module that hardly ever changes. this code can be cached very well.
any other ideas how to make this work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants