Skip to content

build: remove ts-node and load specs as native ESM (42-x-y) - #54196

Merged
MarshallOfSound merged 12 commits into
42-x-yfrom
claude/backport-42-x-y-ts-stack
Sep 22, 2026
Merged

MarshallOfSound merged 12 commits into
42-x-yfrom
claude/backport-42-x-y-ts-stack

Conversation

@MarshallOfSound

@MarshallOfSound MarshallOfSound commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

Backport of #54166
Backport of #54167
Backport of #52100
Backport of #52735
Backport of #54168
Backport of #54169
Backport of #50793
Backport of #54170
Backport of #54171
Backport of #54109

See those PRs for details. #54172 (TypeScript 7) is left out because this branch still bundles lib/ with webpack and ts-loader. #52100 and #52735 ride along because the pre-Sudowoodo release entry scripts and their two specs were the remaining ts-node users on this branch; release-assets.json is already here (#52733), so Sudowoodo does not read anything this removes. #50793 (ws 8 in spec/) rides along so the websocket specs can use the same named ESM imports as newer branches; the lockfile keeps a ws 7 entry for @datadog/datadog-ci. #54109 (the protocol.handle throughput de-flake, already on 43/44/45) rides along because this branch's older version of that test tripped its 3x limit on the first full CI run here.

Branch-specific bits: github-token.mts still uses got here, so its default import is unwrapped for Node's CommonJS interop; yarn 4.18 re-hashes the built-in resolve compat patch entries in the lockfile; the crash-reporter, protocol, service-workers and logging specs use randomUUID() instead of this branch's uuid 3, which has no named ESM exports; a few remote-control bodies in the crash-reporter and fuses specs name what they use now that the CommonJS shims are gone; the spec codemod and the type-import autofix were re-run against this branch's specs rather than cherry-picked line for line; the nan test lockfile in the yarn patch was regenerated for this branch's nan pin.

Notes: none


Generated by Claude Code

MarshallOfSound and others added 9 commits September 21, 2026 23:48
…54166)

The `electron` module that ES module code sees is produced by wrapping the
CommonJS one, so both should expose exactly the same names bound to
exactly the same objects. Nothing checked that until now; esm-spec only
verified that the imports do not throw.

A new fixture app loads `electron` (and the process-specific
`electron/main`, `/common`, `/renderer`, `/utility` aliases) through both
`import()` and `require()` in the main process, a utility process and a
non-sandboxed renderer preload, and reports any export that only one
side has, any export that is not the identical value on both sides, and
a default import that is not the `require()` exports object. esm-spec
asserts the report is empty for each process type.
* build: update yarn from 4.12.0 to 4.18.0

Bumps the vendored yarn release (and the DEPS hook, .yarnrc.yml,
script/yarn.js and packageManager references to it) to 4.18.0.
.yarn/releases/yarn-4.18.0.cjs is bin/yarn.js from @yarnpkg/[email protected]
unmodified. The lockfile only changes its metadata version.

Among other fixes, 4.18's built-in TypeScript compatibility patch knows
about the TypeScript 7 package layout; 4.12 fails the fetch step with
ENOENT on lib/_tsc.js when asked to install typescript@7.

* build: bump the nan test lockfile to yarn 4.18's metadata version

The nan spec runner installs nan's test dependencies with the vendored
yarn in immutable mode, and yarn 4.18 refuses the install because it
wants to rewrite the lockfile's metadata version from 8 to 10. Regenerate
the lockfile in the nan patch with 4.18 so the install is a no-op again.
…52735)

* build: remove release orchestration scripts superseded by Sudowoodo

Follow-up to #52100. Sudowoodo now reads the expected-asset manifest from
script/release/release-assets.json (#52730, electron/sudowoodo#459)
instead of parsing release.ts, which removes the last reason to keep the
dead orchestration code:

- release.ts: no entrypoints since #52100; only remaining consumer was
  Sudowoodo's manifest regex, now retired
- get-url-hash.ts: imported only by release.ts
- upload-node-checksums.py / upload-index-json.py: invoked only by
  release.ts's uploadNodeShasums/uploadIndexJson; Sudowoodo does both
  first-party (checksums-scratchpad merge, direct index.json blob upload)
- get-asset.ts: no importers anywhere

The CI upload subtree stays: upload.py, upload-symbols.py,
upload-node-headers.py, upload-to-github.ts, find-github-release.ts,
github-token.ts, types.ts are invoked by build CI during publish builds
and are unrelated to the Sudowoodo migration.

* build: drop upload.py's unused --publish-release flag

Parsed but never read, and no workflow passes it — a fossil of the
pre-Sudowoodo flow where CI could trigger the publish itself.
ts-node was used as a CLI for a handful of TypeScript scripts under
script/. Those now rely on the type stripping built into Node.js instead:

- script/gen-filenames, check-patch-diff, run-clang-tidy and the release
  helpers (find-github-release, upload-to-github, github-token, types)
  are renamed to .mts and invoked with `node`. They use
  import.meta.dirname and explicit .mts / .js specifiers, and
  tsconfig.script.json moves to nodenext with verbatimModuleSyntax so
  tsc checks them the way Node runs them.
- The documented minimum Node.js for building goes from 22.12 to 22.18,
  the first 22.x release with type stripping on by default.
- script/codesign/gen-trust.ts and its trust.xml template are deleted;
  nothing has invoked them since generate-identity.sh switched to a
  user-scoped keychain in #50058.
- oxfmt, oxlint, lint-staged and .gitattributes learn about .mts.

ts-node itself stays for now because the spec runner still loads specs
through its require hook.
The last user of ts-node was the spec runner, which registered it as a
require hook so spec/**/*.ts could be loaded inside Electron (the
utility-process net fixture did the same).

Both now register a small local hook, spec/ts-register.js, that
transpiles each .ts file on its own with the TypeScript compiler API
using tsconfig.spec.json and inlines a source map so stack traces still
point at the .ts lines. ts-node also type checked specs as it loaded
them; that check now runs once in the lint job via
`tsc -p tsconfig.spec.json` instead, so type errors in specs fail lint
rather than surfacing part-way through a test shard.

Drops ts-node 6.2.0 and its transitive arrify, buffer-from, diff@3,
make-error, [email protected], source-map-support and yn entries from
yarn.lock.
Updates `ws` from 7.5.10 to 8.21.0 and `@types/ws` from 7.4.7 to 8.18.1
in spec/, and moves the specs to ws 8's API.
…54170)

Turn on erasableSyntaxOnly and isolatedModules for the spec typecheck so
the specs only use TypeScript syntax that a plain type stripper can
remove (no enums, parameter properties, import = require or angle
bracket casts), and lint spec/ for type-only imports so they are
written as `import type` / inline `type` specifiers.

Also hoist a handful of inline require() calls in spec bodies up to the
existing top-level imports and use named imports from ws.
* test: mechanically rewrite spec imports and __dirname for native ESM

This is the automated half of loading spec/ as native ES modules and is
not expected to pass on its own; the hand-written half follows in the
next commit. A script (included in the pull request description) made
three changes to spec/*.ts and spec/lib/*.ts, then oxfmt was re-run:

* relative import specifiers gain their real file extension
* __dirname / __filename become import.meta.dirname / .filename
* files that still call require() from module code get a
  createRequire(import.meta.url) prelude

Code inside functions that are stringified and evaluated in another
process (remotely(), itremote(), template-interpolated functions and
similar) is left as it was.

* test: load specs as native ES modules with Node's type stripping

spec/package.json declares "type": "module", so the spec runner and every
spec file now load through Node's own ESM loader and built-in TypeScript
type stripping; the require.extensions transpile hook is gone. A new
spec/fixtures/package.json keeps fixtures in a CommonJS scope.

The hand-written changes on top of the mechanical rewrite:

* spec/index.js becomes an ES module and import()s its test dependencies
  after the app is ready, then uses mocha.loadFilesAsync().
* Functions that are stringified and sent to another process now arrive
  as written rather than as CommonJS transpiler output, so the
  remote-control and utility-process fixtures define the plain names
  those bodies use (chai, expect, once, setTimeout, ...) instead of the
  old `electron_1` style shims, and a few bodies require() what they use.
* The two specs that exercise lib/ sources require() them, since lib/ is
  not in a "type": "module" scope.
* spec-helpers resolves BrowserWindow lazily so it stays loadable from a
  utility process.
* tsconfig.spec.json allows .ts extension imports; spec/tsconfig.json
  points editors at it.
@socket-security

socket-security Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatednpm/​@​types/​ws@​7.4.7 ⏵ 8.18.1100 +110073 +180100
Addednpm/​ws@​8.21.09910010089100

View full report

claude and others added 3 commits September 22, 2026 00:12
uuid@3 on this branch is CommonJS without statically detectable named
exports, so `import { v4 }` and `import * as uuid` fail once the specs load
as ES modules. Use node:crypto's randomUUID() instead, matching the
crash-reporter and protocol specs.
This test body is stringified and run in a renderer, so it cannot reference
the spec module's childProcess import. Restore the inline require() that the
base branch and main use.
Follow up #54028 (1e4b7cb) and #53206.
Separate timing phases can skew the ratio under CI load.
Pair the paths in both orders and time inside the renderer.
Keep the 3x limit. Verify the path each fetch takes.

Assisted-By: GitHub Copilot
(cherry picked from commit 7642250)

Copy link
Copy Markdown
Member Author

linux-x64 / test / test (linux, 2) failed on 93df351 in protocol module handle is fast (expected 172 to be below 156, ~3.3x across all retries). Nothing in this PR touches the protocol path; 42-x-y still had the pre-#54109 shape of that test, which times the two paths in separate phases. I've cherry-picked #54109 (already on 43/44/45 via #54130 etc.) into this branch as 25ff173 so the shard measures paired ratios like the newer branches do.


Generated by Claude Code

@trop trop Bot mentioned this pull request Sep 22, 2026
5 of 6 tasks
@trop
trop Bot requested a review from ckerr September 22, 2026 00:37
@MarshallOfSound
MarshallOfSound merged commit f5a25fd into 42-x-y Sep 22, 2026
69 checks passed
@MarshallOfSound
MarshallOfSound deleted the claude/backport-42-x-y-ts-stack branch September 22, 2026 06:22
@release-clerk

release-clerk Bot commented Sep 22, 2026

Copy link
Copy Markdown

No Release Notes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants