Skip to content

Commit e89efdd

Browse files
committed
Update build scripts
1 parent 6b8078d commit e89efdd

File tree

9 files changed

+74
-21
lines changed

9 files changed

+74
-21
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
css
2+
cjs
23
dist
34
es
45
example/package-example.js

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
cjs/
12
coverage/
23
css/
34
dist/

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.github
22
.husky
3+
cjs
34
coverage
45
css
56
dist

.size-snapshot.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
"gzipped": 32011
1111
},
1212
"react-bootstrap-typeahead.js": {
13-
"bundled": 321551,
14-
"minified": 106107,
15-
"gzipped": 36792
13+
"bundled": 321699,
14+
"minified": 106202,
15+
"gzipped": 36821
1616
},
1717
"react-bootstrap-typeahead.min.js": {
18-
"bundled": 289504,
19-
"minified": 97305,
20-
"gzipped": 33962
18+
"bundled": 289652,
19+
"minified": 97400,
20+
"gzipped": 33990
2121
}
2222
}

package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
"author": "ericgio",
77
"license": "MIT",
88
"files": [
9+
"cjs/",
910
"css/",
1011
"dist/",
1112
"docs/",
1213
"es/",
13-
"lib/",
1414
"types/",
1515
"LICENSE.md"
1616
],
17-
"main": "lib/index.js",
17+
"main": "cjs/index.js",
1818
"module": "es/index.js",
1919
"types": "types/index.d.ts",
2020
"repository": {
@@ -23,26 +23,25 @@
2323
},
2424
"bugs": "https://github.com/ericgio/react-bootstrap-typeahead/issues",
2525
"scripts": {
26-
"build": "npm run clean && npm run build:css && npm run build:cjs && npm run build:es && npm run build:dist && npm run build:types && npm run build:example",
26+
"build": "yarn clean && yarn build:css && yarn build:modules && yarn build:dist && yarn build:types && yarn build:example",
2727
"build:css": "node ./scripts/buildCSS.js",
2828
"build:dist": "rollup -c",
29-
"build:cjs": "BABEL_ENV=cjs babel src --out-dir lib -x '.ts,.tsx,.js,.jsx'",
30-
"build:es": "BABEL_ENV=es babel src --out-dir es -x '.ts,.tsx,.js,.jsx'",
29+
"build:modules": "node ./scripts/buildModules.js",
3130
"build:example": "webpack --mode production --config example/webpack.config.js",
32-
"build:types": "npx tsc",
33-
"check": "npm run lint && npm run typecheck && npm run prettier && npm test",
34-
"ci": "npm run lint && npm run typecheck && npm run prettier && npm run test:coverage",
35-
"clean": "rimraf coverage && rimraf css && rimraf dist && rimraf lib && rimraf es && rimraf types",
31+
"build:types": "tsc",
32+
"check": "yarn lint && yarn typecheck && yarn prettier && yarn test",
33+
"ci": "yarn lint && yarn typecheck && yarn prettier && yarn test:coverage",
34+
"clean": "rimraf coverage && rimraf css && rimraf dist && rimraf cjs && rimraf es && rimraf types",
3635
"deploy-example": "node ./scripts/deployExample.js",
3736
"lint": "eslint . --report-unused-disable-directives",
3837
"lint:fix": "eslint . --fix",
39-
"prettier": "npx prettier --check .",
40-
"postpublish": "npm run deploy-example",
41-
"prepublishOnly": "npm run check && npm run build",
38+
"prettier": "prettier --check .",
39+
"postpublish": "yarn deploy-example",
40+
"prepublishOnly": "yarn check && yarn build",
4241
"start": "webpack --mode development -w --progress --config example/webpack.config.js",
4342
"test": "jest --silent",
4443
"test:coverage": "jest --coverage",
45-
"typecheck": "npx tsc --noEmit"
44+
"typecheck": "tsc --noEmit"
4645
},
4746
"dependencies": {
4847
"@babel/runtime": "^7.14.6",
@@ -98,6 +97,7 @@
9897
"eslint": "^7.30.0",
9998
"eslint-config-prettier": "^8.3.0",
10099
"eslint-plugin-react-hooks": "^4.0.4",
100+
"execa": "^5.1.1",
101101
"gh-pages": "^3.2.3",
102102
"husky": "^7.0.1",
103103
"jest": "^27.0.6",

scripts/buildCSS.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
/* eslint-disable no-console */
55
/* eslint-disable @typescript-eslint/no-var-requires */
66

7+
const chalk = require('chalk');
78
const fs = require('fs');
89
const path = require('path');
910
const sass = require('sass');
@@ -37,6 +38,8 @@ if (!fs.existsSync(OUT_DIR)) {
3738
fs.mkdirSync(OUT_DIR);
3839
}
3940

41+
console.log(chalk.cyan('Building CSS files...\n'));
42+
4043
fs.readdirSync(STYLES_DIR).forEach((filename) => {
4144
const file = path.join(STYLES_DIR, filename);
4245

scripts/buildModules.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env node
2+
3+
/* eslint-disable @typescript-eslint/no-var-requires */
4+
/* eslint-disable import/no-extraneous-dependencies */
5+
/* eslint-disable no-console */
6+
7+
const chalk = require('chalk');
8+
const execa = require('execa');
9+
const path = require('path');
10+
11+
const shell = (cmd) =>
12+
execa(cmd, {
13+
shell: true,
14+
stdio: ['pipe', 'pipe', 'inherit'],
15+
});
16+
17+
const srcRoot = path.join(__dirname, '../src');
18+
const start = Date.now();
19+
20+
function buildModules() {
21+
const commands = [];
22+
['cjs', 'es'].forEach((env) => {
23+
commands.push(
24+
shell(
25+
`yarn babel ${srcRoot} -x ".ts,.tsx,.js,.jsx" --out-dir ${env} --env-name "${env}"`
26+
)
27+
);
28+
});
29+
return Promise.all(commands);
30+
}
31+
32+
Promise.resolve()
33+
.then(() => {
34+
console.log(chalk.cyan('Transpiling modules...\n'));
35+
})
36+
.then(buildModules)
37+
.then(() => {
38+
const seconds = (Date.now() - start) / 1000;
39+
console.log(chalk.green(`Finished building modules in ${seconds}s\n`));
40+
});

tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"emitDeclarationOnly": false,
88
"esModuleInterop": true,
99
"forceConsistentCasingInFileNames": true,
10-
"incremental": true,
1110
"isolatedModules": true,
1211
"jsx": "react",
1312
"module": "commonjs",

yarn.lock

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3070,6 +3070,14 @@ chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.1:
30703070
ansi-styles "^4.1.0"
30713071
supports-color "^7.1.0"
30723072

3073+
chalk@^4.1.2:
3074+
version "4.1.2"
3075+
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
3076+
integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==
3077+
dependencies:
3078+
ansi-styles "^4.1.0"
3079+
supports-color "^7.1.0"
3080+
30733081
char-regex@^1.0.2:
30743082
version "1.0.2"
30753083
resolved "https://registry.yarnpkg.com/char-regex/-/char-regex-1.0.2.tgz#d744358226217f981ed58f479b1d6bcc29545dcf"
@@ -4136,7 +4144,7 @@ evp_bytestokey@^1.0.0, evp_bytestokey@^1.0.3:
41364144
md5.js "^1.3.4"
41374145
safe-buffer "^5.1.1"
41384146

4139-
execa@^5.0.0:
4147+
execa@^5.0.0, execa@^5.1.1:
41404148
version "5.1.1"
41414149
resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.1.tgz#f80ad9cbf4298f7bd1d4c9555c21e93741c411dd"
41424150
integrity sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==

0 commit comments

Comments
 (0)