Repository navigation
feat(javascript): recover code-split bundles from multiple inputs - #1686
Conversation
recover_javascript_sources accepted a single path, and validateModuleSet bound every module's provenance to that one snapshot. A code-split app (runtime + chunks, or an Electron main/preload/renderer set) had to be recovered one file per call, and modules recovered alone could not resolve imports across chunks: cross-chunk require(id) references stayed as numeric ids with property reads. Add an optional additional_paths input. The listed files are concatenated, in order after path, into the single engine snapshot, so one Wakaru run sees every module and cross-chunk imports resolve. validateModuleSet's single-snapshot binding is unchanged. Module provenance is attributed back to the input file its first extraction range starts in, with byte ranges rebased to that file's own offsets; a module whose ranges cross an input boundary keeps the concatenated snapshot identity and offsets, recorded as an explicit limitation. Single-path behavior is byte-for-byte unchanged (one segment, offset 0). Fixes morluto#1605
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
TL;DR: On 5ddf876, every recovery call fails, even with one file. A small local fix makes it work, and then cross-chunk imports resolve on real code. But the files are joined with no newline, so one chunk can hide the next without any warning. ResultsI tested 5ddf876 (parent e5bc4e8) with a real Wakaru 1.14.0 (Apache-2.0). Main was 693ed33.
Why it fails. The new With my local fix (it keeps
I count import lines. The analyzer counts 6 edges on the fixture, and the issue counted 4 on an older main. The 562 left over are 32 ids. 15 are defined only in entry bundles I did not pass in. 17 are defined in two of the chunks I did pass in. In the cases I checked, Wakaru writes a second The newline problemCalendar chunks end with a The pinia chunk, then the subscription-picker chunk, gives 1 module. The picker alone gives 3. Those 3 vanish, and the status stays Not run
Thanks, JingHao-Leon, for the PR. Thanks, pionxzh, for the issue and the repro. Smaller findings
My local fix (6 lines)- source: { ...source, published_copy: publishedCopy },
+ source: {
+ path: source.path,
+ snapshot_path: source.snapshot_path,
+ sha256: source.sha256,
+ bytes: source.bytes,
+ published_copy: publishedCopy,
+ },This is in Test setup
Element Web was used for one of the six one-file inputs (its init chunk, which uses string ids). Commands# build each tree (Node 24): npm ci && npm run build && npm run test:prepare
export REA_WAKARU_COMMAND=/tmp/pr1686/wakaru/wakaru
export REA_JAVASCRIPT_FIXTURE_TOOLS=/tmp/pr1686/fixture-tools
node node_modules/vitest/vitest.mjs run src/javascript/recovery/RecoveryFiles.test.ts \
src/javascript/recovery/WakaruPublication.test.ts src/application/javascript/JavaScriptRecoveryService.test.ts
node node_modules/vitest/vitest.mjs run --project boundary --project process-boundary tests/boundary/javascript-recovery
npm run verify:javascript:recovery
# MCP call (stdio, node scripts/rea.mjs mcp), tool recover_javascript_sources:
# {"path": "<first>", "additional_paths": ["<second>", ...], "output_directory": "<absent dir>"}
node scripts/rea.mjs analyze-javascript-application <output>/modules --json🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
|
Thanks for taking on recovery across multiple JavaScript inputs, @JingHao-Leon, and welcome to REA. Runtime, shared and lazy chunks can now be recovered together and fed straight into application analysis. It's good to have this workflow in place. |
Related code-split scripts previously required separate recovery calls, leaving cross-chunk module IDs unresolved.
additional_pathsnow recovers up to 16 additional files with the primarypathin one native Wakaru invocation. The CLI exposes the same choice through repeatable--additional-pathoptions.Each input has a separate snapshot, digest and published copy. The manifest retains
sourcefor the primary file and addsadditional_sourcesfor the rest; module provenance binds to its producer-reported snapshot and retains that file's extraction/context byte ranges. Relative input layout is preserved, aggregate input is limited to 64 MiB before allocation, and every original file is independently rechecked before commit. Single-file recovery retains its existing result shape. This also fixes the strict-schema failure that broke recovery in CI.Validation:
npm run checkandnpm run docs:checkpass.Fixes #1605.