Parcel: Performance improvements with sideEffects: false

Created on 17 Jun 2018  Â·  1Comment  Â·  Source: parcel-bundler/parcel

Parcel currently treats all assets the same way, and the core algorithm doesn't know about what is inside an asset. With ES modules, it is possible to have multiple exports, and for modules to re-export symbols from another module.

export {foo} from './foo';
export {bar} from './bar';

This example re-exports symbols from two modules, but doesn't actually have any code of its own. Currently, imports like import {foo} from './index' would result in Parcel compiling both foo.js and bar.js, even though only foo.js would end up in the final bundle. This can be slow, especially for large libraries like lodash-es, which have hundreds of exports we would have to compile even if only one was used.

It would be awesome if Parcel could be aware of the symbols exported from a module, and lazily compile them as needed rather than immediately compiling all dependencies. This is only possible if the module with the re-exports is marked with the sideEffects: false flag, since otherwise all code must be included in case side effects are present.

Feature ✨ Parcel 2 🌳 Tree Shaking

Most helpful comment

Implemented in #2967.

>All comments

Implemented in #2967.

Was this page helpful?
0 / 5 - 0 ratings