forked from vercel/pkg
-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
f7dd471
feat: enhanced SEA mode with walker integration and VFS (#204)
robertsLando 7b55262
fix: move @platformatic/vfs to optionalDependencies for Node 20 CI co…
robertsLando 26ddcb0
feat: drop Node.js 20 support, require Node.js >= 22
robertsLando 69c0010
fix: restore test-00-sea Node version guard to < 20
robertsLando 13541e1
fix: restore assertSeaNodeVersion to check Node >= 20
robertsLando 49ad5a9
test: enhance SEA mode tests for pkg compatibility and error handling
robertsLando 0842c82
fix: improve error handling and conditionally remove Mach-O signature…
robertsLando 862df2a
refactor: extract shared runtime code into bootstrap-shared.js
robertsLando 8a42a62
fix: address Copilot review feedback on SEA pipeline
robertsLando f539f92
fix: throw when JSON config targets Node < 22 in SEA mode
robertsLando 6f580b6
fix: normalize paths for Windows compatibility in SEA bootstrap
robertsLando 151f25c
docs: add technical architecture documentation
robertsLando e49e17e
fix: normalize all SEA provider paths to POSIX for Windows compatibility
robertsLando 4d0ef4a
docs: mention --no-bytecode flag in architecture comparison
robertsLando 3399b66
fix: address Copilot review feedback for SEA enhanced mode
robertsLando f3d47fe
feat: add DEBUG_PKG diagnostics to SEA mode, deduplicate diagnostic code
robertsLando e6f5753
fix: address remaining Copilot review feedback
robertsLando 10a84db
feat: add worker thread support and fix SEA walker warnings
robertsLando 8e612e3
docs: update architecture documentation to include worker thread supp…
robertsLando 0808a05
fix: mount VFS at POSIX /snapshot on all platforms for Windows compat
robertsLando 5e4a53a
fix: use Module._compile for worker threads instead of raw eval
robertsLando a4dcb29
fix: use postject JS API instead of npx to inject SEA blobs
robertsLando c2d3b91
fix: avoid eager file loading and unnecessary temp files in SEA walker
robertsLando 2cdf100
fix: pass defaultEntrypoint in SEA bootstrap for API consistency
robertsLando 8293cf8
feat: add snapshotify function to convert file paths to snapshot paths
robertsLando d7229f7
docs: fix version comments and Node 22 requirement notes
robertsLando 1e80fed
refactor: reuse replaceSlashes from common.ts instead of duplicate to…
robertsLando 2801ce4
fix: handle VFS-incompatible fs calls in SEA bootstrap
robertsLando ebc1162
feat: add SKILL.md for packaging performance benchmarks comparison
robertsLando 3d0b118
perf: optimize SEA provider startup and add DEBUG_PKG_PERF instrument…
robertsLando 219d978
docs: split project instructions into modular .claude/rules files
robertsLando 8255a4a
feat: enhance SEA asset generation with single archive blob and offse…
robertsLando 58ccfa5
docs: update README and ARCHITECTURE.md for single archive blob and r…
robertsLando 3fb1387
fix: enable model invocation for performances-compare skill
robertsLando 051c73b
refactor: replace @platformatic/vfs with @roberts_lando/vfs@0.3.0
robertsLando f64bf63
refactor: update Node.js version requirements and testing commands in…
robertsLando 9ed8ce5
feat: track body modifications in stepStrip for enhanced record handling
robertsLando a536430
chore: update @roberts_lando/vfs to version 0.3.1 in package.json, pa…
robertsLando 394deb1
chore: update @roberts_lando/vfs to version 0.3.2
robertsLando af5b851
fix: address Copilot review — patchDlopen regression, SEA blob fallba…
robertsLando f2f1d9f
refactor: use assertSeaOutput helper in test-00-sea
robertsLando dd99f48
fix: address Copilot review — dlopen VFS, docs, prettierignore
robertsLando 7829973
feat(sea): support ESM entrypoints with top-level await
robertsLando 7476440
docs(readme): document ESM entry + top-level await in SEA mode
robertsLando 3155538
fix(sea): harden SEA pipeline — CJS bootstrap for ESM+TLA, blob gener…
robertsLando 33d43f9
fix(sea): self-review fixes — symlink fallback, archive bounds, short…
robertsLando beca977
docs(sea): align README + ARCHITECTURE with single-bootstrap dispatch
robertsLando 2ac0177
perf(sea): read SEA blob once and share buffer across targets
robertsLando 90352a3
fix(sea): address copilot review — mixed-major guard, emitWarning lea…
robertsLando File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| import { mkdir, writeFile } from 'fs/promises'; | ||
| import { dirname, join } from 'path'; | ||
|
|
||
| import { STORE_CONTENT, STORE_LINKS, STORE_STAT, snapshotify } from './common'; | ||
| import { FileRecords, SymLinks } from './types'; | ||
|
|
||
| export interface SeaManifest { | ||
| entrypoint: string; | ||
| directories: Record<string, string[]>; | ||
| stats: Record< | ||
| string, | ||
| { size: number; isFile: boolean; isDirectory: boolean } | ||
| >; | ||
| } | ||
|
robertsLando marked this conversation as resolved.
|
||
|
|
||
| export interface SeaAssetsResult { | ||
| assets: Record<string, string>; | ||
| manifestPath: string; | ||
| } | ||
|
|
||
| /** | ||
| * Transform walker/refiner output into SEA-compatible asset map and manifest. | ||
| * | ||
| * Asset keys use refiner paths (no /snapshot prefix) because @platformatic/vfs | ||
| * strips the mount prefix before passing paths to the provider. The entrypoint | ||
| * in the manifest uses the snapshotified path for process.argv[1] compatibility. | ||
| * | ||
| * Always uses POSIX '/' separator for manifest paths so the same blob works | ||
| * regardless of build platform. The bootstrap normalizes at runtime. | ||
| */ | ||
| export async function generateSeaAssets( | ||
| records: FileRecords, | ||
| entrypoint: string, | ||
| _symLinks: SymLinks, | ||
| tmpDir: string, | ||
| ): Promise<SeaAssetsResult> { | ||
| const assets: Record<string, string> = {}; | ||
| const manifest: SeaManifest = { | ||
| // Always use '/' — the bootstrap normalizes for the runtime platform | ||
| entrypoint: snapshotify(entrypoint, '/'), | ||
| directories: {}, | ||
| stats: {}, | ||
| }; | ||
|
|
||
| let modifiedFileCount = 0; | ||
|
|
||
| for (const snap in records) { | ||
| if (!records[snap]) continue; | ||
| const record = records[snap]; | ||
|
|
||
| // Map file content to SEA asset | ||
| if (record[STORE_CONTENT]) { | ||
| if (record.body != null) { | ||
| // File was modified (patches, rewrites) — write to temp file | ||
| const tempPath = join( | ||
| tmpDir, | ||
| 'assets', | ||
| `modified_${modifiedFileCount}`, | ||
| ); | ||
| modifiedFileCount += 1; | ||
|
robertsLando marked this conversation as resolved.
Outdated
|
||
| await mkdir(dirname(tempPath), { recursive: true }); | ||
| const content = | ||
| typeof record.body === 'string' | ||
| ? Buffer.from(record.body) | ||
| : record.body; | ||
| await writeFile(tempPath, content); | ||
| assets[snap] = tempPath; | ||
| } else { | ||
| // Unmodified file — point to source on disk | ||
| assets[snap] = record.file; | ||
| } | ||
| } | ||
|
|
||
| // Collect directory entries | ||
| if (record[STORE_LINKS]) { | ||
| manifest.directories[snap] = [ | ||
| ...new Set(record[STORE_LINKS] as string[]), | ||
| ]; | ||
| } | ||
|
|
||
| // Collect stat metadata | ||
| if (record[STORE_STAT]) { | ||
| const stat = record[STORE_STAT]; | ||
| manifest.stats[snap] = { | ||
| size: stat.size ?? 0, | ||
| isFile: Boolean(stat.isFileValue), | ||
| isDirectory: Boolean(stat.isDirectoryValue), | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| const manifestPath = join(tmpDir, '__pkg_manifest__.json'); | ||
| await writeFile(manifestPath, JSON.stringify(manifest)); | ||
|
|
||
| return { assets, manifestPath }; | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.