Skip to content

Commit 198cd5f

Browse files
committed
V6.0.0 Use rollup instead of browserify and add module exports for tools that support it.
1 parent 0f8029e commit 198cd5f

File tree

10 files changed

+183
-909
lines changed

10 files changed

+183
-909
lines changed

.babelrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"presets": ["@babel/env", "@babel/react", "@babel/flow"]
2+
"presets": ["@babel/react", "@babel/flow"]
33
}

.eslintrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"node_modules",
4848
"coverage",
4949
"examples",
50-
"lib"
50+
"lib",
51+
"es6"
5152
]
5253
}

.flowconfig

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[ignore]
22
.*/lib/.*
3+
.*/es6/.*
34
.*/coverage/.*
45
.*/node_modules/module-deps/.*
56

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ build/Release
2525

2626
node_modules
2727
lib
28+
es6
2829
examples/simple/bundle.js
2930

3031
.DS_Store

.npmignore

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
__tests__
2+
.circleci
3+
coverage
4+
examples
15
node_modules
26
src
3-
examples
47
.babelrc
5-
coverage
6-
.circleci
8+
.eslintrc
9+
.flowignore
10+
.prettierignore

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ build/Release
2525

2626
node_modules
2727
lib
28+
es6
2829
examples/simple/bundle.js
2930

3031
.DS_Store

examples/simple/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* @flow */
2-
import React from 'react'
2+
import * as React from 'react'
33
import ReactDom from 'react-dom'
44
import TimeAgo from '../../src/index'
55

package.json

+13-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
{
22
"name": "react-timeago",
3-
"version": "5.3.0",
3+
"version": "6.0.0",
44
"description": "A simple Time-Ago component for ReactJs",
55
"main": "lib/index.js",
6+
"module": "es6/index.js",
67
"scripts": {
7-
"babel": "babel src/ --out-dir lib/",
8-
"build": "npm run babel && npm run cpflow && npm run example",
8+
"babel-es6": "babel src/ --out-dir es6/ --presets=@babel/react,@babel/flow",
9+
"babel": "babel src/ --out-dir lib/ --presets=@babel/env,@babel/react,@babel/flow",
10+
"build": "npm run babel && npm run babel-es6 && npm run cpflow && npm run cpflow-es6 && npm run example",
11+
"cpflow-es6": "find ./src -name '*.js' -not -path '*/__*' | while read filepath; do cp $filepath `echo $filepath | sed 's/\\/src\\//\\/es6\\//g'`.flow; done",
912
"cpflow": "find ./src -name '*.js' -not -path '*/__*' | while read filepath; do cp $filepath `echo $filepath | sed 's/\\/src\\//\\/lib\\//g'`.flow; done",
10-
"example": "browserify -t babelify --debug examples/simple/index.js -o examples/simple/bundle.js",
13+
"example": "rollup -c ./rollup.config.js",
1114
"prepublish": "npm run build",
1215
"test": "jest --coverage"
1316
},
@@ -44,11 +47,13 @@
4447
"@babel/preset-flow": "^7.13.13",
4548
"@babel/preset-react": "^7.13.13",
4649
"@babel/preset-stage-1": "^7.8.3",
50+
"@rollup/plugin-babel": "^5.3.0",
51+
"@rollup/plugin-commonjs": "^19.0.0",
52+
"@rollup/plugin-node-resolve": "^13.0.0",
53+
"@rollup/plugin-replace": "^2.4.2",
4754
"@testing-library/jest-dom": "^5.11.4",
4855
"@testing-library/react": "^11.0.4",
4956
"babel-jest": "^26.3.0",
50-
"babelify": "^10.0.0",
51-
"browserify": "^17.0.0",
5257
"eslint-config-prettier": "^8.3.0",
5358
"eslint-plugin-flowtype": "^5.7.2",
5459
"eslint-plugin-import": "^2.23.0",
@@ -57,7 +62,8 @@
5762
"prettier": "^2.3.0",
5863
"react": "^17.0.2",
5964
"react-addons-test-utils": "^15.6.2",
60-
"react-dom": "^17.0.2"
65+
"react-dom": "^17.0.2",
66+
"rollup": "^2.47.0"
6167
},
6268
"dependencies": {
6369
"eslint": "^7.26.0"

rollup.config.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// eslint-disable-next-line
2+
import commonjs from '@rollup/plugin-commonjs'
3+
import { babel } from '@rollup/plugin-babel'
4+
import resolve from '@rollup/plugin-node-resolve'
5+
import replace from '@rollup/plugin-replace'
6+
7+
export default {
8+
external: [],
9+
input: 'examples/simple/index.js',
10+
output: {
11+
file: 'examples/simple/bundle.js',
12+
format: 'iife',
13+
},
14+
plugins: [
15+
babel({ babelHelpers: 'bundled' }),
16+
commonjs(),
17+
resolve({
18+
browser: true,
19+
dedupe: ['react', 'react-dom'],
20+
}),
21+
replace({
22+
'process.env.NODE_ENV': JSON.stringify('production'),
23+
}),
24+
],
25+
}

0 commit comments

Comments
 (0)