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

adding npm scripts for compiling ES5 dist through babel #6

Merged
merged 6 commits into from Nov 23, 2017

Conversation

criography
Copy link

This PR adds a build script that would allow to use this library in opinionated environments ESNext is not fully supported, like create-react-app.

It doesn't alter the source at all.

@onury
Copy link
Owner

onury commented Nov 22, 2017

Thanks @criography. I'd like to merge this but 2 points:

  • Should better make it universal module at once (via webpack maybe) so it'd work directly in the browser too.
  • We might still have a /dist dir but import would be prettier like:
    import { invert } from 'invert-color'

Would you mind updating your PR for this?

@criography
Copy link
Author

  1. It was simpler to just use babel's plugin to achieve UMD.
  2. I wasn't sure if this is what you meant, but if the path is not specified, both require and import methods will use whatever is set as main declaration in package.json. At least that's my understanding - I don't have much experience in this field.
    In this commit, I set main to dist output, which seems to be the common strategy for libraries out there. That said, I'm open to suggestions how to handle it differently.

Copy link
Owner

@onury onury left a comment

Choose a reason for hiding this comment

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

invert object is not exposed properly in DOM. It was exported as window.index per the filename.

package.json Outdated
"scripts": {
"test": "node test",
"build": "babel src --presets es2015 --out-dir dist",
"watch": "babel -w src --presets es2015 --out-dir dist"
"build": "babel src --presets es2015 --plugins transform-es2015-modules-umd --out-dir dist",
Copy link
Owner

Choose a reason for hiding this comment

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

This way in DOM, it's exposed as window.index, not window.invert.

@onury
Copy link
Owner

onury commented Nov 23, 2017

It was simpler to just use babel's plugin to achieve UMD.

That's better.

@onury onury merged commit 88536b5 into onury:master Nov 23, 2017
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

2 participants