Skip to content

Upgrade es-module-lexer to 3.x in instrument-bundler #1617

Closed

Description

@joshunrau

es-module-lexer is held at 2.3.2 in packages/instrument-bundler by the dependency update on the deps branch. The newest release eligible under the repo's 7-day minimumReleaseAge on 2026-10-04 was 3.0.2.

Why it was not upgraded

3.0 changes both the shape of parse results and how the lexer initialises. Running the instrument-bundler suite against 3.0.2 gave 15 failures across 4 files:

  • The default export returns new records. They are tagged unions without the s/e/ss/se/d/n/t fields, and ImportType is now a type-only export. So ImportType[t] at packages/instrument-bundler/src/parse.ts:294 throws at runtime.
  • parse.test.ts asserts the old values importType: 'Static' and 'Dynamic'.
  • init is now a function (3.0.2). await init; at parse.ts:27 becomes a no-op. That matters in the browser, where the playground bundles instruments on the main thread.

What is required

  • Port parse.ts to the new records, or import from es-module-lexer/minimal, which keeps the 2.x record shape.
  • Replace the ImportType[t] lookup with an explicit map, and call await init().
  • Update parse.test.ts and run the instrument-bundler suite.
  • Check bundling in the playground (the esbuild-wasm path) in a browser, and run testing/src/specs/playground.spec.ts.

Activity

  1. added
    Priority: Low
    Difficulty: Medium
    Chore
    Area: Instruments
    on Oct 5, 2026
  2. joshunrau commented on Oct 26, 2026

    @joshunrau
    CollaboratorAuthor

    Covered by #1660 (fb4f73f). That PR is open and conflicting, so this stays open until it merges.

    Merging #1660 as written will not close this

    The PR body puts one keyword in front of a list: Closes #1624, #1626, #1618, …, #1617, …. GitHub needs the keyword before each number (docs: "Use full syntax for each issue"), and gh pr view 1660 --json closingIssuesReferences returns only #1624. Merged as is, it leaves this issue and the 12 others in that list open. Change the line to Closes #1624, closes #1626, … before merging.

    The conflict is not in this commit

    fb4f73f is the only commit on the branch that touches parse.ts, parse.test.ts, or the bundler's package.json and AGENTS.md, and main has not changed any of them since the branch point (c7a6364). Against d86740e, the PR's one conflicting file is apps/outreach/src/plugins/starlight-plugin-typedoc/starlight.ts, from the typedoc commit (bb760ef). If #1660 stays stuck, fb4f73f also applies cleanly to d86740e by itself. Its new test does not need Vitest 5: lexerCalls is a plain array, not a mock, so clearMocks never resets it.

    Before merging

    • 3.0.3 (2026-10-05) and 3.0.4 (2026-10-15) are now past the 7-day minimumReleaseAge. types/lexer.d.ts is byte-identical in 3.0.2 and 3.0.4, so the port compiles against either. The release notes list TypeScript lexing fixes, an import-attribute parsing fix and release CI. Staying on the locked 3.0.2 is fine.
    • Recheck await init() after the Vite 8 rebase. fb4f73f's message says the playground's production bundle keeps it, but that commit comes before 2bda841, which moves the playground to Rolldown. The line is a standalone top-level statement in a file that "sideEffects": ["**/cli.ts"] marks side-effect free, the pattern packages/instrument-bundler/AGENTS.md:62-68 warns a bundler may delete. Nothing visibly fails if it goes. parse.test.ts checks the order only in Node, and playground.spec.ts runs against the playground dev server (testing/playwright.config.ts:61-66), which serves parse.ts as its own module. Build the playground on the rebased branch and check that the chunk containing the lexer still awaits init().

    Triage note written with Claude Code. Code references point at main @ d86740e.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: InstrumentsChoreDifficulty: MediumPriority: Low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions