Skip to content

Add Babel to Rollup publishing#1131

Merged
DenisCarriere merged 5 commits into
masterfrom
babel-rollup
Nov 30, 2017
Merged

Add Babel to Rollup publishing#1131
DenisCarriere merged 5 commits into
masterfrom
babel-rollup

Conversation

@DenisCarriere

@DenisCarriere DenisCarriere commented Nov 27, 2017

Copy link
Copy Markdown
Contributor

Add Babel to Rollup publishing

First stab at trying to improve the published TurfJS bundle.

The ideal goal would be to "Tree Shake" JSTS's excess code and reduce the minified bundle of TurfJS.

✅ Success

  • Able to reduce total bundle size by 30% (200 KB) 40% (317 KB)

Bundle Before

1.86 MB    turf.js
765.94K   turf.min.js

Bundle Now

1.2M    turf.js
448K    turf.min.js

❌ Current Issues

  • When applying babel() all the Tree Shaking is disabled and filesize is increased the current size.
  • Babel + Rollup might have an issue when using export * syntax from turf-jsts

@DenisCarriere

DenisCarriere commented Nov 27, 2017

Copy link
Copy Markdown
Contributor Author

@stebogit If we get this right we can now introduce ES6 code to any dependencies & internally. That means Class, Set(), Map() would be fine to include. As long as the ES6 syntax is supported with NodeJS v6.

More and more dependencies are slowly introducing ES6 into their source code, I'd personally rather use real ES6 Classes than fake Functions that act like Classes.

@DenisCarriere

Copy link
Copy Markdown
Contributor Author

JSTS-free bundle filesize

// JSTS Modules
export {default as difference} from '@turf/difference';
export {default as buffer} from '@turf/buffer';
export {default as union} from '@turf/union';
export {default as intersect} from '@turf/intersect';

// JSTS Sub-Modules
export {default as dissolve} from '@turf/dissolve';
export {default as hexGrid} from '@turf/hex-grid';
export {default as mask} from '@turf/mask';
export {default as squareGrid} from '@turf/square-grid';
export {default as triangleGrid} from '@turf/triangle-grid';
export {default as interpolate} from '@turf/interpolate';

When commenting out the JSTS dependent modules from the index and the file size significantly gets reduced to:

668K    turf.js
168K    turf.min.js

With JSTS bundle size

The difference in filesize between both is about 372KB which means JSTS inflates the TurfJS repo by 3x.

1.4M    turf.js
540K    turf.min.js

@DenisCarriere DenisCarriere merged commit a99071b into master Nov 30, 2017
@DenisCarriere DenisCarriere deleted the babel-rollup branch November 30, 2017 02:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant