Skip to content

fix: parse with acorn and remap source maps in scripts/hardenNamespaces.ts - #5307

Merged
jxom merged 1 commit into
mainfrom
jxom/festive-dijkstra-lkawxx
Oct 26, 2026
Merged

jxom merged 1 commit into
mainfrom
jxom/festive-dijkstra-lkawxx

Conversation

@jxom

@jxom jxom commented Oct 26, 2026

Copy link
Copy Markdown
Member

Follow-up to #5306.

Types (latest) on main. scripts/hardenNamespaces.ts imported the TypeScript compiler API, which typescript@7 no longer ships (import ts from 'typescript' resolves to lib/version). As a result, check:types failed in Verify / Types (latest). The script now parses the emitted JavaScript with acorn.

Source maps (review comment). The script rewrote each .js file without updating its .js.map, so segments after the start of each rewritten statement pointed into the new Object.defineProperty text. The edits now go through magic-string, and @jridgewell/remapping combines the edit map with the tsc map. Only the text around the value changes, so the value and the ; keep their segments:

line  "    Object.defineProperty(getAllowance, "call", { …, value: call, writable: true });"
before  [4→89:18] [21→89:22] [28→103:3]   (21 and 28 point into the new text)
after   [4→89:18] [95→89:22] [118→103:3]

The emitted JavaScript is byte-identical to the output from #5306. The new devDependencies ([email protected], [email protected], @jridgewell/[email protected]) were already in the lockfile at these versions.

Validation

  • tsc -b scripts/tsconfig.json passes with [email protected] and with typescript@latest (7.0.2). With 7.0.2 the Fix viem imports under SES lockdown() #5306 script fails with the same errors as CI.
  • pnpm build hardens 119 members in _cjs and 119 in _esm, and pnpm test:env:ses passes.
  • I compared tsc's maps against the hardened maps for every rewritten file (21 ESM, 21 CJS).
    • On unchanged lines, every character resolves to the same original position (573,419 ESM and 351,889 CJS, 0 mismatches).
    • On the 119 rewritten statements, the statement start, the value, and the ; resolve to their original positions (0 failures). The Fix viem imports under SES lockdown() #5306 maps fail 119 of these checks.

Generated by Claude Code

…ces.ts`

`scripts/hardenNamespaces.ts` imported the TypeScript compiler API, which
`typescript@7` no longer ships, so `check:types` failed on the "Types
(latest)" job. The script now parses the emitted JavaScript with `acorn`.

The script also rewrote each `.js` file without its `.js.map`, so segments
after the start of each rewritten statement pointed into the new
`Object.defineProperty` text. The edits now go through `magic-string`, and
`@jridgewell/remapping` combines its map with the tsc map. The emitted
JavaScript does not change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BS98KhLjRx59DyEQFi6C7c
@changeset-bot

changeset-bot Bot commented Oct 26, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: d083dcc

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel

vercel Bot commented Oct 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
viem Building Building Preview Oct 26, 2026 9:28am UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T09:31:44.040890Z d083dcc PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@jxom
jxom merged commit 1d2a825 into main Oct 26, 2026
34 of 35 checks passed
@jxom
jxom deleted the jxom/festive-dijkstra-lkawxx branch October 26, 2026 09:28

This branch was successfully deployed

1 active deployment
Preview — d083dcc1 Deployed Oct 26, 2026 by vercel[bot]
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