Skip to content
This repository was archived by the owner on Mar 17, 2024. It is now read-only.

Commit 4a8c0b4

Browse files
committed
add build script
1 parent 8b5d9ee commit 4a8c0b4

File tree

6 files changed

+152
-25
lines changed

6 files changed

+152
-25
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,9 @@ Temporary Items
130130

131131
# End of https://www.gitignore.io/api/macos
132132

133+
# Output Modules
133134
lib
135+
lib.js
136+
lib.mjs
137+
web.js
138+
web.mjs

.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ config
99
coverage
1010
jest.config.js
1111
LICENSE
12-
rollup.config.js
12+
rollup.build.ts
1313
src
1414
tsconfig.json

package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@
2323
"publishConfig": {
2424
"access": "public"
2525
},
26-
"main": "lib/index.js",
27-
"module": "lib/index.mjs",
26+
"main": "index.js",
27+
"module": "index.mjs",
2828
"types": "lib/index.d.ts",
2929
"scripts": {
30-
"build": "rollup -c",
30+
"example": "ts-node example/example",
31+
"build": "ts-node rollup.build",
3132
"test": "jest",
3233
"lint": "eslint -c .eslintrc.json --ext ts,tsx src",
3334
"storybook": "start-storybook -p 9000"
@@ -52,6 +53,7 @@
5253
"@rollup/plugin-commonjs": "^11.1.0",
5354
"@storybook/react": "^5.3.18",
5455
"@testing-library/react-hooks": "^3.2.1",
56+
"@types/fs-extra": "^8.1.0",
5557
"@types/prop-types": "^15.7.3",
5658
"@types/react": "^16.9.17",
5759
"@types/react-dom": "^16.9.4",
@@ -68,6 +70,7 @@
6870
"eslint-plugin-prettier": "^3.1.3",
6971
"eslint-plugin-react": "^7.19.0",
7072
"eslint-plugin-react-hooks": "^3.0.0",
73+
"fs-extra": "^9.0.0",
7174
"jest": "^25.3.0",
7275
"jest-graphviz": "^0.3.1",
7376
"prettier": "^1.19.1",
@@ -80,6 +83,7 @@
8083
"ts-graphviz": "^0.10.0",
8184
"ts-jest": "^25.3.1",
8285
"ts-loader": "^7.0.2",
86+
"ts-node": "^8.9.1",
8387
"typescript": "^3.8.2"
8488
}
8589
}

rollup.build.ts

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import { rollup } from 'rollup';
2+
import typescript from 'rollup-plugin-typescript2';
3+
import { terser } from 'rollup-plugin-terser';
4+
import commonjs from '@rollup/plugin-commonjs';
5+
import { move, remove } from 'fs-extra';
6+
7+
async function build({
8+
input,
9+
output,
10+
declaration,
11+
external,
12+
}: {
13+
input: string;
14+
output: string;
15+
declaration: boolean;
16+
external: string[];
17+
}): Promise<void> {
18+
const bundle = await rollup({
19+
input,
20+
plugins: [
21+
commonjs(),
22+
typescript({
23+
tsconfigOverride: {
24+
compilerOptions: {
25+
declaration,
26+
},
27+
},
28+
}),
29+
terser(),
30+
],
31+
external,
32+
});
33+
await Promise.all([
34+
bundle.write({
35+
format: 'cjs',
36+
file: `${output}/index.js`,
37+
}),
38+
bundle.write({
39+
format: 'esm',
40+
file: `${output}/index.mjs`,
41+
}),
42+
]);
43+
}
44+
45+
(async (): Promise<void> => {
46+
await Promise.all([remove('lib'), remove('lib.js'), remove('lib.mjs'), remove('web.js'), remove('web.mjs')]);
47+
await Promise.all([
48+
build({
49+
input: 'src/index.ts',
50+
output: 'lib',
51+
declaration: true,
52+
external: ['react', 'react-dom/server', 'ts-graphviz', 'prop-types', 'react-reconciler'],
53+
}),
54+
build({
55+
input: 'src/web/index.ts',
56+
output: 'lib/web',
57+
declaration: false,
58+
external: ['react', 'react-dom/server', 'ts-graphviz', 'react-reconciler', '@hpcc-js/wasm'],
59+
}),
60+
]);
61+
62+
await Promise.all([
63+
move('lib/index.js', 'lib.js'),
64+
move('lib/index.mjs', 'lib.mjs'),
65+
move('lib/web/index.js', 'web.js'),
66+
move('lib/web/index.mjs', 'web.mjs'),
67+
]);
68+
})();

rollup.config.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

yarn.lock

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2075,6 +2075,13 @@
20752075
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f"
20762076
integrity sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==
20772077

2078+
"@types/fs-extra@^8.1.0":
2079+
version "8.1.0"
2080+
resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-8.1.0.tgz#1114834b53c3914806cd03b3304b37b3bd221a4d"
2081+
integrity sha512-UoOfVEzAUpeSPmjm7h1uk5MH6KZma2z2O7a75onTGjnNvAvMVrPzPL/vBbT65iIGHWj6rokwfmYcmxmlSf2uwg==
2082+
dependencies:
2083+
"@types/node" "*"
2084+
20782085
"@types/history@*":
20792086
version "4.7.5"
20802087
resolved "https://registry.yarnpkg.com/@types/history/-/history-4.7.5.tgz#527d20ef68571a4af02ed74350164e7a67544860"
@@ -2703,6 +2710,11 @@ are-we-there-yet@~1.1.2:
27032710
delegates "^1.0.0"
27042711
readable-stream "^2.0.6"
27052712

2713+
arg@^4.1.0:
2714+
version "4.1.3"
2715+
resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089"
2716+
integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==
2717+
27062718
argparse@^1.0.7:
27072719
version "1.0.10"
27082720
resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
@@ -2870,6 +2882,11 @@ asynckit@^0.4.0:
28702882
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
28712883
integrity sha1-x57Zf380y48robyXkLzDZkdLS3k=
28722884

2885+
at-least-node@^1.0.0:
2886+
version "1.0.0"
2887+
resolved "https://registry.yarnpkg.com/at-least-node/-/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2"
2888+
integrity sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==
2889+
28732890
atob@^2.1.2:
28742891
version "2.1.2"
28752892
resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9"
@@ -4469,6 +4486,11 @@ diff-sequences@^25.2.6:
44694486
resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-25.2.6.tgz#5f467c00edd35352b7bca46d7927d60e687a76dd"
44704487
integrity sha512-Hq8o7+6GaZeoFjtpgvRBUknSXNeJiCx7V9Fr94ZMljNiCr9n9L8H8aJqgWOQiDDGdyn29fRNcDdRVJ5fdyihfg==
44714488

4489+
diff@^4.0.1:
4490+
version "4.0.2"
4491+
resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d"
4492+
integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==
4493+
44724494
diffie-hellman@^5.0.0:
44734495
version "5.0.3"
44744496
resolved "https://registry.yarnpkg.com/diffie-hellman/-/diffie-hellman-5.0.3.tgz#40e8ee98f55a2149607146921c63e1ae5f3d2875"
@@ -5580,6 +5602,16 @@ fs-extra@^0.30.0:
55805602
path-is-absolute "^1.0.0"
55815603
rimraf "^2.2.8"
55825604

5605+
fs-extra@^9.0.0:
5606+
version "9.0.0"
5607+
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.0.0.tgz#b6afc31036e247b2466dc99c29ae797d5d4580a3"
5608+
integrity sha512-pmEYSk3vYsG/bF651KPUXZ+hvjpgWYw/Gc7W9NFUe3ZVLczKKWIij3IKpOrQcdw4TILtibFslZ0UmR8Vvzig4g==
5609+
dependencies:
5610+
at-least-node "^1.0.0"
5611+
graceful-fs "^4.2.0"
5612+
jsonfile "^6.0.1"
5613+
universalify "^1.0.0"
5614+
55835615
fs-minipass@^2.0.0:
55845616
version "2.1.0"
55855617
resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-2.1.0.tgz#7f5036fdbf12c63c169190cbe4199c852271f9fb"
@@ -7598,6 +7630,15 @@ jsonfile@^4.0.0:
75987630
optionalDependencies:
75997631
graceful-fs "^4.1.6"
76007632

7633+
jsonfile@^6.0.1:
7634+
version "6.0.1"
7635+
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.0.1.tgz#98966cba214378c8c84b82e085907b40bf614179"
7636+
integrity sha512-jR2b5v7d2vIOust+w3wtFKZIfpC2pnRmFAhAC/BuweZFQR8qZzxH1OyrQ10HmdVYiXWkYUqPVsz91cG7EL2FBg==
7637+
dependencies:
7638+
universalify "^1.0.0"
7639+
optionalDependencies:
7640+
graceful-fs "^4.1.6"
7641+
76017642
jsprim@^1.2.2:
76027643
version "1.4.1"
76037644
resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2"
@@ -7868,7 +7909,7 @@ make-dir@^3.0.0, make-dir@^3.0.2:
78687909
dependencies:
78697910
semver "^6.0.0"
78707911

7871-
make-error@1.x:
7912+
make-error@1.x, make-error@^1.1.1:
78727913
version "1.3.6"
78737914
resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2"
78747915
integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==
@@ -10387,6 +10428,14 @@ source-map-resolve@^0.5.0:
1038710428
source-map-url "^0.4.0"
1038810429
urix "^0.1.0"
1038910430

10431+
source-map-support@^0.5.17:
10432+
version "0.5.19"
10433+
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61"
10434+
integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==
10435+
dependencies:
10436+
buffer-from "^1.0.0"
10437+
source-map "^0.6.0"
10438+
1039010439
source-map-support@^0.5.6, source-map-support@~0.5.12:
1039110440
version "0.5.16"
1039210441
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.16.tgz#0ae069e7fe3ba7538c64c98515e35339eac5a042"
@@ -11093,6 +11142,17 @@ ts-loader@^7.0.2:
1109311142
micromatch "^4.0.0"
1109411143
semver "^6.0.0"
1109511144

11145+
ts-node@^8.9.1:
11146+
version "8.9.1"
11147+
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-8.9.1.tgz#2f857f46c47e91dcd28a14e052482eb14cfd65a5"
11148+
integrity sha512-yrq6ODsxEFTLz0R3BX2myf0WBCSQh9A+py8PBo1dCzWIOcvisbyH6akNKqDHMgXePF2kir5mm5JXJTH3OUJYOQ==
11149+
dependencies:
11150+
arg "^4.1.0"
11151+
diff "^4.0.1"
11152+
make-error "^1.1.1"
11153+
source-map-support "^0.5.17"
11154+
yn "3.1.1"
11155+
1109611156
ts-pnp@^1.1.2:
1109711157
version "1.2.0"
1109811158
resolved "https://registry.yarnpkg.com/ts-pnp/-/ts-pnp-1.2.0.tgz#a500ad084b0798f1c3071af391e65912c86bca92"
@@ -11246,6 +11306,11 @@ universalify@^0.1.0:
1124611306
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66"
1124711307
integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==
1124811308

11309+
universalify@^1.0.0:
11310+
version "1.0.0"
11311+
resolved "https://registry.yarnpkg.com/universalify/-/universalify-1.0.0.tgz#b61a1da173e8435b2fe3c67d29b9adf8594bd16d"
11312+
integrity sha512-rb6X1W158d7pRQBg5gkR8uPaSfiids68LTJQYOtEUhoJUWBdaQHsuT/EUduxXYxcrt4r5PJ4fuHW1MHT6p0qug==
11313+
1124911314
unpipe@1.0.0, unpipe@~1.0.0:
1125011315
version "1.0.0"
1125111316
resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec"
@@ -11783,3 +11848,8 @@ yargs@^15.3.1:
1178311848
which-module "^2.0.0"
1178411849
y18n "^4.0.0"
1178511850
yargs-parser "^18.1.1"
11851+
11852+
yn@3.1.1:
11853+
version "3.1.1"
11854+
resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50"
11855+
integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==

0 commit comments

Comments
 (0)