Skip to content

Commit

Permalink
Change build folders to es & cjs
Browse files Browse the repository at this point in the history
This will make importing the es module a little nicer:

  import Waypoint from 'react-waypoint/es';

instead of

  import Waypoint from 'react-waypoint/build/index.mjs';

Thanks to @jmeas for the suggestion.
  • Loading branch information
trotzig committed Oct 5, 2017
1 parent c7df56c commit c593bdf
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
@@ -1 +1,3 @@
build
es
cjs
2 changes: 2 additions & 0 deletions .gitignore
@@ -1,4 +1,6 @@
build
es
cjs
node_modules
npm-debug.log
.idea/
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -47,7 +47,7 @@ import Waypoint from 'react-waypoint';
```

*Alternatively, you can also use the ES module that this package provides:
`import Waypoint from 'react-waypoint/build/index.mjs'`.*
`import Waypoint from 'react-waypoint/es'`.*

A waypoint normally fires `onEnter` and `onLeave` as you are scrolling, but it
can fire because of other events too:
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -2,7 +2,7 @@
"name": "react-waypoint",
"version": "7.3.0",
"description": "A React component to execute a function whenever you scroll to an element.",
"main": "build/index.js",
"main": "cjs/index.js",
"types": "index.d.ts",
"repository": {
"type": "git",
Expand All @@ -14,7 +14,7 @@
"build": "npm run clean && rollup -c",
"check-changelog": "expr $(git status --porcelain 2>/dev/null| grep \"^\\s*M.*CHANGELOG.md\" | wc -l) >/dev/null || (echo 'Please edit CHANGELOG.md' && exit 1)",
"check-only-changelog-changed": "(expr $(git status --porcelain 2>/dev/null| grep -v \"CHANGELOG.md\" | wc -l) >/dev/null && echo 'Only CHANGELOG.md may have uncommitted changes' && exit 1) || exit 0",
"clean": "rimraf build",
"clean": "rimraf es cjs",
"lint": "eslint . --ext .js,.jsx",
"postversion": "git commit package.json CHANGELOG.md -m \"Version $npm_package_version\" && npm run tag && git push && git push --tags && npm publish",
"prepublish": "in-publish && safe-publish-latest && npm run build || not-in-publish",
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js
Expand Up @@ -10,7 +10,7 @@ export default [
],
output: [
{ file: pkg.main, format: 'cjs' },
{ file: 'build/index.mjs', format: 'es' }
{ file: 'es/index.mjs', format: 'es' }

This comment has been minimized.

Copy link
@jamesplease

jamesplease Oct 5, 2017

Collaborator

Do we know if earlier versions of Node will support import Waypoint from 'react-waypoint/es; when the index file is .mjs? Because the .mjs file extension is still pretty new, and largely unsupported, we might still need to document this as import Waypoint from 'react-waypoint/es/index.mjs.

In other words, I'm not sure if this change makes the import any less ugly

This comment has been minimized.

Copy link
@trotzig

trotzig Oct 5, 2017

Author Collaborator

Good point. I don't know to be honest. I'll keep what we have here, it's easy to update the readme if people complain.

],
plugins: [
babel({
Expand Down

0 comments on commit c593bdf

Please sign in to comment.