File tree Expand file tree Collapse file tree 7 files changed +62
-33
lines changed Expand file tree Collapse file tree 7 files changed +62
-33
lines changed Original file line number Diff line number Diff line change 1+ es
12node_modules
23umd
34/* .js
Original file line number Diff line number Diff line change @@ -19,10 +19,10 @@ Using [npm](https://www.npmjs.com/):
1919Then with a module bundler like [ webpack] ( https://webpack.github.io/ ) , use as you would anything else:
2020
2121``` js
22- // using an ES6 transpiler, like babel
22+ // using ES modules
2323import Media from ' react-media'
2424
25- // not using an ES6 transpiler
25+ // using CommonJS modules
2626var Media = require (' react-media' )
2727```
2828
Original file line number Diff line number Diff line change 11{
22 "presets" : [
3- [ " es2015" , { "loose" : true } ] ,
3+ " ../tools/ es2015-preset " ,
44 " stage-1" ,
55 " react"
66 ],
Original file line number Diff line number Diff line change 66 "author" : " Michael Jackson" ,
77 "license" : " MIT" ,
88 "scripts" : {
9- "build" : " node ./scripts /build.js" ,
9+ "build" : " node ./tools /build.js" ,
1010 "clean" : " git clean -e '!node_modules' -fdX ." ,
11- "build-lib" : " babel ./modules -d . --ignore '__tests__'" ,
12- "build-umd" : " webpack modules/index.js umd/react-media.js" ,
13- "build-min" : " webpack -p modules/index.js umd/react-media.min.js" ,
1411 "release" : " node ./scripts/release.js" ,
15- "prepublish" : " node ./scripts /build.js" ,
12+ "prepublish" : " node ./tools /build.js" ,
1613 "lint" : " eslint modules" ,
1714 "test" : " npm run lint && karma start"
1815 },
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ const fs = require ( 'fs' )
2+ const execSync = require ( 'child_process' ) . execSync
3+ const inInstall = require ( 'in-publish' ) . inInstall
4+ const prettyBytes = require ( 'pretty-bytes' )
5+ const gzipSize = require ( 'gzip-size' )
6+
7+ if ( inInstall ( ) )
8+ process . exit ( 0 )
9+
10+ const exec = ( command , extraEnv ) =>
11+ execSync ( command , {
12+ stdio : 'inherit' ,
13+ env : Object . assign ( { } , process . env , extraEnv )
14+ } )
15+
16+ console . log ( 'Building CommonJS modules ...' )
17+
18+ exec ( 'babel modules -d . --ignore __tests__' , {
19+ BABEL_ENV : 'cjs'
20+ } )
21+
22+ console . log ( '\nBuilding ES modules ...' )
23+
24+ exec ( 'babel modules -d es --ignore __tests__' , {
25+ BABEL_ENV : 'es'
26+ } )
27+
28+ console . log ( '\nBuilding react-media.js ...' )
29+
30+ exec ( 'webpack modules/index.js umd/react-media.js' , {
31+ NODE_ENV : 'production'
32+ } )
33+
34+ console . log ( '\nBuilding react-media.min.js ...' )
35+
36+ exec ( 'webpack -p modules/index.js umd/react-media.min.js' , {
37+ NODE_ENV : 'production'
38+ } )
39+
40+ const size = gzipSize . sync (
41+ fs . readFileSync ( 'umd/react-media.min.js' )
42+ )
43+
44+ console . log ( '\ngzipped, the UMD build is %s' , prettyBytes ( size ) )
Original file line number Diff line number Diff line change 1+ const buildPreset = require ( 'babel-preset-es2015' ) . buildPreset
2+
3+ const BABEL_ENV = process . env . BABEL_ENV
4+
5+ module . exports = {
6+ presets : [
7+ [ buildPreset , {
8+ loose : true ,
9+ modules : BABEL_ENV === 'es' ? false : 'commonjs'
10+ } ]
11+ ]
12+ }
You can’t perform that action at this time.
0 commit comments