compasscode / editor

Compass Project editor
https://compasscode.github.io/editor/
2 stars 0 forks source link

Use ES6 modules and tree shaking #12

Closed bates64 closed 7 years ago

bates64 commented 7 years ago

Rollupify allows us to tree-shake JavaScript, which basically means that unused functions are not included in the build. This means smaller file sizes.

Rollup, however, requires the use of ES6 modules over require:

import { coolFn } from './util'

Problem is, parcel doesn't yet support ES6 module syntax due to its complexity. We could:

PullJosh commented 7 years ago

Is it possible to run Rollupify in production builds only?

bates64 commented 7 years ago

@PullJosh Yeah, that's what I'm proposing.

Problem is, for development, parcel is unable to parse import/export, and in order to use rollup we need to use import/export - - we'd use browserify in dev too (with less plugins, like how the CSS is processed) but that'd certainly be slower than just using parcel.

Is that a worthwhile tradeoff for significantly smaller production files? I have no idea.