Skip to content

Commit 36d680f

Browse files
committed
Compile using rollup and minify using terser
1 parent 9e5e0b3 commit 36d680f

File tree

3 files changed

+34
-7
lines changed

3 files changed

+34
-7
lines changed

package.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,9 @@
3939
"src/{ts,js}/"
4040
],
4141
"scripts": {
42-
"clean": "shx rm -rf dist src/js",
43-
"compile": "npm-run-all --sequential clean compile:ts compile:js minify:*",
42+
"clean": "shx rm -rf dist",
43+
"compile": "npm-run-all --sequential clean compile:js",
4444
"compile:js": "rollup --config rollup.config.js --sourcemap",
45-
"compile:ts": "tsc --module ESNext",
46-
"minify:umd": "uglifyjs --compress typeofs=false,drop_console=true --mangle --comments \"/^!/\" --source-map \"content=dist/umd/nusantara-valid.js.map,includeSources,url=nusantara-valid.js.map\" --output dist/umd/nusantara-valid.min.js dist/umd/nusantara-valid.js",
4745
"test": "mocha --require ts-node/register **/*.test.ts"
4846
},
4947
"devDependencies": {

rollup.config.js

+30-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import babel from '@rollup/plugin-babel'
2+
import typescript from '@rollup/plugin-typescript'
3+
import { terser } from 'rollup-plugin-terser'
24

35
export default {
4-
input: 'src/js/nusantara-valid.js',
6+
input: 'src/ts/nusantara-valid.ts',
57
output: [
68
{
79
file: 'dist/cjs/nusantara-valid.js',
@@ -15,12 +17,39 @@ export default {
1517
file: 'dist/umd/nusantara-valid.js',
1618
format: 'umd',
1719
name: 'NusantaraValid'
20+
}, {
21+
file: 'dist/js/nusantara-valid.js',
22+
format: 'iife',
23+
name: 'NusantaraValid'
24+
}, {
25+
file: 'dist/cjs/nusantara-valid.min.js',
26+
format: 'cjs',
27+
name: 'NusantaraValid',
28+
plugins: [terser()]
29+
}, {
30+
file: 'dist/esm/nusantara-valid.min.mjs',
31+
format: 'esm',
32+
name: 'NusantaraValid',
33+
plugins: [terser()]
34+
}, {
35+
file: 'dist/umd/nusantara-valid.min.js',
36+
format: 'umd',
37+
name: 'NusantaraValid',
38+
plugins: [terser()]
39+
}, {
40+
file: 'dist/js/nusantara-valid.min.js',
41+
format: 'iife',
42+
name: 'NusantaraValid',
43+
plugins: [terser()]
1844
}
1945
],
2046
plugins: [
2147
babel({
2248
exclude: 'node_modules/**',
2349
babelHelpers: 'bundled'
50+
}),
51+
typescript({
52+
typescript: require('typescript')
2453
})
2554
]
2655
}

tsconfig.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
/* Basic Options */
66
// "incremental": true, /* Enable incremental compilation */
7-
"target": "ESNEXT", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
7+
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
88
// "module": "", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
99
"lib": ["es6", "dom", "esnext"], /* Specify library files to be included in the compilation. */
1010
// "allowJs": true, /* Allow javascript files to be compiled. */
@@ -14,7 +14,7 @@
1414
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
1515
"sourceMap": true, /* Generates corresponding '.map' file. */
1616
// "outFile": "./", /* Concatenate and emit output to single file. */
17-
"outDir": "src/js", /* Redirect output structure to the directory. */
17+
// "outDir": "src/js", /* Redirect output structure to the directory. */
1818
"rootDir": "src/ts", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
1919
// "composite": true, /* Enable project compilation */
2020
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */

0 commit comments

Comments
 (0)