-
-
Notifications
You must be signed in to change notification settings - Fork 61
feat: enhanced SEA mode with walker integration and VFS #229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
f7dd471
7b55262
26ddcb0
69c0010
13541e1
49ad5a9
0842c82
862df2a
8a42a62
f539f92
6f580b6
151f25c
e49e17e
4d0ef4a
3399b66
f3d47fe
e6f5753
10a84db
8e612e3
0808a05
5e4a53a
a4dcb29
c2d3b91
2cdf100
8293cf8
d7229f7
1e80fed
2801ce4
ebc1162
3d0b118
219d978
8255a4a
58ccfa5
3fb1387
051c73b
f64bf63
9ed8ce5
a536430
394deb1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| --- | ||
| description: Build, lint, formatting, and TypeScript rules | ||
| --- | ||
|
|
||
| # Development | ||
|
|
||
| ## Build | ||
|
|
||
| ```bash | ||
| npm run build # Required before testing — compiles lib/ to lib-es5/ | ||
| npm run start # Watch mode with auto-rebuild | ||
| ``` | ||
|
|
||
| ## Lint & Format | ||
|
|
||
| ```bash | ||
| npm run lint # Check both ESLint + Prettier | ||
| npm run fix # Auto-fix all issues | ||
| npm run lint:code # ESLint only | ||
| npm run lint:style # Prettier only | ||
| ``` | ||
|
|
||
| - Always run `npm run lint` before committing. Fix all issues — never push dirty code. | ||
| - Console statements are disallowed in production code but allowed in test files. | ||
|
|
||
| ## TypeScript | ||
|
|
||
| - Strict mode enabled. Target: ES2022. Module system: CommonJS. | ||
| - Edit `lib/*.ts` only — never edit `lib-es5/*.js` directly. | ||
| - Requires Node.js >= 22.0.0. | ||
|
|
||
| ## Dependencies | ||
|
|
||
| - Keep runtime dependencies minimal — they affect all packaged apps. | ||
| - Use exact or caret ranges. | ||
| - `pkg-fetch` provides pre-compiled Node.js binaries. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| --- | ||
| description: Git workflow, commit conventions, and PR rules | ||
| --- | ||
|
|
||
| # Git & PR Workflow | ||
|
|
||
| ## CRITICAL: PR Target | ||
|
|
||
| - ALWAYS create PRs against `yao-pkg/pkg` (this fork). | ||
| - NEVER target `vercel/pkg` — it is archived and read-only. | ||
|
|
||
| ## Commits | ||
|
|
||
| - Use conventional commits: `feat:`, `fix:`, `refactor:`, `test:`, `chore:`, `docs:` | ||
| - Default branch: `main`. Tag format: `v${version}`. | ||
| - Branch protection requires passing CI checks. | ||
|
|
||
| ## Before Committing | ||
|
|
||
| 1. Clean test artifacts from test directories (`*.exe`, `*-linux`, `*-macos`, `*-win.exe`). | ||
| 2. Run `npm run lint` and fix all issues. | ||
| 3. Show `git status --short` and get user approval before committing. | ||
|
|
||
| ## Release | ||
|
|
||
| Uses `release-it` with conventional commits (`npm run release`). This runs linting, generates changelog, creates a git tag, pushes to GitHub, and publishes to npm as `@yao-pkg/pkg`. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| --- | ||
| description: VFS, native addons, cross-compilation, ESM, and platform-specific notes | ||
| paths: | ||
| - 'prelude/**' | ||
| - 'lib/**' | ||
| --- | ||
|
|
||
| # Platform & Virtual Filesystem | ||
|
|
||
| ## VFS Path Handling | ||
|
|
||
| - Packaged apps use `/snapshot/` prefix (or `C:\snapshot\` on Windows). | ||
| - Use `__dirname`/`__filename` for snapshot files, `process.cwd()` for runtime fs. | ||
| - Path handling differs between packaged and non-packaged execution. | ||
|
|
||
| ## Native Addons | ||
|
|
||
| - Extracted to `$HOME/.cache/pkg/` at runtime. Must match target Node.js version. | ||
| - `linuxstatic` target cannot load native bindings. | ||
| - Add `.node` files to `assets` if not detected automatically. | ||
|
|
||
| ## Cross-Compilation | ||
|
|
||
| - Bytecode generation requires the target architecture binary. | ||
| - Use `--no-bytecode` for cross-arch builds. | ||
| - Linux: QEMU for emulation. macOS: Rosetta 2 for arm64 building x64. | ||
|
|
||
| ## ESM | ||
|
|
||
| - Requires `--options experimental-require-module` on Node.js < 22.12.0. | ||
| - Check existing dictionary files for package-specific ESM handling. | ||
|
|
||
| ## Platform Notes | ||
|
|
||
| - **Linux**: `linuxstatic` target for max portability. | ||
| - **macOS**: arm64 requires code signing (`codesign` or `ldid`). | ||
| - **Windows**: `.exe` extension required; native modules must match target arch. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| --- | ||
| description: Project overview, structure, and key files for yao-pkg/pkg | ||
| --- | ||
|
|
||
| # Project Overview | ||
|
|
||
| `pkg` packages Node.js projects into standalone executables for Linux, macOS, and Windows. It supports Node.js 22 and newer, virtual filesystem bundling, V8 bytecode compilation, native addons, and compression (Brotli, GZip). | ||
|
|
||
|
Comment on lines
+6
to
+8
|
||
| This is `yao-pkg/pkg` — a maintained fork of the archived `vercel/pkg`. | ||
|
|
||
| ## Repository Structure | ||
|
|
||
| - `lib/` — TypeScript source (compiled to `lib-es5/` via `npm run build`) | ||
| - `prelude/` — Bootstrap code injected into packaged executables | ||
| - `dictionary/` — Package-specific configs for known npm packages | ||
| - `test/` — Numbered test directories (`test-XX-name/`) | ||
| - `.github/workflows/` — CI/CD (GitHub Actions) | ||
|
|
||
| ## Key Entry Points | ||
|
|
||
| - `lib/index.js` — API entry point | ||
| - `lib/bin.js` — CLI entry point | ||
| - `prelude/bootstrap.js` — Injected into every packaged executable | ||
| - `dictionary/*.js` — Special handling for specific npm packages | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| --- | ||
| description: Test commands, organization, and patterns | ||
| paths: | ||
| - 'test/**' | ||
| --- | ||
|
|
||
| # Testing | ||
|
|
||
| ## Commands | ||
|
|
||
| ```bash | ||
| npm run build # Always build first | ||
| npm run test:22 # Test with Node.js 22 | ||
| npm run test:host # Test with host Node.js version | ||
| node test/test.js node22 no-npm test-50-* # Run specific test pattern | ||
| ``` | ||
|
|
||
|
Comment on lines
+11
to
+17
|
||
| ## Organization | ||
|
|
||
| - Tests live in `test/test-XX-descriptive-name/` directories (XX = execution order). | ||
| - Each test has a `main.js` entry point using utilities from `test/utils.js`. | ||
| - `test-79-npm/` — npm package integration tests (only-npm). | ||
| - `test-42-fetch-all/` — verifies patches exist for all Node.js versions. | ||
|
|
||
| ## Writing Tests | ||
|
|
||
| 1. Create `test/test-XX-descriptive-name/` with a `main.js` | ||
| 2. Use `utils.pkg.sync()` to invoke pkg | ||
| 3. Verify outputs, clean up with `utils.filesAfter()` | ||
|
|
||
| Test artifacts (`*.exe`, `*-linux`, `*-macos`, `*-win.exe`) must be cleaned from test directories before committing. | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This document says TypeScript targets ES2017 and the project requires Node.js >= 20.0.0, but tsconfig.json targets ES2022 and package.json engines is now >= 22.0.0. Please update these lines so contributor guidance matches the actual build/runtime requirements.