Archived
0
0
Fork 0

feat: bundle wahpkg with 'pkg' for production

This commit is contained in:
Daryl Ronningen 2022-10-08 12:51:52 -07:00
parent cbb3e40e14
commit 10b690c8ce
4 changed files with 744 additions and 34 deletions

View file

@ -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"
}
}

View file

@ -1,18 +1,39 @@
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 {
input: 'src/index.ts',
output: {
dir: 'dist',
format: 'esm',
},
plugins: [
commonjs(),
nodeResolve({ exportConditions: ['node'] }),
typescript(),
terser(),
],
};
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',
format: 'esm',
},
plugins: [
commonjs(),
nodeResolve({ exportConditions: ['node'] }),
typescript(),
],
};
}
export default rollup;

View file

@ -6,7 +6,7 @@
"ES2022",
"dom"
],
"target": "ES2022",
"target": "ESNext",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true
}

721
yarn.lock

File diff suppressed because it is too large Load diff