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

Treeshaking pure external functions #1829

Closed
basav22 opened this issue Jan 1, 2018 · 5 comments
Closed

Treeshaking pure external functions #1829

basav22 opened this issue Jan 1, 2018 · 5 comments

Comments

@guybedford
Copy link
Contributor

@lukastaegert a treeshake.pureExternalFunctions = [{ id: 'styled-components', name: 'button' }] perhaps!?

@lukastaegert
Copy link
Member

@basav22: The issue is that rollup will always assume that external functions (which includes tag functions of tagged template literals as in this example) have side-effects. Both the definitions of the "primary" and the "default" button call the function "styled.button()" - and this function is called when the module is initialised and not when the buttons are actually used.

@guybedford 's suggestion of adding an option to list pure external function sounds good to me.

Additionally, we could start supporting UglifyJS /*@__PURE__*/ annotations. There already is an issue for that (#1293) and it might be a good idea to implement this together with a complementary /*@__KEEP__*/ annotation to resolve #1771 .

In any case I would classify solving this problem as an interesting enhancement. Further suggestions are always welcome.

@lukastaegert lukastaegert changed the title Treeshaking with external dependencies Treeshaking pure external functions Jan 1, 2018
@lukastaegert
Copy link
Member

I have taken the liberty to slightly adjust the issue title

@acewf
Copy link

acewf commented Jun 26, 2018

i resolved the issue by adding { modules: false } on the babel loader present

{
   loader: 'babel-loader',
   options: {
       presets: [
            ["@babel/preset-env", { modules: false }]
       ],
   }
}

@shellscape
Copy link
Contributor

Hey folks. This is a saved-form message, but rest assured we mean every word. The Rollup team is attempting to clean up the Issues backlog in the hopes that the active and still-needed, still-relevant issues bubble up to the surface. With that, we're closing issues that have been open for an eon or two, and have gone stale like pirate hard-tack without activity.

We really appreciate the folks have taken the time to open and comment on this issue. Please don't confuse this closure with us not caring or dismissing your issue, feature request, discussion, or report. The issue will still be here, just in a closed state. If the issue pertains to a bug, please re-test for the bug on the latest version of Rollup and if present, please tag @shellscape and request a re-open, and we'll be happy to oblige.

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

5 participants