perf(ext): convert ext/process and ext/http JS sources to lazy-loaded scripts#33817
Conversation
fibibot
left a comment
There was a problem hiding this comment.
LGTM. Clean ESM-to-IIFE conversion for ext/process/40_process.js + ext/http/{00_serve.ts, 01_http.js, 02_websocket.ts}, mirroring the pattern already landed for ext/web (#33760), ext/cache/ext/canvas/ext/crypto (#9499507), and ext/telemetry/ext/cron (#5a970fa). CI fully green at this head: 99 success, 1 skip, 0 fail.
What I verified
Module conversions:
ext/process/40_process.js: ESMimport { core, internals, primordials } from "ext:core/mod.js"→ IIFEconst { core, internals, primordials } = globalThis.__bootstrap. Allexport const/export functiondeclarations stripped to local + returned in the IIFE result object. ✓ext/http/00_serve.ts,01_http.js,02_websocket.ts: same conversion pattern. ✓- The four exported Symbols (
kExtraStdio,kIpc,kNeedsNpmProcessState,kSerialization) are returned in the IIFE result so consumers can destructure them viacore.loadExtScript().
Consumer updates (all the import sites I could trace):
runtime/js/90_deno_ns.js:17-19, 27: switchedimport * astocore.loadExtScript()for all four converted modules. ✓runtime/js/99_main.js:53:registerDeclarativeServernamed import → destructured fromcore.loadExtScript("ext:deno_http/00_serve.ts"). ✓ext/node/polyfills/child_process.ts:51:kNeedsNpmProcessStatenamed import → destructured fromcore.loadExtScript("ext:deno_process/40_process.js"). ✓ext/node/polyfills/internal/child_process.ts:80:kNeedsNpmProcessState+nodeSpawnChild+nodeSpawnSyncChild→ same pattern. ✓ext/http/01_http.js:33:_wsnamed import from sibling02_websocket.ts→ also viacore.loadExtScript(). ✓
import.meta.log → internals.log (00_serve.ts:587, 612, 879, 894, 911, 928, 988, 1033): IIFE-wrapped scripts can't access import.meta, so the 8 logging call sites switch to internals.log. Verified the substitute exists at runtime/js/99_main.js:145 (internals.log = function internalLog(levelStr, ...args) { ... op_internal_log("ext:runtime", level, message); }) — equivalent to import.meta.log with a fixed source URL. ✓
Smaller observations (non-blocking)
// deno-fmt-ignore-fileis added to all four converted files. Matches the convention from #33760 and earlier — IIFE-wrapped scripts often have a slightly idiomatic indentation pattern that dprint would otherwise reformat.- The IIFE conversion is the right shape for the V8 module-namespace concern that bit
OffscreenCanvasin the original #33760 — when an ESM converts to a script, anything that didimport * as nsand usedns.foolookups breaks because there's no module namespace anymore. This PR converts both producers and all consumers atomically, so the namespace-lookup hazard doesn't apply here. op_http_websocket_accept_headerandop_http_ws_create_from_stream_resourcein02_websocket.tsare now sourced fromcore.ops(the runtime ops object) instead of the staticext:core/opsESM. Equivalent at runtime; just a different access pattern.- The diff doesn't touch the
panic-trace-relevant or--inspect-relevant paths, so the prior-session snapshot panic class (08_text_encoding.js was not passed as an extension module) doesn't apply here either.
…ripts (#33818) ## Summary - Convert `ext/kv/01_db.ts` from ESM to IIFE-wrapped lazy-loaded script (`lazy_loaded_js`) - Convert `ext/webgpu/00_init.js` from ESM to IIFE-wrapped lazy-loaded script (`lazy_loaded_js`) - Update all consumers (`runtime/js/90_deno_ns.js`, `runtime/js/98_global_scope_shared.js`, `runtime/js/98_global_scope_window.js`, `runtime/js/98_global_scope_worker.js`) to use `core.loadExtScript()` instead of ESM imports - Replace `import.meta.log` call with `internals.log` in `01_db.ts` Follows the same pattern established in #33778, #33780, #33784, #33800, #33801, and #33817.
… scripts (denoland#33817) - Convert `ext/process/40_process.js` from ESM to IIFE-wrapped lazy-loaded script (`lazy_loaded_js`) - Convert `ext/http/00_serve.ts`, `ext/http/01_http.js`, `ext/http/02_websocket.ts` from ESM to IIFE-wrapped lazy-loaded scripts - Update all consumers (`runtime/js/90_deno_ns.js`, `runtime/js/99_main.js`, `ext/node/polyfills/child_process.ts`, `ext/node/polyfills/internal/child_process.ts`) to use `core.loadExtScript()` instead of ESM imports - Replace `import.meta.log` calls with `internals.log` in `00_serve.ts` Follows the same pattern established in denoland#33778, denoland#33780, denoland#33784, denoland#33800, and denoland#33801.
…ripts (denoland#33818) ## Summary - Convert `ext/kv/01_db.ts` from ESM to IIFE-wrapped lazy-loaded script (`lazy_loaded_js`) - Convert `ext/webgpu/00_init.js` from ESM to IIFE-wrapped lazy-loaded script (`lazy_loaded_js`) - Update all consumers (`runtime/js/90_deno_ns.js`, `runtime/js/98_global_scope_shared.js`, `runtime/js/98_global_scope_window.js`, `runtime/js/98_global_scope_worker.js`) to use `core.loadExtScript()` instead of ESM imports - Replace `import.meta.log` call with `internals.log` in `01_db.ts` Follows the same pattern established in denoland#33778, denoland#33780, denoland#33784, denoland#33800, denoland#33801, and denoland#33817.
Summary
ext/process/40_process.jsfrom ESM to IIFE-wrapped lazy-loaded script (lazy_loaded_js)ext/http/00_serve.ts,ext/http/01_http.js,ext/http/02_websocket.tsfrom ESM to IIFE-wrapped lazy-loaded scriptsruntime/js/90_deno_ns.js,runtime/js/99_main.js,ext/node/polyfills/child_process.ts,ext/node/polyfills/internal/child_process.ts) to usecore.loadExtScript()instead of ESM importsimport.meta.logcalls withinternals.login00_serve.tsFollows the same pattern established in #33778, #33780, #33784, #33800, and #33801.
Test plan
cargo checkpasses