Skip to content

perf(ext): convert ext/process and ext/http JS sources to lazy-loaded scripts#33817

Merged
bartlomieju merged 1 commit into
mainfrom
perf/lazy-load-process-http
May 4, 2026
Merged

perf(ext): convert ext/process and ext/http JS sources to lazy-loaded scripts#33817
bartlomieju merged 1 commit into
mainfrom
perf/lazy-load-process-http

Conversation

@bartlomieju

Copy link
Copy Markdown
Member

Summary

  • 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 #33778, #33780, #33784, #33800, and #33801.

Test plan

  • cargo check passes
  • CI passes (existing spec/unit tests cover ext/process and ext/http functionality)

@fibibot fibibot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: ESM import { core, internals, primordials } from "ext:core/mod.js" → IIFE const { core, internals, primordials } = globalThis.__bootstrap. All export const/export function declarations 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 via core.loadExtScript().

Consumer updates (all the import sites I could trace):

  • runtime/js/90_deno_ns.js:17-19, 27: switched import * as to core.loadExtScript() for all four converted modules. ✓
  • runtime/js/99_main.js:53: registerDeclarativeServer named import → destructured from core.loadExtScript("ext:deno_http/00_serve.ts"). ✓
  • ext/node/polyfills/child_process.ts:51: kNeedsNpmProcessState named import → destructured from core.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: _ws named import from sibling 02_websocket.ts → also via core.loadExtScript(). ✓

import.meta.loginternals.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-file is 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 OffscreenCanvas in the original #33760 — when an ESM converts to a script, anything that did import * as ns and used ns.foo lookups 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_header and op_http_ws_create_from_stream_resource in 02_websocket.ts are now sourced from core.ops (the runtime ops object) instead of the static ext:core/ops ESM. 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.

@bartlomieju
bartlomieju merged commit bf42857 into main May 4, 2026
136 checks passed
@bartlomieju
bartlomieju deleted the perf/lazy-load-process-http branch May 4, 2026 08:53
bartlomieju added a commit that referenced this pull request May 4, 2026
…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.
littledivy pushed a commit to crowlKats/deno that referenced this pull request Jun 10, 2026
… 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.
littledivy pushed a commit to crowlKats/deno that referenced this pull request Jun 10, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants