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

Add ES6 module build #2530

Merged
merged 1 commit into from
Nov 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
es6
lib
umd
examples/**/*-bundle.js
Expand Down
4 changes: 2 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## [HEAD]

- Add ES2015 module build ([#2530])

[#2530]: https://github.com/rackt/react-router/pull/2530

## [v1.0.0]

Expand Down Expand Up @@ -355,5 +357,3 @@ To cancel a "transition from", please refer to the

There's a lot of the old API we've missed, please give the [new
docs](/docs) a read and help us fill this guide in. Thanks!


2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Using [npm](https://www.npmjs.com/):

Note that you need to also install the [history](https://www.npmjs.com/package/history) package since it is a peer dependency of React Router and won't automatically be installed for you in npm 3+.

Then with a module bundler like [webpack](https://webpack.github.io/), use as you would anything else:
Then with a module bundler like [webpack](https://webpack.github.io/) that supports either CommonJS or ES2015 modules, use as you would anything else:

```js
// using an ES6 transpiler, like babel
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,23 @@
"files": [
"*.md",
"docs",
"es6",
"lib",
"npm-scripts",
"umd"
],
"main": "lib/index",
"jsnext:main": "es6/index",
"repository": {
"type": "git",
"url": "https://github.com/rackt/react-router.git"
},
"homepage": "https://rackt.github.io/react-router/",
"bugs": "https://github.com/rackt/react-router/issues",
"scripts": {
"build": "rimraf lib && babel ./modules -d lib --ignore '__tests__'",
"build": "npm run build-cjs && npm run build-es6",
"build-cjs": "rimraf lib && babel ./modules -d lib --ignore '__tests__'",
"build-es6": "rimraf es6 && babel ./modules -d es6 --blacklist=es6.modules --ignore '__tests__'",
Copy link
Member

Choose a reason for hiding this comment

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

Where do you get the --blacklist flag from? I don't see it in the docs.

Copy link
Member

Choose a reason for hiding this comment

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

Basically, this is supposed to do all transpiling except for modules, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The docs on the page now are for Babel 6. This is a Babel 5 option to disable a specific transform, per https://github.com/babel/babel.github.io/blob/862b43db93e48762671267034a50c30c00e433e2/docs/usage/options.md#options.

This is just making a build that is applying all of our normal Babel transforms, except for the ES6 module transform, leaving the import/export statements intact. It even properly transpiles the ES7 export extensions we use on index.js to be vanilla ES6.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exactly. It will look a little different with Babel 6, since --blacklist is gone there, and everything goes through plugins and presets, but it would thematically be very similar.

"build-umd": "NODE_ENV=production webpack modules/index.js umd/ReactRouter.js",
"build-min": "NODE_ENV=production webpack -p modules/index.js umd/ReactRouter.min.js",
"lint": "eslint modules examples",
Expand Down