feat: bundle wahpkg with 'pkg' for production
This commit is contained in:
parent
cbb3e40e14
commit
10b690c8ce
4 changed files with 744 additions and 34 deletions
|
@ -8,7 +8,9 @@
|
|||
"bin": "./dist/index.js",
|
||||
"scripts": {
|
||||
"build": "rollup -c",
|
||||
"lint": "eslint --fix src/**/*.ts"
|
||||
"lint": "eslint --fix src/**/*.ts",
|
||||
"package:alpine": "rollup -c --environment PRODUCTION && pkg -t node18-alpine-x64 -C brotli -o dist/wahpkg dist/index.js",
|
||||
"package:linux": "rollup -c --environment PRODUCTION && pkg -t node18-linux-x64 -C brotli -o dist/wahpkg dist/index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"chalk": "^5.1.0",
|
||||
|
@ -30,10 +32,10 @@
|
|||
"@typescript-eslint/parser": "^5.39.0",
|
||||
"@yarnpkg/sdks": "^3.0.0-rc.22",
|
||||
"eslint": "^8.24.0",
|
||||
"pkg": "^5.8.0",
|
||||
"rollup": "^2.79.1",
|
||||
"rollup-plugin-terser": "^7.0.2",
|
||||
"rollup-plugin-typescript2": "^0.34.1",
|
||||
"typescript": "^4.8.4"
|
||||
},
|
||||
"packageManager": "yarn@3.2.4"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,27 @@
|
|||
import commonjs from '@rollup/plugin-commonjs';
|
||||
import { nodeResolve } from '@rollup/plugin-node-resolve';
|
||||
import process from 'node:process';
|
||||
import { terser } from 'rollup-plugin-terser';
|
||||
import typescript from 'rollup-plugin-typescript2';
|
||||
|
||||
export default {
|
||||
let rollup = {};
|
||||
|
||||
if (process.env.PRODUCTION) {
|
||||
rollup = {
|
||||
input: 'src/index.ts',
|
||||
output: {
|
||||
dir: 'dist',
|
||||
format: 'cjs',
|
||||
},
|
||||
plugins: [
|
||||
commonjs(),
|
||||
nodeResolve({ exportConditions: ['node'] }),
|
||||
typescript(),
|
||||
terser(),
|
||||
],
|
||||
};
|
||||
} else {
|
||||
rollup = {
|
||||
input: 'src/index.ts',
|
||||
output: {
|
||||
dir: 'dist',
|
||||
|
@ -13,6 +31,9 @@ export default {
|
|||
commonjs(),
|
||||
nodeResolve({ exportConditions: ['node'] }),
|
||||
typescript(),
|
||||
terser(),
|
||||
],
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
export default rollup;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"ES2022",
|
||||
"dom"
|
||||
],
|
||||
"target": "ES2022",
|
||||
"target": "ESNext",
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"esModuleInterop": true
|
||||
}
|
||||
|
|
Reference in a new issue