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

Use ES6 import/export, create bundles with microbundle #41

Merged
merged 7 commits into from
Mar 31, 2019

Conversation

nrabinowitz
Copy link
Collaborator

@nrabinowitz nrabinowitz commented Mar 25, 2019

Modernizes the module imports and the build process, in order to create better bundles for distribution. This is a precursor to a separate PR that will create a browser-only Emscripten build in addition to the current universal build.

  • Moves from require to ES6 import/export (should allow tree-shaking for some bundlers)
  • Creates separate CommonJS and UMD bundles in dist
  • Cleans up and organizes scripts, breaking build-emscripten into two parts, one to update H3 and one to actually build
  • Moves to nyc for code coverage

Closes #21.

TODO:

"main": "index.js",
"main": "dist/h3-js.js",
"umd:main": "dist/h3-js.umd.js",
"browser": "dist/h3-js.umd.js",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one will be replaced by h3-js.browser.js in a subsequent diff.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely looking forward to that one. UMD is an abomination.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally agreed, but it's useful for standalone use in script tags, etc.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity how will the "browser" version be different to the UMD version?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm putting this diff up shortly - we're actually going to use browser to remap the CommonJS and ES6 bundles to builds that use the Emscripten browser environment build. This removes the references to fs and path that you noted in #21, and should simplify Webpack builds. So browser will actually be used for browser builds in external rollup tools, rather than for direct use in the browser.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I shall keep an eye out for it and give a quick test with Rollup JS + Webpack when its up...

@coveralls
Copy link

coveralls commented Mar 25, 2019

Pull Request Test Coverage Report for Build 92

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 87: 0.0%
Covered Lines: 308
Relevant Lines: 308

💛 - Coveralls


NOTE: The current `h3-js` is built with `emscripten-1.37.40`. Earlier or later versions MAY NOT WORK (emscripten does not follow semver, so patch updates may include breaking changes).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure you want to remove this warning about emscripten?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's no longer valid (currently using v1.38.29) and the recommended option is now clearly defined in the scripts, when you run docker boot.

@@ -0,0 +1,25 @@
#!/usr/bin/env bash

# Copyright 2018 Uber Technologies, Inc.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: should be 2019 here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will update, thanks!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed globally.

"main": "index.js",
"main": "dist/h3-js.js",
"umd:main": "dist/h3-js.umd.js",
"browser": "dist/h3-js.umd.js",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely looking forward to that one. UMD is an abomination.

cp libh3.js ../../../../out/libh3.js
cat << EOF >> ../../../../out/libh3.js
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need the module hackery anymore!

@nrabinowitz nrabinowitz merged commit 8d890be into uber:master Mar 31, 2019
@nrabinowitz nrabinowitz deleted the es6-bundles branch March 31, 2019 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants