Skip to content

Commit 749fb26

Browse files
build: update build tooling
1 parent d797c05 commit 749fb26

9 files changed

+226
-58
lines changed

package-lock.json

+157-48
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+12-5
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@
2222
"typescript"
2323
],
2424
"scripts": {
25-
"build": "rimraf build && tsc --project tsconfig.prod.json",
25+
"build": "npm run build:cjs",
26+
"build:clean": "rimraf build",
27+
"build:es2015": "tsc --project tsconfig.prod.esm2015.json",
28+
"build:esm5": "tsc --project tsconfig.prod.esm5.json",
29+
"build:cjs": "tsc --project tsconfig.prod.cjs.json",
30+
"build:umd": "rollup --config rollup.config.js",
31+
"build:types": "tsc --project tsconfig.prod.types.json",
2632
"prettier:fix": "prettier --write \"**/*.{ts,md}\"",
2733
"prettier:check": "prettier --check \"**/*.{ts,md}\"",
2834
"lint:fix": "eslint --max-warnings 0 --fix --ext .ts src/",
@@ -32,17 +38,17 @@
3238
"test:ci": "jest --runInBand --no-cache --coverage --verbose"
3339
},
3440
"dependencies": {
35-
"@types/validator": "13.1.0",
36-
"google-libphonenumber": "^3.2.10",
41+
"libphonenumber-js": "^1.7.55",
42+
"rollup-plugin-terser": "^6.1.0",
3743
"validator": "^13.1.1"
3844
},
3945
"devDependencies": {
40-
"@types/google-libphonenumber": "^7.4.19",
46+
"@rollup/plugin-node-resolve": "^8.4.0",
4147
"@types/jest": "^26.0.8",
4248
"@types/node": "^14.0.27",
49+
"@types/validator": "^13.1.0",
4350
"@typescript-eslint/eslint-plugin": "^3.7.1",
4451
"@typescript-eslint/parser": "^3.7.1",
45-
"dayjs": "1.8.31",
4652
"eslint": "^7.5.0",
4753
"eslint-config-prettier": "^6.11.0",
4854
"eslint-plugin-jest": "^23.20.0",
@@ -52,6 +58,7 @@
5258
"prettier": "^2.0.5",
5359
"reflect-metadata": "0.1.13",
5460
"rimraf": "3.0.2",
61+
"rollup": "^2.23.0",
5562
"ts-jest": "^26.1.4",
5663
"ts-node": "^8.10.2",
5764
"typescript": "^3.9.7"

rollup.config.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { nodeResolve } from '@rollup/plugin-node-resolve';
2+
import { terser } from 'rollup-plugin-terser';
3+
4+
export default {
5+
input: 'build/esm5/index.js',
6+
output: [
7+
{
8+
name: 'ClassValidator',
9+
format: 'umd',
10+
file: 'build/bundles/class-validator.umd.js',
11+
sourcemap: true,
12+
},
13+
{
14+
name: 'ClassValidator',
15+
format: 'umd',
16+
file: 'build/bundles/class-validator.umd.min.js',
17+
sourcemap: true,
18+
plugins: [terser()],
19+
},
20+
],
21+
plugins: [nodeResolve()],
22+
};

tsconfig.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
{
22
"compilerOptions": {
33
"module": "commonjs",
4+
"moduleResolution": "node",
45
"target": "es2018",
56
"lib": ["es2018"],
6-
"outDir": "build",
7+
"outDir": "build/node",
78
"rootDir": "./src",
89
"strict": true,
910
"sourceMap": true,
11+
"removeComments": false,
1012
"esModuleInterop": true,
1113
"experimentalDecorators": true,
1214
"emitDecoratorMetadata": true,
1315
"forceConsistentCasingInFileNames": true
1416
},
15-
"exclude": ["node_modules", "sample", "**/*.spec.ts", "test/**"]
17+
"exclude": ["build", "node_modules", "sample", "**/*.spec.ts", "test/**"]
1618
}

tsconfig.prod.cjs.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./tsconfig.prod.json",
3+
"compilerOptions": {
4+
"module": "CommonJS",
5+
"outDir": "build/cjs"
6+
},
7+
}

tsconfig.prod.esm2015.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./tsconfig.prod.json",
3+
"compilerOptions": {
4+
"module": "ES2015",
5+
"outDir": "build/esm2015",
6+
},
7+
}

tsconfig.prod.esm5.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "./tsconfig.prod.json",
3+
"compilerOptions": {
4+
"module": "ES2015",
5+
"target": "ES5",
6+
"outDir": "build/esm5",
7+
},
8+
}

tsconfig.prod.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
"extends": "./tsconfig.json",
33
"compilerOptions": {
44
"strict": false,
5-
"sourceMap": true,
6-
"removeComments": false,
7-
"declaration": true,
5+
"declaration": false,
86
},
97
}

tsconfig.prod.types.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "./tsconfig.prod.json",
3+
"compilerOptions": {
4+
"declaration": true,
5+
"emitDeclarationOnly": true,
6+
"outDir": "build/types",
7+
},
8+
}

0 commit comments

Comments
 (0)