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",
|
"bin": "./dist/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "rollup -c",
|
"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": {
|
"dependencies": {
|
||||||
"chalk": "^5.1.0",
|
"chalk": "^5.1.0",
|
||||||
|
@ -30,10 +32,10 @@
|
||||||
"@typescript-eslint/parser": "^5.39.0",
|
"@typescript-eslint/parser": "^5.39.0",
|
||||||
"@yarnpkg/sdks": "^3.0.0-rc.22",
|
"@yarnpkg/sdks": "^3.0.0-rc.22",
|
||||||
"eslint": "^8.24.0",
|
"eslint": "^8.24.0",
|
||||||
|
"pkg": "^5.8.0",
|
||||||
"rollup": "^2.79.1",
|
"rollup": "^2.79.1",
|
||||||
"rollup-plugin-terser": "^7.0.2",
|
"rollup-plugin-terser": "^7.0.2",
|
||||||
"rollup-plugin-typescript2": "^0.34.1",
|
"rollup-plugin-typescript2": "^0.34.1",
|
||||||
"typescript": "^4.8.4"
|
"typescript": "^4.8.4"
|
||||||
},
|
}
|
||||||
"packageManager": "yarn@3.2.4"
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,39 @@
|
||||||
import commonjs from '@rollup/plugin-commonjs';
|
import commonjs from '@rollup/plugin-commonjs';
|
||||||
import { nodeResolve } from '@rollup/plugin-node-resolve';
|
import { nodeResolve } from '@rollup/plugin-node-resolve';
|
||||||
|
import process from 'node:process';
|
||||||
import { terser } from 'rollup-plugin-terser';
|
import { terser } from 'rollup-plugin-terser';
|
||||||
import typescript from 'rollup-plugin-typescript2';
|
import typescript from 'rollup-plugin-typescript2';
|
||||||
|
|
||||||
export default {
|
let rollup = {};
|
||||||
input: 'src/index.ts',
|
|
||||||
output: {
|
if (process.env.PRODUCTION) {
|
||||||
dir: 'dist',
|
rollup = {
|
||||||
format: 'esm',
|
input: 'src/index.ts',
|
||||||
},
|
output: {
|
||||||
plugins: [
|
dir: 'dist',
|
||||||
commonjs(),
|
format: 'cjs',
|
||||||
nodeResolve({ exportConditions: ['node'] }),
|
},
|
||||||
typescript(),
|
plugins: [
|
||||||
terser(),
|
commonjs(),
|
||||||
],
|
nodeResolve({ exportConditions: ['node'] }),
|
||||||
};
|
typescript(),
|
||||||
|
terser(),
|
||||||
|
],
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
rollup = {
|
||||||
|
input: 'src/index.ts',
|
||||||
|
output: {
|
||||||
|
dir: 'dist',
|
||||||
|
format: 'esm',
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
commonjs(),
|
||||||
|
nodeResolve({ exportConditions: ['node'] }),
|
||||||
|
typescript(),
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default rollup;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"ES2022",
|
"ES2022",
|
||||||
"dom"
|
"dom"
|
||||||
],
|
],
|
||||||
"target": "ES2022",
|
"target": "ESNext",
|
||||||
"allowSyntheticDefaultImports": true,
|
"allowSyntheticDefaultImports": true,
|
||||||
"esModuleInterop": true
|
"esModuleInterop": true
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue