Webpack: Tree shaking doesn't work with "export * from 'module'"

Created on 6 Aug 2016  路  3Comments  路  Source: webpack/webpack

I'm submitting a bug report

Webpack version:
2.1.0-beta.20

Current behavior:
Tree shaking works with re-exports like "export { something } from 'module'" but doesn't work with "export * from 'module'".

Expected/desired behavior:
Tree shaking works with any kind of re-export.

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem along with a gist/jsbin of your webpack configuration.
app/
    my-feature/
        func12.js
        func34.js
        index.js
    main.js

func12.js

export function func1() { console.log("func1") }
export function func2() { console.log("func2") }

func34.js

export function func3() { console.log("func3") }
export function func4() { console.log("func4") }

index.js

export * from "./func12"
export * from "./func34"

main.js

import { func1, func3 } from "./my-feature"

func1();
func3();
  • What is the expected behavior?
    Only func1() and func3() should be exported.
    func2() and func4() should not, they should be marked as "unused harmony export"
work required bug

Most helpful comment

Also, changing index.js like this

export { func1, func2 } from "./func12"
export { func3, func4 } from "./func34"

solves the problem, but I can't change all the third party modules to follow that rule.

All 3 comments

Also, changing index.js like this

export { func1, func2 } from "./func12"
export { func3, func4 } from "./func34"

solves the problem, but I can't change all the third party modules to follow that rule.

Same bug unfortunately, tree shaking is not working with export * from.

We'll fix it..

Was this page helpful?
0 / 5 - 0 ratings

Related issues

IngwiePhoenix picture IngwiePhoenix  路  3Comments

natew picture natew  路  3Comments

jaesung2061 picture jaesung2061  路  3Comments

dubrowgn picture dubrowgn  路  3Comments

abergs picture abergs  路  3Comments