Skip to content

perf(ext/node): convert validators.mjs and dependencies to lazy-loaded scripts - #33821

Merged
bartlomieju merged 2 commits into
mainfrom
perf/lazy-load-node-foundation
May 4, 2026
Merged

bartlomieju merged 2 commits into
mainfrom
perf/lazy-load-node-foundation

Conversation

@bartlomieju

Copy link
Copy Markdown
Member

Summary

Converts the first batch of ext/node polyfill files from ESM to IIFE-wrapped lazy-loaded scripts (lazy_loaded_js):

  • internal/validators.mjs (89 consumers)
  • internal/error_codes.ts
  • internal/hide_stack_frames.ts
  • internal/util/types.ts
  • internal/crypto/_keys.ts
  • internal/crypto/constants.ts
  • internal_binding/types.ts

Updates ~100 consumer files to use core.loadExtScript() instead of ESM imports. Breaks the circular dependency between validators.mjs and util.mjs via deferred loading in validateEncoding().

This is the first step toward converting ext/node internals bottom-up by dependency order. validators.mjs is one of the most widely imported modules, so converting it (and its dependency chain) unblocks many future conversions.

Test plan

  • cargo check passes
  • CI passes (existing spec/unit/node_compat tests cover validators usage)

…d scripts

Converts the following ext/node polyfill files from ESM to IIFE-wrapped
lazy-loaded scripts (lazy_loaded_js):
- internal/validators.mjs
- internal/error_codes.ts
- internal/hide_stack_frames.ts
- internal/util/types.ts
- internal/crypto/_keys.ts
- internal/crypto/constants.ts
- internal_binding/types.ts

Updates ~100 consumer files to use core.loadExtScript() instead of ESM
imports. Breaks circular dependency between validators.mjs and util.mjs
via deferred loading in validateEncoding().
validators.mjs cannot core.loadExtScript() from util.mjs because
util.mjs is still in the esm list. Instead, load normalizeEncoding
from its actual source (normalize_encoding.ts) which is now also
converted to lazy_loaded_js.

Also removes redundant `const core = globalThis.Deno.core` in
x509.ts that shadowed the imported core binding.
@bartlomieju
bartlomieju merged commit ce3598e into main May 4, 2026
268 of 270 checks passed
@bartlomieju
bartlomieju deleted the perf/lazy-load-node-foundation branch May 4, 2026 13:01
littledivy pushed a commit to crowlKats/deno that referenced this pull request Jun 10, 2026
…d scripts (denoland#33821)

Converts the first batch of ext/node polyfill files from ESM to
IIFE-wrapped lazy-loaded scripts (`lazy_loaded_js`):

- `internal/validators.mjs` (89 consumers)
- `internal/error_codes.ts`
- `internal/hide_stack_frames.ts`
- `internal/util/types.ts`
- `internal/crypto/_keys.ts`
- `internal/crypto/constants.ts`
- `internal_binding/types.ts`

Updates ~100 consumer files to use `core.loadExtScript()` instead of ESM
imports. Breaks the circular dependency between `validators.mjs` and
`util.mjs` via deferred loading in `validateEncoding()`.

This is the first step toward converting ext/node internals bottom-up by
dependency order. `validators.mjs` is one of the most widely imported
modules, so converting it (and its dependency chain) unblocks many
future conversions.
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.

1 participant