From 57ab623ec98afc895ae344b61192793670f0cead Mon Sep 17 00:00:00 2001 From: dadajian Date: Tue, 5 May 2026 12:20:14 -0500 Subject: [PATCH] fix: use named import for @babel/generator to fix bundled codegen crash The rolldown bundler calls __toESM with isNodeMode=1 for default imports, which sets .default to the entire exports object rather than the actual generate function. Switching to the named export avoids this path and resolves the TypeError at runtime. Also updates the CLI CI job to run the built dist artifact instead of the TypeScript source directly, so this class of bundler regression is caught before release. Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/test.yml | 4 ++-- src/generate-content-with-exports.ts | 2 +- src/generate-content-with-imports.ts | 2 +- src/generate-contents-with-interface.ts | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ad533457..deb2e477 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -49,8 +49,8 @@ jobs: - name: Run cypress-codegen run: | - bun src/cli.ts --testingType component - bun src/cli.ts --testingType e2e + bun dist/cli.mjs --testingType component + bun dist/cli.mjs --testingType e2e - name: Check generated types match git run: | diff --git a/src/generate-content-with-exports.ts b/src/generate-content-with-exports.ts index 5c96d22f..44262aff 100644 --- a/src/generate-content-with-exports.ts +++ b/src/generate-content-with-exports.ts @@ -12,7 +12,7 @@ limitations under the License. */ import * as t from "@babel/types"; -import generate from "@babel/generator"; +import { generate } from "@babel/generator"; import { format, Options } from "prettier"; import { join, parse, relative } from "path"; diff --git a/src/generate-content-with-imports.ts b/src/generate-content-with-imports.ts index 22622fb7..7c70dd8d 100644 --- a/src/generate-content-with-imports.ts +++ b/src/generate-content-with-imports.ts @@ -13,7 +13,7 @@ limitations under the License. import { parse } from "@babel/parser"; import * as t from "@babel/types"; -import generate from "@babel/generator"; +import { generate } from "@babel/generator"; import { readFileSync } from "fs"; import { resolve } from "path"; import { format, Options } from "prettier"; diff --git a/src/generate-contents-with-interface.ts b/src/generate-contents-with-interface.ts index 33e90916..bba3c1c1 100644 --- a/src/generate-contents-with-interface.ts +++ b/src/generate-contents-with-interface.ts @@ -24,7 +24,7 @@ import type { VariableDeclaration, } from "@babel/types"; import * as t from "@babel/types"; -import generate from "@babel/generator"; +import { generate } from "@babel/generator"; import { readFileSync } from "fs"; import { resolve } from "path"; import { format, Options } from "prettier";