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

Support for ES2015 modules. #9

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

qubyte
Copy link
Collaborator

@qubyte qubyte commented Mar 24, 2016

One of the unfortunate drawbacks of ES2015 modules is that they can't be mixed with other module types, so there's no Grand Unified Module Definition. However, rollup allows an ES2015 module to be turned into a UMD module, so it's possible to get most of the way there.

This PR:

  • Updates the module to use ES2015 module syntax (no other ES2015 is used).
  • Updates the linter (initially for module support, but this picked up a couple of unusual whitespace issues). I've encoded Crockford's style in the rules to the best of my ability. The diff might be clearer with w=1.
  • Adds build scripts to generate the UMD module for tests and before publishing.
  • Updates the test runner to use the UMD build.
  • Adds a "jsnext:main" field (rollup specifies this, and webpack 2 can be configured to use it).

What you lose:

  • The UMD build is not committed, so github can't serve the UMD module.

It's possible to change this to have the UMD module built and added pre-commit or pre-push, which would resolve this issue, with a little inelegance.

So why do this? I'm using a fair amount of rollup lately, and it's great. It's entirely possible to use it with UMD modules, but that entails writing a module to call rollup and you lose the command line. Since the future is ES2015, the better option seemed to me to be to future-proof modules as I encounter them.

This is a speculative PR. If for whatever reason you don't like/want it, I shan't be offended!

@mroderick
Copy link
Owner

The UMD build is not committed, so github can't serve the UMD module.

I don't think that is much of a loss. People should use the tagged versions from npm anyway

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.

2 participants