Skip to content

Commit 414f0a2

Browse files
committed
Add sea scripts
1 parent 3bb1a0d commit 414f0a2

File tree

6 files changed

+966
-108
lines changed

6 files changed

+966
-108
lines changed

.config/rollup.sea.config.mjs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* Rollup configuration for building SEA bootstrap thin wrapper.
3+
* Compiles TypeScript bootstrap to CommonJS for Node.js SEA compatibility.
4+
*/
5+
6+
import path from 'node:path'
7+
import url from 'node:url'
8+
9+
import { babel as babelPlugin } from '@rollup/plugin-babel'
10+
import commonjsPlugin from '@rollup/plugin-commonjs'
11+
import { nodeResolve } from '@rollup/plugin-node-resolve'
12+
13+
const __dirname = path.dirname(url.fileURLToPath(import.meta.url))
14+
const rootDir = path.join(__dirname, '..')
15+
16+
export default {
17+
input:
18+
process.env.SEA_BOOTSTRAP || path.join(rootDir, 'src/sea/bootstrap.mts'),
19+
output: {
20+
file:
21+
process.env.SEA_OUTPUT || path.join(rootDir, 'dist/sea/bootstrap.cjs'),
22+
format: 'cjs',
23+
interop: 'auto',
24+
},
25+
external: [
26+
// Only externalize Node.js built-ins for the thin wrapper.
27+
/^node:/,
28+
],
29+
plugins: [
30+
nodeResolve({
31+
preferBuiltins: true,
32+
exportConditions: ['node'],
33+
}),
34+
babelPlugin({
35+
babelHelpers: 'runtime',
36+
babelrc: false,
37+
configFile: path.join(__dirname, 'babel.config.js'),
38+
extensions: ['.mjs', '.js', '.ts', '.mts'],
39+
}),
40+
commonjsPlugin(),
41+
],
42+
}

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
"build:dist": "pnpm build:dist:src && pnpm build:dist:types",
3737
"build:dist:src": "run-p -c clean:dist clean:external && dotenvx -q run -f .env.local -- rollup -c .config/rollup.dist.config.mjs",
3838
"build:dist:types": "pnpm clean:dist:types && tsgo --project tsconfig.dts.json",
39+
"build:sea": "node src/sea/build-sea.mts",
40+
"build:sea:internal:bootstrap": "rollup -c .config/rollup.sea.config.mjs",
3941
"check": "pnpm check:lint && pnpm check:tsc",
4042
"check:lint": "dotenvx -q run -f .env.local -- eslint --report-unused-disable-directives .",
4143
"check:tsc": "tsgo",
@@ -167,6 +169,7 @@
167169
"open": "10.2.0",
168170
"oxlint": "1.15.0",
169171
"pony-cause": "2.1.11",
172+
"postject": "1.0.0-alpha.6",
170173
"registry-auth-token": "5.1.0",
171174
"registry-url": "7.2.0",
172175
"rollup": "4.50.1",

0 commit comments

Comments
 (0)