Skip to content

Commit 4ccab1b

Browse files
NathanFlurryclaude
andcommitted
chore: update PRD and progress for US-025
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d823cd5 commit 4ccab1b

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

scripts/ralph/prd.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@
417417
"pnpm --filter secure-exec exec vitest run passes"
418418
],
419419
"priority": 25,
420-
"passes": false,
420+
"passes": true,
421421
"notes": "Cleanup story after US-023 and US-024. The regex hacks to remove/bypass: (1) transformDynamicImport in esm-utils.ts:22 — replaces import( with __dynamicImport( via regex, breaks minified code, (2) convertEsmToCjs in bridge-handlers.ts:968 — 100-line regex ESM→CJS converter, breaks on edge cases, (3) __dynamicImport shim in global-exposure.ts:337 and bridge-contract.ts:24 — no longer needed when V8 handles import() natively. The browser worker (packages/browser/src/worker.ts) may still need these hacks since it doesn't use the V8 sidecar — leave those paths intact but clearly mark them as browser-only fallbacks."
422422
},
423423
{

scripts/ralph/progress.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,3 +796,25 @@ Started: Sat Mar 21 02:49:43 AM PDT 2026
796796
- import_meta_callback uses MODULE_RESOLVE_STATE thread-local (same as module_resolve_callback) to look up module file paths
797797
- cargo test SIGSEGV is pre-existing from US-023 — caused by V8 teardown, not import_meta_callback
798798
---
799+
800+
## 2026-03-21 18:00 - US-025
801+
- Removed transformDynamicImport() from loadFileSync handler — V8 handles import() natively via dynamic_import_callback in both CJS and ESM modes
802+
- Added CJS-to-ESM wrapping in async _loadFile handler using wrapCJSForESMWithModulePath — ensures V8's module system can correctly import CJS files
803+
- Marked __dynamicImport, _dynamicImport, and transformDynamicImport as browser-only fallbacks with comments in:
804+
- packages/core/src/shared/esm-utils.ts
805+
- packages/core/src/shared/global-exposure.ts
806+
- packages/core/isolate-runtime/src/inject/setup-dynamic-import.ts
807+
- packages/nodejs/src/bridge-contract.ts
808+
- packages/nodejs/src/bridge-handlers.ts
809+
- Files changed:
810+
- packages/nodejs/src/bridge-handlers.ts (removed transformDynamicImport import/call, added wrapCJSForESMWithModulePath import, updated loadFileSync and loadFile handlers)
811+
- packages/core/src/shared/esm-utils.ts (browser-only comment on transformDynamicImport)
812+
- packages/core/src/shared/global-exposure.ts (browser-only comments on _dynamicImport, __dynamicImport)
813+
- packages/nodejs/src/bridge-contract.ts (browser-only comment on dynamicImport key)
814+
- packages/core/isolate-runtime/src/inject/setup-dynamic-import.ts (browser-only comment)
815+
- **Learnings for future iterations:**
816+
- V8's dynamic_import_callback works in BOTH CJS (execute_script) and ESM (execute_module) modes — no JS-side shim needed
817+
- When V8's module system loads a CJS file via import(), it must be wrapped as ESM (wrapCJSForESMWithModulePath) because V8 parses all module loads as ESM
818+
- The __dynamicImport global is still installed in V8 snapshots but never called — removing it would require a snapshot rebuild
819+
- convertEsmToCjs is still needed in loadFileSync for require() of ESM-only packages in CJS exec mode
820+
---

0 commit comments

Comments
 (0)