Skip to content

Commit 4009dcb

Browse files
committed
chore: update build process
1 parent 84ec286 commit 4009dcb

File tree

10 files changed

+133
-836
lines changed

10 files changed

+133
-836
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
/build
44
/bundle
55
/dist
6+
/site
67
/.rts2*
78
/index.d.ts
8-
/shallowEqual.d.ts
99

1010
# Logs
1111
logs

build.sh

+2-10
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,12 @@
22
# Build use-restate
33

44
function BUNDLE {
5-
echo "Microbundling..."
5+
echo "Bundling..."
66
rm -rf dist
77
yarn bundle
88
mv dist/index.d.ts index.d.ts
9-
mv dist/shallowEqual.d.ts shallowEqual.d.ts
10-
echo "Microbundling done."
11-
}
12-
13-
function DELETE_TEMP {
14-
rm -rf .rts2_cache_cjs
15-
rm -rf .rts2_cache_es
16-
rm -rf .rts2_cache_umd
9+
echo "Bundling done."
1710
}
1811

1912
BUNDLE
20-
DELETE_TEMP
2113
echo "Completed build process."

example/App.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import { createStore } from 'redux';
33
import Count from './Count';
4-
import { RestateProvider } from 'use-restate';
4+
import { RestateProvider } from '../src';
55

66
const Actions = {
77
INCREMENT: 'INCREMENT',

example/Count.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { useRestate, useAction, useDispatch } from 'use-restate';
2+
import { useRestate, useAction, useDispatch } from '../src';
33

44
export default function Component() {
55
const dispatch = useDispatch();

package.json

+17-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"name": "use-restate",
33
"version": "0.0.15",
4-
"main": "dist/use-restate.js",
5-
"umd:main": "dist/use-restate.umd.js",
6-
"module": "dist/use-restate.m.js",
4+
"main": "dist/index.js",
5+
"umd": "dist/index.umd.js",
6+
"module": "dist/index.m.js",
77
"repository": {
88
"type": "git",
99
"url": "git+https://github.com/animify/useRestate.git"
@@ -19,15 +19,19 @@
1919
"author": "Stefan Mansson <st.mansson@icloud.com>",
2020
"license": "MIT",
2121
"scripts": {
22-
"start": "parcel ./example/index.html",
23-
"bundle": "microbundle build -i src/index.ts -o dist/ --name use-restate --compress false --sourcemap false",
22+
"start": "parcel ./example/index.html -d site",
23+
"bundle": "rollup -c",
2424
"build": "sh ./build.sh",
2525
"prepublishOnly": "yarn build",
2626
"release": "changelog && git push --follow-tags && yarn publish --access public --non-interactive",
2727
"lint": "tslint -p tsconfig.json",
2828
"test": "jest"
2929
},
3030
"dependencies": {
31+
"react": "^16.7.0-alpha.0",
32+
"react-dom": "^16.7.0-alpha.0"
33+
},
34+
"peerDependencies": {
3135
"react": "^16.7.0-alpha.0",
3236
"react-dom": "^16.7.0-alpha.0",
3337
"redux": "^4.0.1"
@@ -36,12 +40,18 @@
3640
"@types/jest": "^23.3.10",
3741
"@types/react": "^16.7.11",
3842
"@types/react-dom": "^16.0.11",
43+
"@types/redux": "^3.6.0",
3944
"changelog.md": "^1.1.0",
4045
"husky": "^1.2.0",
4146
"jest": "^23.6.0",
4247
"lint-staged": "^8.1.0",
43-
"microbundle": "^0.8.1",
4448
"parcel": "^1.10.3",
49+
"rollup": "^0.66.6",
50+
"rollup-plugin-babel": "^4.0.3",
51+
"rollup-plugin-commonjs": "^9.2.0",
52+
"rollup-plugin-node-resolve": "^3.4.0",
53+
"rollup-plugin-peer-deps-external": "^2.2.0",
54+
"rollup-plugin-typescript2": "^0.18.0",
4555
"ts-jest": "^23.10.5",
4656
"tslint": "^5.11.0",
4757
"typescript": "^3.2.1"
@@ -65,4 +75,4 @@
6575
"lint-staged": {
6676
"*.ts": "yarn run lint"
6777
}
68-
}
78+
}

rollup.config.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import typescript from 'rollup-plugin-typescript2';
2+
import commonjs from 'rollup-plugin-commonjs';
3+
import external from 'rollup-plugin-peer-deps-external';
4+
import resolve from 'rollup-plugin-node-resolve';
5+
import pkg from './package.json';
6+
7+
export default {
8+
input: 'src/index.ts',
9+
output: [
10+
{
11+
file: pkg.main,
12+
format: 'cjs',
13+
exports: 'named',
14+
},
15+
{
16+
file: pkg.module,
17+
format: 'es',
18+
exports: 'named',
19+
},
20+
],
21+
plugins: [
22+
external(),
23+
resolve(),
24+
typescript({
25+
clean: true,
26+
rollupCommonJSResolveHack: true,
27+
exclude: ['*.d.ts', '**/*.d.ts'],
28+
}),
29+
commonjs(),
30+
],
31+
};

src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function useRestate<TState, TSelector>(selectFrom: (state: TState) => TSe
2121
const store = useStore();
2222

2323
const [restate, setRestate] = useState(() => selectFrom(store.getState()));
24-
const previousRestate = useRef();
24+
const previousRestate = useRef({});
2525

2626
useEffect(() => {
2727
previousRestate.current = restate;

src/react.d.ts

-17
This file was deleted.

tsconfig.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
{
22
"compilerOptions": {
3-
"moduleResolution": "node",
3+
"lib": ["dom", "es2015", "es2016", "es2017"],
4+
"outDir": "build",
45
"module": "esnext",
56
"target": "es5",
6-
"lib": ["es6", "dom", "es2016", "es2017"],
7-
"allowJs": false,
8-
"sourceMap": false,
97
"jsx": "react",
10-
"outDir": "build",
11-
"suppressImplicitAnyIndexErrors": true,
8+
"sourceMap": false,
9+
"allowJs": false,
10+
"noUnusedLocals": true,
1211
"declaration": true,
12+
"moduleResolution": "node",
1313
"forceConsistentCasingInFileNames": true,
1414
"noImplicitReturns": true,
1515
"noImplicitThis": true,
1616
"noImplicitAny": true,
1717
"strictNullChecks": true,
18-
"noUnusedLocals": true,
18+
"suppressImplicitAnyIndexErrors": true,
1919
"noUnusedParameters": true
2020
},
2121
"include": ["src"],
22-
"exclude": ["node_modules"]
23-
}
22+
"exclude": ["node_modules", "dist", "rollup.config.js"]
23+
}

0 commit comments

Comments
 (0)