Skip to content

feat(sdk): make typescript/node follow best practices (e.g. ESM) - #3648

Merged
sxlijin merged 3 commits into
canaryfrom
sam/node-esm
Jun 3, 2026
Merged

sxlijin merged 3 commits into
canaryfrom
sam/node-esm

Conversation

@sxlijin

@sxlijin sxlijin commented Jun 2, 2026 •

Copy link
Copy Markdown
Contributor

Implement best practices for nodejs publish/sdkgen.

This note evaluates the current sam/node-esm implementation against the
best-practice sources listed in the prompt:

Short answer: yes on the core ESM package recommendations, and now mostly
yes on publish-shape validation too.

The branch now implements the high-value recommendations:

  • @boundaryml/baml-core-node is ESM-only.
  • It uses "type": "module".
  • It uses package exports, with no top-level main.
  • It puts the "types" condition first.
  • It publishes from dist/.
  • TypeScript compiles with module: "nodenext" and
    moduleResolution: "nodenext".
  • Handwritten TypeScript source and generated SDK source use .js relative
    import specifiers.
  • The napi wrapper is generated as ESM.
  • Protobuf output is generated/post-processed as ESM.
  • Tests use Vitest.
  • The sdk-test harness has an esm_output regression check.
  • The sdk-test harness now runs attw --pack against the bridge package.
  • The napi toolchain is updated to current versions:
    • @napi-rs/cli 3.7.0
    • napi 3.9.0
    • napi-derive 3.5.6
    • napi-build 2.3.2

Remaining gaps are smaller and more policy-dependent:

  • no engines.node field yet
  • no sideEffects field yet
  • no prepublishOnly pipeline yet
  • no publint check yet

Current Package Shape

The bridge package now has the package metadata shape recommended by the
ESM-first sources:

{
  "name": "@boundaryml/baml-core-node",
  "type": "module",
  "types": "./dist/index.d.ts",
  "exports": {
    ".": {
      "types": "./dist/index.d.ts",
      "import": "./dist/index.js"
    }
  },
  "files": ["dist"]
}

This is the important change from the earlier version of this note. We no
longer publish root-level index.js, native.js, proto.js, or root .d.ts
files. The package boundary points into dist/, and npm pack --dry-run
shows the tarball as package.json plus dist/**.

The package is exports-only. There is no top-level main, which matches
Sindre's pure-ESM recommendation to replace main with exports.

What We Now Conform To

1. ESM-only is a defensible choice for a new package

Anthony Fu's newer guidance is explicit: new packages should usually ship
ESM-only, especially when they target evergreen Node or modern toolchains.
Sindre Sorhus takes the same strong position for pure ESM packages.

sam/node-esm follows that. The package has only an import condition:

{
  "exports": {
    ".": {
      "types": "./dist/index.d.ts",
      "import": "./dist/index.js"
    }
  }
}

There is no require condition. That is intentional. CommonJS consumers must
use dynamic import(...):

async function main() {
  const baml = await import("@boundaryml/baml-core-node");
}

That is the breaking change we chose. It conforms to the ESM-only guidance,
not to the older dual-package compatibility strategy.

2. The emitted entrypoint is really ESM

The invalid pattern is:

  1. Set "type": "module".
  2. Keep emitting CommonJS.
  3. Node parses index.js as ESM.
  4. Runtime fails on exports, module.exports, or require.

The current implementation avoids that. bridge_nodejs/tsconfig.json uses:

{
  "compilerOptions": {
    "target": "es2022",
    "module": "nodenext",
    "moduleResolution": "nodenext",
    "rootDir": "./typescript_src",
    "outDir": "./dist"
  }
}

The generated dist/index.js has real ESM syntax:

import { BamlRuntime, Collector as NativeCollector } from "./native.js";
export { BamlRuntime, AbortController } from "./native.js";
export { BamlStream } from "./stream.js";

That conforms to Matt Pocock's package guide, Sindre's pure-ESM checklist, and
the TypeScript 4.7 Node ESM model.

3. Relative imports use .js

Matt Pocock's NodeNext import-extension article and Sindre's pure-ESM guide
both call out the same rule: in TypeScript source compiled under Node-style
ESM, relative imports should point at the emitted JavaScript file name:

export { BamlStream } from "./stream.js";

not:

export { BamlStream } from "./stream";
export { BamlStream } from "./stream.ts";

The branch follows this in two places:

  • handwritten bridge source under bridge_nodejs/typescript_src
  • generated SDK source from codegen_nodejs

The SDK tests enforce it. Each TypeScript fixture gets an esm_output test
that scans generated/baml_sdk/**/*.ts and fails if a relative from "./..."
import omits .js.

4. The exports map is intentionally import-only

Node's package docs define conditional exports as the mechanism for routing
different entrypoints for import and require. Anthony Fu's dual-package
article shows the dual form:

{
  "exports": {
    ".": {
      "types": "./dist/index.d.ts",
      "import": "./dist/index.mjs",
      "require": "./dist/index.cjs"
    }
  }
}

We intentionally do not do that. Our map is:

{
  "exports": {
    ".": {
      "types": "./dist/index.d.ts",
      "import": "./dist/index.js"
    }
  }
}

That is ESM-only, not dual ESM/CJS. TypeScript's "types" condition comes
first, matching the TypeScript 4.7 guidance that "types" should be first in
conditional exports.

One nuance: some checklists use "default" instead of or in addition to
"import". Our map has only "import". That is fine for Node ESM and
TypeScript's NodeNext resolver. A "default" condition could improve
unknown-runtime compatibility, but it is not required for this Node-targeted
package.

5. We now publish from dist/

Matt Pocock's package guide uses:

{
  "files": ["dist"],
  "main": "dist/index.js"
}

In our ESM-only package we use the same dist/ publishing idea, but through
exports instead of main:

{
  "types": "./dist/index.d.ts",
  "exports": {
    ".": {
      "types": "./dist/index.d.ts",
      "import": "./dist/index.js"
    }
  },
  "files": ["dist"]
}

This is now aligned with the package-layout recommendation. The build emits:

  • dist/index.js
  • dist/index.d.ts
  • dist/native.js
  • dist/native.d.ts
  • dist/baml_node.<platform>.node
  • dist/proto.js
  • dist/proto/baml_cffi.js
  • source maps and declaration maps

The napi wrapper is generated directly at dist/native.js. The platform
.node file is copied into dist/ so dist/native.js can load a local
./baml_node.<platform>.node file from the packed package.

6. Internal createRequire in dist/native.js is acceptable

Sindre's guide says to replace require() and module.exports with
import/export. That rule is about the module's public syntax and ordinary
dependency loading.

The napi-generated native wrapper is different. It is an ESM file:

import { createRequire } from "node:module";
const require = createRequire(import.meta.url);

It uses createRequire internally to load .node native addon files and
platform-specific native packages. That is a normal ESM escape hatch for Node
APIs and native addons. The important package boundary remains ESM:

  • no module.exports
  • named ESM exports
  • package entrypoint imports from dist/index.js

So this conforms in spirit. It is not the bad pattern of publishing a CJS file
as .js under "type": "module".

7. Protobuf output is ESM-compatible

The build uses:

pbjs -t static-module -w es6

and post-processes the generated import to:

import $protobuf from "protobufjs/minimal.js";

The generated protobuf runtime is copied to dist/proto/baml_cffi.js, which
matches the runtime import from dist/proto.js.

8. Tests use Vitest

Matt Pocock's package guide uses Vitest as the test runner. We now use Vitest
in both:

  • bridge_nodejs/package.json
  • generated sdk_test_typescript_node fixture packages

The bridge package tests import from ../dist/..., so they exercise the same
layout the package publishes.

The generated fixture package template has:

{
  "type": "module",
  "scripts": {
    "test": "vitest run"
  }
}

That is aligned with the new-package guidance and avoids Jest's historically
awkward ESM behavior.

9. Are The Types Wrong is now part of sdk_test_typescript_node

Mark Erikson's ESM modernization writeup is the strongest warning that package
exports, ESM/CJS conditions, and TypeScript declarations are easy to get
subtly wrong. Are The Types Wrong exists specifically to validate the packed
artifact shape across TypeScript module-resolution modes.

The bridge package now has:

{
  "scripts": {
    "attw": "attw --pack"
  },
  "devDependencies": {
    "@arethetypeswrong/cli": "0.18.3"
  }
}

The sdk_test_typescript_node scaffold emits a package-level test:

mod bridge_nodejs {
    #[test]
    fn attw() {
        run_workspace_cmd(
            "sdks/nodejs/bridge_nodejs",
            "pnpm exec attw --pack",
            ...
        );
    }
}

This is better than only testing repo-local source files. It checks the
package the way consumers install it: by packing the npm artifact and
analyzing its exports and declarations.

10. Napi is on current versions

The current Node and Rust napi toolchain versions are up to date for this
branch:

{
  "devDependencies": {
    "@napi-rs/cli": "3.7.0"
  }
}
napi = { version = "3.9.0", default-features = false }
napi-derive = "3.5.6"
napi-build = "2.3.2"

This is not directly an ESM best-practice item, but it matters here because
native ESM support depends on the napi-rs generated wrapper.

What Still Does Not Fully Conform

1. No engines.node field yet

Sindre recommends a modern Node floor, such as:

{
  "engines": {
    "node": ">=18"
  }
}

We do not currently declare an engine. Given the current toolchain:

  • @arethetypeswrong/cli requires Node >=20
  • the package uses native ESM
  • the generated SDK tests run on modern Node

I would probably add:

{
  "engines": {
    "node": ">=20"
  }
}

That is a policy decision, because it changes the package's declared runtime
support floor. If BAML wants to support Node 18 consumers, then attw being a
dev dependency with Node >=20 is not by itself a reason to make the runtime
package require Node 20. But the support floor should be explicit.

2. No sideEffects field yet

The distilled checklist includes:

{
  "sideEffects": false
}

I would not add that blindly here.

This package initializes native bindings, exposes runtime singletons, installs
exit hooks, and generated SDK entrypoints call runtime initialization at module
evaluation time. That does not automatically mean every export is
side-effectful, but it does mean sideEffects: false needs an audit.

For this package, omitting sideEffects is safer than claiming it is
tree-shake-pure.

3. No prepublishOnly pipeline yet

Matt Pocock's guide recommends a publish-time validation pipeline. We now have
the ingredients:

  • build scripts
  • Vitest
  • attw --pack
  • generated SDK consumer tests

But the package does not yet have:

{
  "scripts": {
    "prepublishOnly": "pnpm build:release && pnpm test && pnpm attw"
  }
}

The exact command should account for this monorepo's release flow and native
matrix build. Still, some release-time gate should run build, tests, and ATTW
against the packed artifact.

4. No publint check yet

ATTW focuses on TypeScript package entrypoint/type correctness. publint
checks a different slice of package-publishing problems. Given Mark Erikson's
warning about how easy ESM package metadata is to get subtly wrong, adding
publint would be a reasonable next hardening step.

5. We do not ship dual ESM/CJS

This is not a non-conformance with the new-package guidance. It is a
deliberate non-conformance with the older dual-package compatibility strategy.

Anthony Fu's dual-package article is useful if we decide CommonJS users still
matter enough to support:

{
  "exports": {
    ".": {
      "types": "./dist/index.d.ts",
      "import": "./dist/index.mjs",
      "require": "./dist/index.cjs"
    }
  }
}

But the newer guidance says new packages should generally move on to ESM-only.
Our stated product decision was to break CommonJS users and require dynamic
import(...). So the lack of a require condition is correct for this branch.

Suggested Follow-Ups

If we want @boundaryml/baml-core-node to be closer to the full 2026
best-practice checklist, I would do these in order:

  1. Decide and declare a Node engine floor, probably >=20 if that matches the
    support policy.
  2. Add a release-aware prepublishOnly or equivalent CI packaging gate.
  3. Add publint.
  4. Audit side effects before adding, or deliberately not adding,
    sideEffects: false.
  5. Consider adding a "default": "./dist/index.js" condition if we want
    better unknown-runtime compatibility beyond Node's "import" condition.

Verdict

sam/node-esm now conforms to the core ESM and package-shape best practices:

  • ESM-only package boundary
  • exports-only package metadata
  • types condition first
  • no top-level main
  • dist/ publishing layout
  • real ESM output
  • NodeNext TypeScript settings
  • .js relative imports
  • napi wrapper generated as ESM
  • protobuf generated/copied as ESM
  • Vitest-based tests
  • regression coverage against accidentally generating CJS
  • ATTW packed-artifact validation in sdk_test_typescript_node

The remaining work is release-policy hardening, not the ESM conversion itself:

  • declare engines.node
  • decide on sideEffects
  • add a publish/CI gate
  • optionally add publint

Summary by CodeRabbit

  • New Features

    • Switched test framework to Vitest for improved test performance and modern JavaScript support.
  • Refactor

    • Migrated Node.js SDK from CommonJS to ES modules (ESM).
    • Updated TypeScript compiler to target ES2022 with NodeNext module resolution.
    • Reorganized build output to dist directory for cleaner distribution.
    • Updated all module imports to explicit .js file extensions for ESM compatibility.

@vercel

vercel Bot commented Jun 2, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
beps Ready Ready Preview, Comment Jun 3, 2026 1:50am
new-baml-website Error Error Jun 3, 2026 1:50am
promptfiddle Ready Ready Preview, Comment Jun 3, 2026 1:50am
promptfiddle2 Ready Ready Preview, Comment Jun 3, 2026 1:50am

Request Review

@vercel
vercel Bot temporarily deployed to Preview – beps June 2, 2026 23:30 Inactive
@coderabbitai

coderabbitai Bot commented Jun 2, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This pull request migrates the Node.js SDK from CommonJS+Jest to ESM+Vitest. The package now publishes from a dist/ directory with ESM output, TypeScript targets ES2022 with NodeNext modules, build scripts handle protobuf and native addon copying, the bridge runtime converts to ES module syntax with explicit .js imports, SDK code generation now emits explicit index.js specifiers and namespace-based typemap resolvers, harness infrastructure validates ESM output, and all fixture tests update to Vitest with ESM import paths.

Changes

Node.js SDK ESM + Vitest migration

Layer / File(s) Summary
Package manifest, build scripts, and compiler config
baml_language/Cargo.toml, baml_language/sdks/nodejs/bridge_nodejs/package.json, baml_language/sdks/nodejs/bridge_nodejs/tsconfig.json, baml_language/sdks/nodejs/bridge_nodejs/vitest.config.ts, baml_language/sdks/nodejs/bridge_nodejs/.gitignore
Package.json switches to type: module with ESM exports from ./dist, removes main entry, tsconfig targets ES2022 and NodeNext modules, vitest.config.ts configures Node environment and globals, and build dependencies (napi, napi-derive, napi-build) are version-bumped.
Distribution build and artifact copying
baml_language/sdks/nodejs/bridge_nodejs/typescript_src/clean-dist.js, baml_language/sdks/nodejs/bridge_nodejs/typescript_src/copy-native-dts.js, baml_language/sdks/nodejs/bridge_nodejs/typescript_src/copy-proto.js, baml_language/sdks/nodejs/bridge_nodejs/typescript_src/tag-generated-files.js
ESM helper scripts clean, create, and populate the dist/ directory; protobuf outputs and native type definitions copy into dist/; tag-generated-files conditionally rewrites Long and protobufjs imports for ESM compatibility.
Bridge runtime and native binding ESM conversion
baml_language/sdks/nodejs/bridge_nodejs/index.js, baml_language/sdks/nodejs/bridge_nodejs/native.js, baml_language/sdks/nodejs/bridge_nodejs/typescript_src/*.ts
Native bridge and TypeScript sources switch to ES module imports/exports and explicit .js internal specifiers (./native.js, ./proto.js, etc.); classes become export declarations; functions use direct imports instead of module indirection.
Bridge test suite updates
baml_language/sdks/nodejs/bridge_nodejs/tests/*.test.ts, baml_language/sdks/nodejs/bridge_nodejs/tests/run_vitest.rs
Tests import from ../dist/index.js instead of ../index, use Vitest runner with Node environment, and update narrative comments from Jest to Vitest (e.g., forced teardown behavior).
SDK code generation for ESM and namespace imports
baml_language/sdks/nodejs/codegen_nodejs/src/emit/typemap_file.rs, baml_language/sdks/nodejs/codegen_nodejs/src/leaf.rs, baml_language/sdks/nodejs/codegen_nodejs/src/lib.rs, baml_language/sdks/nodejs/codegen_nodejs/src/routing.rs
Emitters now generate explicit ./index.js for cross-leaf imports and child re-exports; typemap resolvers use static namespace imports (import * as __leaf_N) with alias-based deferred thunks instead of require() lookups; unit tests updated to match new output.
Test harness templates for ESM and Vitest
baml_language/sdk_tests/harness_setup/src/templates/package.json, baml_language/sdk_tests/harness_setup/src/templates/tsconfig.json
Fixture scaffold templates set type: module, run vitest run for tests, target ES2022 and NodeNext, include node and vitest types, and remove Jest/ts-jest references.
Harness runner with ESM output validation
baml_language/sdk_tests/harness_runner/src/lib.rs
New helpers: run_workspace_cmd() runs commands from workspace root; assert_typescript_node_generated_esm() validates generated SDK has NodeNext config, no CommonJS markers, ESM syntax present, and relative imports end with .js.
Harness fixture scaffold generation for Vitest
baml_language/sdk_tests/harness_setup/src/typescript_node.rs
Fixture detection switches from has_jest_tests to has_vitest_tests; per-fixture scaffold emits Vitest runner test and new ESM output validation test; bridge_nodejs workspace module adds ATTW (Are the types right) check.
Fixture setup scripts and environment
baml_language/sdk_tests/crates/typescript_node/setup.sh, baml_language/sdk_tests/crates/typescript_node/setup.ps1, baml_language/sdk_tests/crates/typescript_node/src/lib.rs, baml_language/sdk_tests/README.md
Per-fixture pnpm install now uses --force to avoid stale packed file: dependencies after build changes; comments describe ESM runtime resolution and Vitest toolchain; README updated to list vitest instead of jest.
Fixture test files: Jest to Vitest and ESM imports
baml_language/sdk_tests/crates/typescript_node/*/customizable/*.test.ts
All ~30 test files switch from @jest/globals to vitest imports; all SDK imports change from extensionless paths (e.g., ./baml_sdk/docs) to explicit ./baml_sdk/docs/index.js entry points.

🎯 4 (Complex) | ⏱️ ~60 minutes

🐰 A bridge to the future hops with glee—
From CommonJS tangles to ESM so free,
With Vitest's swift stride and fixtures that gleam,
The Node SDK dances—no more Jest's old dream! 🌲✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: converting the Node.js/TypeScript SDK to follow ESM best practices, with ESM as a concrete example.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sam/node-esm

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5fc86535bf

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

"version": "0.0.0-beta",
"main": "index.js",
"types": "index.d.ts",
"type": "module",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Compile the entrypoint as ESM before marking it module

With this package set to "type": "module", Node treats the emitted index.js as ESM, but the unchanged tsconfig.json still emits CommonJS and the checked-in/generated entrypoint uses exports and require(...). Any consumer importing this package now aborts before loading the bridge (e.g. Node reports ReferenceError: exports is not defined in ES module scope for index.js), so the package entrypoint is unusable until the TS output is actually converted to ESM or the CommonJS files are renamed/exported as .cjs.

Useful? React with 👍 / 👎.

"ts-jest": "^29.1.0",
"typescript": "^5.4.5"
"typescript": "^5.4.5",
"vitest": "^3.2.3"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Update the lockfiles with the dependency swap

The switch from Jest to Vitest is not reflected in the lockfiles: the root importer and the package-local pnpm-lock.yaml still list jest, ts-jest, and @types/jest but no vitest for this package. I checked pnpm --dir baml_language/sdks/nodejs/bridge_nodejs install --frozen-lockfile --ignore-scripts, and pnpm fails with ERR_PNPM_OUTDATED_LOCKFILE; any CI or release path using frozen lockfile installs will fail before build/test starts.

Useful? React with 👍 / 👎.

"build:proto": "node node_modules/protobufjs-cli/bin/pbjs -t static-module -w commonjs -p ../../../crates/bridge_ctypes/types -o typescript_src/proto/baml_cffi.js ../../../crates/bridge_ctypes/types/baml_core/cffi/v1/baml_inbound.proto ../../../crates/bridge_ctypes/types/baml_core/cffi/v1/baml_outbound.proto && node node_modules/protobufjs-cli/bin/pbts -o typescript_src/proto/baml_cffi.d.ts typescript_src/proto/baml_cffi.js",
"build:napi-debug": "napi build --js ./native.js --dts ./native.d.ts --platform && cp native.d.ts typescript_src/native.d.ts",
"build:napi-release": "napi build --js ./native.js --dts ./native.d.ts --platform --release && cp native.d.ts typescript_src/native.d.ts",
"build:proto": "node node_modules/protobufjs-cli/bin/pbjs -t static-module -w commonjs -p ../../../crates/bridge_ctypes/types -o typescript_src/proto/baml_cffi.cjs ../../../crates/bridge_ctypes/types/baml_core/cffi/v1/baml_inbound.proto ../../../crates/bridge_ctypes/types/baml_core/cffi/v1/baml_outbound.proto",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep protobuf output aligned with its consumers

This now generates only typescript_src/proto/baml_cffi.cjs, but the rest of this package still imports/copies/tags baml_cffi as .js/.d.ts (typescript_src/proto.ts, copy-proto.js, and tag-generated-files.js). On a clean generation or after any proto change, the freshly generated .cjs is never the file loaded or copied, and no updated declaration file is produced, so the build either uses stale checked-in protobuf artifacts or fails if those artifacts are absent.

Useful? React with 👍 / 👎.

@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 June 2, 2026 23:35 Inactive

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@baml_language/sdks/nodejs/bridge_nodejs/package.json`:
- Around line 34-35: The package scripts build:napi-debug and build:napi-release
use the Unix-only cp command which breaks on Windows; replace the shell cp usage
with a cross-platform solution (e.g. a Node-based copy or a CLI like cpy/cpx) so
pnpm scripts run on all platforms. Update the two scripts to perform the same
file copy of native.d.ts into typescript_src/native.d.ts using a Node-compatible
approach and ensure the change preserves the existing flags (--js, --esm, --dts,
--platform, --release).
- Line 33: The build step changed the generated filename to baml_cffi.cjs but
the copy script (typescript_src/copy-proto.js) and runtime import
(require("./proto/baml_cffi")) still expect baml_cffi.js and typings, causing
build failures; fix by either (A) updating the package.json "build:proto" script
to emit the legacy artifacts (typescript_src/proto/baml_cffi.js plus a .d.ts via
pbts) so copy-proto.js and require("./proto/baml_cffi") continue to work, or (B)
keep the .cjs output and update copy-proto.js to copy baml_cffi.cjs and
remove/adjust .d.ts expectations and change runtime imports to
require("./proto/baml_cffi.cjs"); pick one option and apply consistently across
build:proto, typescript_src/copy-proto.js, and any runtime require sites.
- Around line 4-12: package.json declares ESM ("type": "module" and
exports.import -> "./index.js") but the generated runtime files (index.js,
native.js) and proto artifacts are CommonJS and the build scripts are
inconsistent/portable; fix by either switching package.json to CommonJS (remove
"type": "module" and add an exports.require entry pointing to "./index.js") OR
regenerate/emit ESM-compatible build outputs for index.js/native.js and adjust
exports.import accordingly; update the proto build pipeline so build:proto emits
typescript_src/proto/baml_cffi.js (or change typescript_src/copy-proto.js and
typescript_src/tag-generated-files.js to expect .cjs) to keep artifact names
consistent; and replace shell cp in build:napi-debug/release scripts with a
cross-platform file copy (use a Node script or an npm cross-copy utility) so
Windows builds work.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 2af594cf-6e30-42eb-97c3-bab92b94771f

📥 Commits

Reviewing files that changed from the base of the PR and between aedf222 and 5fc8653.

📒 Files selected for processing (1)
  • baml_language/sdks/nodejs/bridge_nodejs/package.json

@github-actions

github-actions Bot commented Jun 2, 2026 •

Copy link
Copy Markdown

Binary size checks passed

✅ 7 passed

Artifact Platform File Gzip Gated on Baseline Delta Status
✅ baml-cli Linux 🔒 17.3 MB 7.4 MB file 24.1 MB -6.7 MB (-28.0%) OK
✅ packed-program Linux 🔒 12.7 MB 5.4 MB file 15.1 MB -2.4 MB (-16.1%) OK
✅ baml-cli macOS 🔒 13.2 MB 6.4 MB file 18.2 MB -5.0 MB (-27.3%) OK
✅ packed-program macOS 🔒 9.7 MB 4.7 MB file 11.5 MB -1.8 MB (-16.0%) OK
✅ baml-cli Windows 🔒 14.2 MB 6.5 MB file 19.6 MB -5.4 MB (-27.6%) OK
✅ packed-program Windows 🔒 10.2 MB 4.7 MB file 12.2 MB -2.1 MB (-16.8%) OK
✅ bridge_wasm WASM 11.6 MB 🔒 3.3 MB gzip 3.9 MB -585.6 KB (-15.1%) OK

🔒 = the size this artifact is GATED on (ceiling + delta). Binaries gate on file size (installed binary); WASM gates on gzip (download size). The other size is shown for information only.


Generated by cargo size-gate · workflow run

@vercel
vercel Bot temporarily deployed to Preview – promptfiddle June 2, 2026 23:56 Inactive
@vercel
vercel Bot temporarily deployed to Preview – beps June 2, 2026 23:57 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 June 3, 2026 00:03 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle June 3, 2026 00:09 Inactive
@vercel
vercel Bot temporarily deployed to Preview – new-baml-website June 3, 2026 00:10 Inactive
@vercel
vercel Bot temporarily deployed to Preview – beps June 3, 2026 00:10 Inactive

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
baml_language/sdk_tests/harness_setup/src/typescript_node.rs (1)

68-76: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix stale symlink rationale for preserveSymlinks in TSCONFIG_JSON docs
The comment above TSCONFIG_JSON (lines ~67-75) says customizable/*.test.ts are symlinked and that preserveSymlinks: true is load-bearing, but the TypeScript harness now copies the entire customizable/ overlay into generated/ via copy_customizable (uses fs::copy, lines ~186-193 and copy_customizable in harness_setup/src/lib.rs). Update the comment to match the current copy behavior (and clarify why preserveSymlinks is still set to true, if it is required for other symlinks).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@baml_language/sdk_tests/harness_setup/src/typescript_node.rs` around lines 68
- 76, Update the comment above TSCONFIG_JSON to remove the stale claim that
customizable/*.test.ts are symlinked and instead note that copy_customizable
(which uses fs::copy) now copies the entire customizable overlay into
generated/, so tests are not symlinked; also state whether preserveSymlinks:
true remains necessary for any other symlinked assets (or remove that
justification if not), and reference TSCONFIG_JSON and copy_customizable in the
comment so future readers can find the relevant behavior.
🧹 Nitpick comments (1)
baml_language/sdk_tests/harness_setup/src/templates/package.json (1)

1-17: 💤 Low value

Consider adding Node.js engine constraint.

The configuration uses "type": "module", ES2022, and nodenext module resolution, which require Node.js 16.0.0 or later. Adding an engines field would document this requirement and prevent runtime issues.

📦 Suggested engine constraint
   "devDependencies": {
     "`@types/node`": "^20.0.0",
     "typescript": "^5.4.5",
     "vitest": "^3.2.3"
+  },
+  "engines": {
+    "node": ">=16.0.0"
   }
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@baml_language/sdk_tests/harness_setup/src/templates/package.json` around
lines 1 - 17, Add a Node.js engine constraint to package.json to document and
enforce the minimum Node version required by "type": "module" and
ES2022/nodenext resolution; update the package manifest (the object containing
"name", "version", "type", "scripts", "dependencies", "devDependencies") to
include an "engines" field (e.g., "engines": { "node": ">=16.0.0" }) so package
managers and users are informed of the runtime requirement.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@baml_language/sdk_tests/crates/typescript_node/docstrings_etc/customizable/main.test.ts`:
- Around line 5-12: The test uses __dirname inside docsSource but the file is
ESM so __dirname is undefined; update docsSource to compute the directory from
import.meta.url (e.g. use fileURLToPath(import.meta.url) and path.dirname) and
replace join(__dirname, "baml_sdk", "docs", "index.ts") accordingly; also add
the necessary imports (fileURLToPath from "url" and dirname or dirname from
"path" alongside join) and ensure docsSource reads the resolved path.

In
`@baml_language/sdks/nodejs/bridge_nodejs/typescript_src/tag-generated-files.js`:
- Around line 29-30: The replacement that rewrites `import Long =
require("long");` to `import Long from "long";` in the branch that handles
filenames ending with `baml_cffi.d.ts` must be removed or guarded so the `.d.ts`
is left with the original `import Long = require("long");`; update the code in
tag-generated-files.js (the if (f.endsWith('baml_cffi.d.ts')) branch and the c =
c.replaceAll(...) call) to stop performing that rewrite so the generated
declaration keeps the `export =`-style import that consumers without
esModuleInterop/allowSyntheticDefaultImports require.

---

Outside diff comments:
In `@baml_language/sdk_tests/harness_setup/src/typescript_node.rs`:
- Around line 68-76: Update the comment above TSCONFIG_JSON to remove the stale
claim that customizable/*.test.ts are symlinked and instead note that
copy_customizable (which uses fs::copy) now copies the entire customizable
overlay into generated/, so tests are not symlinked; also state whether
preserveSymlinks: true remains necessary for any other symlinked assets (or
remove that justification if not), and reference TSCONFIG_JSON and
copy_customizable in the comment so future readers can find the relevant
behavior.

---

Nitpick comments:
In `@baml_language/sdk_tests/harness_setup/src/templates/package.json`:
- Around line 1-17: Add a Node.js engine constraint to package.json to document
and enforce the minimum Node version required by "type": "module" and
ES2022/nodenext resolution; update the package manifest (the object containing
"name", "version", "type", "scripts", "dependencies", "devDependencies") to
include an "engines" field (e.g., "engines": { "node": ">=16.0.0" }) so package
managers and users are informed of the runtime requirement.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e9c9766b-e61a-4b61-813a-8a0f76526dc7

📥 Commits

Reviewing files that changed from the base of the PR and between 5fc8653 and 37707a1.

⛔ Files ignored due to path filters (13)
  • baml_language/sdks/nodejs/bridge_nodejs/ctx_manager.d.ts.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/ctx_manager.js.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/define_function.js.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/errors.js.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/exit_hook.js.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/index.d.ts.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/index.js.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • baml_language/sdks/nodejs/bridge_nodejs/proto.js.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/stream.d.ts.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/stream.js.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/typemap.d.ts.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/typemap.js.map is excluded by !**/*.map
📒 Files selected for processing (74)
  • baml_language/sdk_tests/README.md
  • baml_language/sdk_tests/crates/typescript_node/docstrings_etc/customizable/main.test.ts
  • baml_language/sdk_tests/crates/typescript_node/function_calls/customizable/methods_on_classes.test.ts
  • baml_language/sdk_tests/crates/typescript_node/function_calls/customizable/stdlib_entrypoints.test.ts
  • baml_language/sdk_tests/crates/typescript_node/llm_functions/customizable/main.test.ts
  • baml_language/sdk_tests/crates/typescript_node/setup.sh
  • baml_language/sdk_tests/crates/typescript_node/src/lib.rs
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/main.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_aliases.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_class_refs.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_complex_models.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_enums.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_forward_refs.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_generics.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_handles.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_lists.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_literals.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_maps.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_media.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_optional.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_primitives.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_recursion.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_routing.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_streams.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_symbol_collisions.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_unions.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_void.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/test_generic.test.ts
  • baml_language/sdk_tests/harness_setup/src/templates/package.json
  • baml_language/sdk_tests/harness_setup/src/templates/tsconfig.json
  • baml_language/sdk_tests/harness_setup/src/typescript_node.rs
  • baml_language/sdks/nodejs/bridge_nodejs/ctx_manager.d.ts
  • baml_language/sdks/nodejs/bridge_nodejs/ctx_manager.js
  • baml_language/sdks/nodejs/bridge_nodejs/define_function.js
  • baml_language/sdks/nodejs/bridge_nodejs/errors.js
  • baml_language/sdks/nodejs/bridge_nodejs/exit_hook.js
  • baml_language/sdks/nodejs/bridge_nodejs/index.d.ts
  • baml_language/sdks/nodejs/bridge_nodejs/index.js
  • baml_language/sdks/nodejs/bridge_nodejs/native.js
  • baml_language/sdks/nodejs/bridge_nodejs/package.json
  • baml_language/sdks/nodejs/bridge_nodejs/proto.js
  • baml_language/sdks/nodejs/bridge_nodejs/proto/baml_cffi.d.ts
  • baml_language/sdks/nodejs/bridge_nodejs/proto/baml_cffi.js
  • baml_language/sdks/nodejs/bridge_nodejs/stream.d.ts
  • baml_language/sdks/nodejs/bridge_nodejs/stream.js
  • baml_language/sdks/nodejs/bridge_nodejs/tests/call_function.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/host_callable.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/run_vitest.rs
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_collector.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_decode_call_result.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_decode_handle.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_engine.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_media.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_stream.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_tracing.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_typemap.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tsconfig.json
  • baml_language/sdks/nodejs/bridge_nodejs/typemap.js
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/copy-proto.js
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/ctx_manager.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/define_function.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/exit_hook.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/index.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/proto.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/proto/baml_cffi.d.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/proto/baml_cffi.js
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/stream.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/tag-generated-files.js
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/typemap.ts
  • baml_language/sdks/nodejs/bridge_nodejs/vitest.config.ts
  • baml_language/sdks/nodejs/codegen_nodejs/src/emit/typemap_file.rs
  • baml_language/sdks/nodejs/codegen_nodejs/src/leaf.rs
  • baml_language/sdks/nodejs/codegen_nodejs/src/lib.rs
  • baml_language/sdks/nodejs/codegen_nodejs/src/routing.rs
✅ Files skipped from review due to trivial changes (22)
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_media.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/exit_hook.ts
  • baml_language/sdks/nodejs/bridge_nodejs/stream.d.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/test_generic.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_engine.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/ctx_manager.d.ts
  • baml_language/sdk_tests/crates/typescript_node/src/lib.rs
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_tracing.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/call_function.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/stream.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_collector.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/vitest.config.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/proto.ts
  • baml_language/sdk_tests/crates/typescript_node/setup.sh
  • baml_language/sdks/nodejs/codegen_nodejs/src/routing.rs
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/proto/baml_cffi.d.ts
  • baml_language/sdks/nodejs/bridge_nodejs/proto/baml_cffi.d.ts
  • baml_language/sdks/nodejs/bridge_nodejs/index.d.ts
  • baml_language/sdk_tests/README.md
  • baml_language/sdks/nodejs/bridge_nodejs/ctx_manager.js
  • baml_language/sdks/nodejs/bridge_nodejs/index.js
  • baml_language/sdks/nodejs/bridge_nodejs/proto.js

Comment on lines +5 to 12
import { describe, it, expect } from "vitest";
import { readFileSync } from "node:fs";
import { join } from "node:path";

import { Doc, Note, Priority, Sentiment } from "./baml_sdk/docs";
import { Doc, Note, Priority, Sentiment } from "./baml_sdk/docs/index.js";

const docsSource = () =>
readFileSync(join(__dirname, "baml_sdk", "docs", "index.ts"), "utf8").replace(/\r\n/g, "\n");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Test/module config =="
fd -a 'package.json|tsconfig.json|vitest.config.ts' baml_language/sdk_tests/crates/typescript_node baml_language/sdk_tests/harness_setup \
  | xargs -I{} sh -c 'echo "--- {} ---"; sed -n "1,200p" "{}"; echo'

echo "== __dirname usages in TypeScript Node SDK tests =="
rg -n --type=ts '\b__dirname\b' baml_language/sdk_tests/crates/typescript_node

Repository: BoundaryML/baml

Length of output: 1293


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Search for any __dirname polyfills/workarounds =="
rg -n --type=ts --type=js '\b__dirname\b' baml_language/sdk_tests/crates/typescript_node baml_language/sdk_tests/harness_setup

echo "== Check for vitest/ts-node/esm config that might define __dirname =="
fd -a 'vitest.config.ts|vitest.config.js|vitest.workspace.ts|tsconfig*.json|node*.json' baml_language/sdk_tests/harness_setup baml_language/sdk_tests/crates/typescript_node \
  | xargs -I{} sh -c 'echo "--- {} ---"; sed -n "1,200p" "{}"'

Repository: BoundaryML/baml

Length of output: 890


Fix ESM test by removing __dirname usage

baml_language/sdk_tests/crates/typescript_node/docstrings_etc/customizable/main.test.ts is executed as ESM (type: "module", module: "nodenext"), so __dirname is undefined in the test module scope and the test will fail before assertions run.

Suggested fix
 import { describe, it, expect } from "vitest";
 import { readFileSync } from "node:fs";
 import { join } from "node:path";
+import { fileURLToPath } from "node:url";
 
 import { Doc, Note, Priority, Sentiment } from "./baml_sdk/docs/index.js";
+
+const __dirname = fileURLToPath(new URL(".", import.meta.url));
 
 const docsSource = () =>
   readFileSync(join(__dirname, "baml_sdk", "docs", "index.ts"), "utf8").replace(/\r\n/g, "\n");
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { describe, it, expect } from "vitest";
import { readFileSync } from "node:fs";
import { join } from "node:path";
import { Doc, Note, Priority, Sentiment } from "./baml_sdk/docs";
import { Doc, Note, Priority, Sentiment } from "./baml_sdk/docs/index.js";
const docsSource = () =>
readFileSync(join(__dirname, "baml_sdk", "docs", "index.ts"), "utf8").replace(/\r\n/g, "\n");
import { describe, it, expect } from "vitest";
import { readFileSync } from "node:fs";
import { join } from "node:path";
import { fileURLToPath } from "node:url";
import { Doc, Note, Priority, Sentiment } from "./baml_sdk/docs/index.js";
const __dirname = fileURLToPath(new URL(".", import.meta.url));
const docsSource = () =>
readFileSync(join(__dirname, "baml_sdk", "docs", "index.ts"), "utf8").replace(/\r\n/g, "\n");
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@baml_language/sdk_tests/crates/typescript_node/docstrings_etc/customizable/main.test.ts`
around lines 5 - 12, The test uses __dirname inside docsSource but the file is
ESM so __dirname is undefined; update docsSource to compute the directory from
import.meta.url (e.g. use fileURLToPath(import.meta.url) and path.dirname) and
replace join(__dirname, "baml_sdk", "docs", "index.ts") accordingly; also add
the necessary imports (fileURLToPath from "url" and dirname or dirname from
"path" alongside join) and ensure docsSource reads the resolved path.

Comment on lines +29 to +30
if (f.endsWith('baml_cffi.d.ts')) {
c = c.replaceAll('import Long = require("long");', 'import Long from "long";');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

Does TypeScript allow import Long from "long"in a.d.tswhen thelongpackage usesexport = Long, without esModuleInteroporallowSyntheticDefaultImports? Please cite TypeScript and/or long package documentation.

💡 Result:

No, TypeScript does not allow import Long from "long" in a .d.ts file (or any TypeScript file) when the long package uses export = Long and the esModuleInterop and allowSyntheticDefaultImports flags are disabled [1][2]. When a module uses the export = syntax, it follows the CommonJS model, which TypeScript specifically requires to be imported using the import ... = require(...) syntax [3][4]. Using the standard import Long from "long" syntax to import an export = module is incompatible with TypeScript's module resolution and type-checking rules when those flags are disabled [1][5][6][2]. Specifically: 1. The export = syntax is a TypeScript-specific construct used to model traditional CommonJS module.exports [4][7]. 2. Without esModuleInterop or allowSyntheticDefaultImports, TypeScript does not permit treating a CommonJS/UMD module as an ES module for the purpose of default imports [5][6]. Attempting to do so will result in an error such as TS2497 (or similar, depending on the environment), indicating that the module can only be imported using require [1][2]. 3. To correctly import such a module, you must use: import Long = require("long"); [1][4]. This requirement is well-documented in TypeScript's module reference, which explains that export = is intended to be used with the corresponding import = require() syntax [4][7]. While esModuleInterop was introduced to relax these restrictions by creating synthetic default imports for CommonJS modules, disabling it reverts TypeScript to its strict interpretation of module compatibility [5][6].

Citations:


Don’t rewrite the long import in baml_cffi.d.ts

In baml_language/sdks/nodejs/bridge_nodejs/typescript_src/tag-generated-files.js, changing import Long = require("long"); to import Long from "long"; makes the published .d.ts rely on esModuleInterop/allowSyntheticDefaultImports. Since long uses export =, TypeScript requires import ... = require(...) for correct typing when those interop flags aren’t enabled, so this can break consumer type-checking.

Suggested fix
-  if (f.endsWith('baml_cffi.d.ts')) {
-    c = c.replaceAll('import Long = require("long");', 'import Long from "long";');
-  }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@baml_language/sdks/nodejs/bridge_nodejs/typescript_src/tag-generated-files.js`
around lines 29 - 30, The replacement that rewrites `import Long =
require("long");` to `import Long from "long";` in the branch that handles
filenames ending with `baml_cffi.d.ts` must be removed or guarded so the `.d.ts`
is left with the original `import Long = require("long");`; update the code in
tag-generated-files.js (the if (f.endsWith('baml_cffi.d.ts')) branch and the c =
c.replaceAll(...) call) to stop performing that rewrite so the generated
declaration keeps the `export =`-style import that consumers without
esModuleInterop/allowSyntheticDefaultImports require.

@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 June 3, 2026 00:15 Inactive

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
baml_language/sdk_tests/harness_runner/src/lib.rs (1)

168-197: ⚡ Quick win

Add unit tests for the new import-specifier parser.

import_from_specifier and the .js-suffix assertion are pure helper logic now sitting on the critical ESM verification path. A few module-local tests would lock down the accepted import/export shapes without depending on full fixture generation. Based on learnings, **/*.rs: Prefer writing Rust unit tests over integration tests where possible.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@baml_language/sdk_tests/harness_runner/src/lib.rs` around lines 168 - 197,
Add unit tests for the import specifier parsing and the `.js` suffix assertion
by creating module-local Rust unit tests that exercise import_from_specifier and
the logic that checks for `.js` suffix (the helpers used on the ESM verification
path). Write tests covering typical import/export forms (single- and
double-quoted specifiers, leading/trailing whitespace, no " from " cases,
non-string specifiers) and cases asserting `.js` suffix handling (with and
without `.js`, uppercase/lowercase, edge cases like empty specifier). Put tests
in the same file using #[cfg(test)] mod tests so they run as unit tests and
reference import_from_specifier and the suffix-check code directly to lock down
accepted shapes without requiring fixture generation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@baml_language/sdk_tests/harness_runner/src/lib.rs`:
- Around line 168-197: Add unit tests for the import specifier parsing and the
`.js` suffix assertion by creating module-local Rust unit tests that exercise
import_from_specifier and the logic that checks for `.js` suffix (the helpers
used on the ESM verification path). Write tests covering typical import/export
forms (single- and double-quoted specifiers, leading/trailing whitespace, no "
from " cases, non-string specifiers) and cases asserting `.js` suffix handling
(with and without `.js`, uppercase/lowercase, edge cases like empty specifier).
Put tests in the same file using #[cfg(test)] mod tests so they run as unit
tests and reference import_from_specifier and the suffix-check code directly to
lock down accepted shapes without requiring fixture generation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b08263cf-9db0-406b-8f09-4dd1d1fc68a6

📥 Commits

Reviewing files that changed from the base of the PR and between 37707a1 and c727fe0.

⛔ Files ignored due to path filters (13)
  • baml_language/sdks/nodejs/bridge_nodejs/ctx_manager.d.ts.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/ctx_manager.js.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/define_function.js.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/errors.js.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/exit_hook.js.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/index.d.ts.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/index.js.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • baml_language/sdks/nodejs/bridge_nodejs/proto.js.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/stream.d.ts.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/stream.js.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/typemap.d.ts.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/typemap.js.map is excluded by !**/*.map
📒 Files selected for processing (76)
  • baml_language/sdk_tests/README.md
  • baml_language/sdk_tests/crates/typescript_node/docstrings_etc/customizable/main.test.ts
  • baml_language/sdk_tests/crates/typescript_node/function_calls/customizable/methods_on_classes.test.ts
  • baml_language/sdk_tests/crates/typescript_node/function_calls/customizable/stdlib_entrypoints.test.ts
  • baml_language/sdk_tests/crates/typescript_node/llm_functions/customizable/main.test.ts
  • baml_language/sdk_tests/crates/typescript_node/setup.sh
  • baml_language/sdk_tests/crates/typescript_node/src/lib.rs
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/main.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_aliases.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_class_refs.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_complex_models.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_enums.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_forward_refs.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_generics.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_handles.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_lists.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_literals.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_maps.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_media.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_optional.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_primitives.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_recursion.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_routing.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_streams.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_symbol_collisions.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_unions.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_void.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/test_generic.test.ts
  • baml_language/sdk_tests/harness_runner/src/lib.rs
  • baml_language/sdk_tests/harness_setup/src/templates/package.json
  • baml_language/sdk_tests/harness_setup/src/templates/tsconfig.json
  • baml_language/sdk_tests/harness_setup/src/typescript_node.rs
  • baml_language/sdks/nodejs/bridge_nodejs/ctx_manager.d.ts
  • baml_language/sdks/nodejs/bridge_nodejs/ctx_manager.js
  • baml_language/sdks/nodejs/bridge_nodejs/define_function.js
  • baml_language/sdks/nodejs/bridge_nodejs/errors.js
  • baml_language/sdks/nodejs/bridge_nodejs/exit_hook.js
  • baml_language/sdks/nodejs/bridge_nodejs/index.d.ts
  • baml_language/sdks/nodejs/bridge_nodejs/index.js
  • baml_language/sdks/nodejs/bridge_nodejs/native.js
  • baml_language/sdks/nodejs/bridge_nodejs/package.json
  • baml_language/sdks/nodejs/bridge_nodejs/proto.js
  • baml_language/sdks/nodejs/bridge_nodejs/proto/baml_cffi.d.ts
  • baml_language/sdks/nodejs/bridge_nodejs/proto/baml_cffi.js
  • baml_language/sdks/nodejs/bridge_nodejs/stream.d.ts
  • baml_language/sdks/nodejs/bridge_nodejs/stream.js
  • baml_language/sdks/nodejs/bridge_nodejs/tests/call_function.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/host_callable.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/run_vitest.rs
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_collector.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_decode_call_result.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_decode_handle.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_engine.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_media.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_stream.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_tracing.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_typemap.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tsconfig.json
  • baml_language/sdks/nodejs/bridge_nodejs/typemap.js
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/copy-native-dts.js
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/copy-proto.js
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/ctx_manager.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/define_function.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/exit_hook.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/index.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/proto.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/proto/baml_cffi.d.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/proto/baml_cffi.js
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/stream.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/tag-generated-files.js
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/typemap.ts
  • baml_language/sdks/nodejs/bridge_nodejs/vitest.config.ts
  • baml_language/sdks/nodejs/codegen_nodejs/src/emit/typemap_file.rs
  • baml_language/sdks/nodejs/codegen_nodejs/src/leaf.rs
  • baml_language/sdks/nodejs/codegen_nodejs/src/lib.rs
  • baml_language/sdks/nodejs/codegen_nodejs/src/routing.rs
✅ Files skipped from review due to trivial changes (16)
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_collector.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_engine.test.ts
  • baml_language/sdk_tests/crates/typescript_node/src/lib.rs
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_handles.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/exit_hook.ts
  • baml_language/sdk_tests/README.md
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_tracing.test.ts
  • baml_language/sdk_tests/crates/typescript_node/setup.sh
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_complex_models.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/stream.d.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_decode_handle.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_media.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/proto.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_streams.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/ctx_manager.js
  • baml_language/sdks/nodejs/codegen_nodejs/src/lib.rs
🚧 Files skipped from review as they are similar to previous changes (40)
  • baml_language/sdks/nodejs/bridge_nodejs/ctx_manager.d.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_primitives.test.ts
  • baml_language/sdk_tests/crates/typescript_node/function_calls/customizable/methods_on_classes.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tsconfig.json
  • baml_language/sdks/nodejs/codegen_nodejs/src/routing.rs
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_generics.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/typemap.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/stream.ts
  • baml_language/sdk_tests/crates/typescript_node/llm_functions/customizable/main.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/test_generic.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/copy-proto.js
  • baml_language/sdk_tests/crates/typescript_node/docstrings_etc/customizable/main.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/ctx_manager.ts
  • baml_language/sdks/nodejs/bridge_nodejs/proto/baml_cffi.d.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/index.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/proto/baml_cffi.d.ts
  • baml_language/sdks/nodejs/bridge_nodejs/index.d.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/main.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_void.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_forward_refs.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_routing.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/tag-generated-files.js
  • baml_language/sdks/nodejs/bridge_nodejs/tests/host_callable.test.ts
  • baml_language/sdk_tests/harness_setup/src/templates/tsconfig.json
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_aliases.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_class_refs.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/vitest.config.ts
  • baml_language/sdk_tests/harness_setup/src/typescript_node.rs
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_maps.test.ts
  • baml_language/sdks/nodejs/codegen_nodejs/src/emit/typemap_file.rs
  • baml_language/sdks/nodejs/bridge_nodejs/native.js
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_typemap.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_literals.test.ts
  • baml_language/sdks/nodejs/codegen_nodejs/src/leaf.rs
  • baml_language/sdk_tests/harness_setup/src/templates/package.json
  • baml_language/sdks/nodejs/bridge_nodejs/tests/run_vitest.rs
  • baml_language/sdks/nodejs/bridge_nodejs/errors.js
  • baml_language/sdks/nodejs/bridge_nodejs/define_function.js
  • baml_language/sdks/nodejs/bridge_nodejs/index.js
  • baml_language/sdks/nodejs/bridge_nodejs/proto.js

@vercel
vercel Bot temporarily deployed to Preview – promptfiddle June 3, 2026 00:26 Inactive
@vercel
vercel Bot temporarily deployed to Preview – beps June 3, 2026 00:26 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 June 3, 2026 00:31 Inactive

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
baml_language/sdk_tests/crates/typescript_node/docstrings_etc/customizable/main.test.ts (1)

12-12: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

__dirname is undefined in ESM context.

This test runs as ESM (type: "module", module: "nodenext"), so __dirname is not available. The test will fail at runtime when docsSource() attempts to read the file.

🔧 Proposed fix
 import { describe, it, expect } from "vitest";
 import { readFileSync } from "node:fs";
 import { join } from "node:path";
+import { fileURLToPath } from "node:url";
 
 import { Doc, Note, Priority, Sentiment } from "./baml_sdk/docs/index.js";
+
+const __dirname = fileURLToPath(new URL(".", import.meta.url));
 
 const docsSource = () =>
   readFileSync(join(__dirname, "baml_sdk", "docs", "index.ts"), "utf8").replace(/\r\n/g, "\n");
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@baml_language/sdk_tests/crates/typescript_node/docstrings_etc/customizable/main.test.ts`
at line 12, The test uses __dirname (in the readFileSync call inside
docsSource() in main.test.ts) which is undefined in ESM; replace that usage by
deriving the directory from import.meta.url (e.g. use
fileURLToPath(import.meta.url) and path.dirname or new URL('.',
import.meta.url)) and update the readFileSync(join(...)) call to use that
computed directory; also add the necessary import (fileURLToPath from 'url' or
use new URL) at the top of the test so the file read works in ESM.
🧹 Nitpick comments (1)
baml_language/sdks/nodejs/bridge_nodejs/package.json (1)

47-47: Check vitest dependency (^3.2.3) for stability

  • [email protected] is published (released 2025-06-09) and the release notes list multiple bug fixes.
  • There are also reported issues across the broader 3.2.x line (e.g., CI “Channel closed”, promisify spying/mocking regressions, and hangs in certain workspace/bail/pool configurations). Keep an eye on your CI/test setup; upgrading to a newer Vitest major (v4.x) would reduce exposure.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@baml_language/sdks/nodejs/bridge_nodejs/package.json` at line 47,
package.json currently pins vitest as "vitest": "^3.2.3", which is in the 3.2.x
line with known CI/test instability; update package.json to either pin a stable
3.2.x patch (if you need minimal change) or upgrade to the supported major
(vitest v4.x) to avoid those regressions, then run the test suite and CI to
validate and address any breaking config changes (adjustments may be needed in
vitest config and any test mocks/spies). Ensure you update any vitest-related
scripts or config keys referenced in package.json and the repository (search for
"vitest" and the test scripts) and commit the package.json and lockfile changes
after verifying CI passes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In
`@baml_language/sdk_tests/crates/typescript_node/docstrings_etc/customizable/main.test.ts`:
- Line 12: The test uses __dirname (in the readFileSync call inside docsSource()
in main.test.ts) which is undefined in ESM; replace that usage by deriving the
directory from import.meta.url (e.g. use fileURLToPath(import.meta.url) and
path.dirname or new URL('.', import.meta.url)) and update the
readFileSync(join(...)) call to use that computed directory; also add the
necessary import (fileURLToPath from 'url' or use new URL) at the top of the
test so the file read works in ESM.

---

Nitpick comments:
In `@baml_language/sdks/nodejs/bridge_nodejs/package.json`:
- Line 47: package.json currently pins vitest as "vitest": "^3.2.3", which is in
the 3.2.x line with known CI/test instability; update package.json to either pin
a stable 3.2.x patch (if you need minimal change) or upgrade to the supported
major (vitest v4.x) to avoid those regressions, then run the test suite and CI
to validate and address any breaking config changes (adjustments may be needed
in vitest config and any test mocks/spies). Ensure you update any vitest-related
scripts or config keys referenced in package.json and the repository (search for
"vitest" and the test scripts) and commit the package.json and lockfile changes
after verifying CI passes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 25460fcf-4f17-4a68-a6f9-addc493d47da

📥 Commits

Reviewing files that changed from the base of the PR and between c727fe0 and af02c2c.

⛔ Files ignored due to path filters (13)
  • baml_language/sdks/nodejs/bridge_nodejs/ctx_manager.d.ts.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/ctx_manager.js.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/define_function.js.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/errors.js.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/exit_hook.js.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/index.d.ts.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/index.js.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • baml_language/sdks/nodejs/bridge_nodejs/proto.js.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/stream.d.ts.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/stream.js.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/typemap.d.ts.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/typemap.js.map is excluded by !**/*.map
📒 Files selected for processing (76)
  • baml_language/sdk_tests/README.md
  • baml_language/sdk_tests/crates/typescript_node/docstrings_etc/customizable/main.test.ts
  • baml_language/sdk_tests/crates/typescript_node/function_calls/customizable/methods_on_classes.test.ts
  • baml_language/sdk_tests/crates/typescript_node/function_calls/customizable/stdlib_entrypoints.test.ts
  • baml_language/sdk_tests/crates/typescript_node/llm_functions/customizable/main.test.ts
  • baml_language/sdk_tests/crates/typescript_node/setup.sh
  • baml_language/sdk_tests/crates/typescript_node/src/lib.rs
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/main.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_aliases.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_class_refs.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_complex_models.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_enums.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_forward_refs.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_generics.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_handles.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_lists.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_literals.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_maps.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_media.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_optional.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_primitives.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_recursion.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_routing.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_streams.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_symbol_collisions.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_unions.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_void.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/test_generic.test.ts
  • baml_language/sdk_tests/harness_runner/src/lib.rs
  • baml_language/sdk_tests/harness_setup/src/templates/package.json
  • baml_language/sdk_tests/harness_setup/src/templates/tsconfig.json
  • baml_language/sdk_tests/harness_setup/src/typescript_node.rs
  • baml_language/sdks/nodejs/bridge_nodejs/ctx_manager.d.ts
  • baml_language/sdks/nodejs/bridge_nodejs/ctx_manager.js
  • baml_language/sdks/nodejs/bridge_nodejs/define_function.js
  • baml_language/sdks/nodejs/bridge_nodejs/errors.js
  • baml_language/sdks/nodejs/bridge_nodejs/exit_hook.js
  • baml_language/sdks/nodejs/bridge_nodejs/index.d.ts
  • baml_language/sdks/nodejs/bridge_nodejs/index.js
  • baml_language/sdks/nodejs/bridge_nodejs/native.js
  • baml_language/sdks/nodejs/bridge_nodejs/package.json
  • baml_language/sdks/nodejs/bridge_nodejs/proto.js
  • baml_language/sdks/nodejs/bridge_nodejs/proto/baml_cffi.d.ts
  • baml_language/sdks/nodejs/bridge_nodejs/proto/baml_cffi.js
  • baml_language/sdks/nodejs/bridge_nodejs/stream.d.ts
  • baml_language/sdks/nodejs/bridge_nodejs/stream.js
  • baml_language/sdks/nodejs/bridge_nodejs/tests/call_function.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/host_callable.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/run_vitest.rs
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_collector.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_decode_call_result.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_decode_handle.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_engine.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_media.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_stream.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_tracing.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_typemap.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tsconfig.json
  • baml_language/sdks/nodejs/bridge_nodejs/typemap.js
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/copy-native-dts.js
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/copy-proto.js
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/ctx_manager.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/define_function.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/exit_hook.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/index.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/proto.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/proto/baml_cffi.d.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/proto/baml_cffi.js
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/stream.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/tag-generated-files.js
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/typemap.ts
  • baml_language/sdks/nodejs/bridge_nodejs/vitest.config.ts
  • baml_language/sdks/nodejs/codegen_nodejs/src/emit/typemap_file.rs
  • baml_language/sdks/nodejs/codegen_nodejs/src/leaf.rs
  • baml_language/sdks/nodejs/codegen_nodejs/src/lib.rs
  • baml_language/sdks/nodejs/codegen_nodejs/src/routing.rs
✅ Files skipped from review due to trivial changes (26)
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_engine.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_decode_call_result.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_collector.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/proto.ts
  • baml_language/sdks/nodejs/bridge_nodejs/ctx_manager.d.ts
  • baml_language/sdks/nodejs/bridge_nodejs/proto/baml_cffi.d.ts
  • baml_language/sdks/nodejs/bridge_nodejs/stream.d.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_handles.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/call_function.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/stream.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/proto/baml_cffi.d.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_symbol_collisions.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/ctx_manager.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_decode_handle.test.ts
  • baml_language/sdk_tests/crates/typescript_node/llm_functions/customizable/main.test.ts
  • baml_language/sdk_tests/crates/typescript_node/setup.sh
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_streams.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_unions.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_void.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/stream.js
  • baml_language/sdk_tests/README.md
  • baml_language/sdks/nodejs/bridge_nodejs/index.d.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_literals.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/ctx_manager.js
  • baml_language/sdk_tests/crates/typescript_node/src/lib.rs
  • baml_language/sdks/nodejs/bridge_nodejs/proto.js
🚧 Files skipped from review as they are similar to previous changes (38)
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/typemap.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/exit_hook.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/index.ts
  • baml_language/sdk_tests/crates/typescript_node/function_calls/customizable/methods_on_classes.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_lists.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/run_vitest.rs
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_complex_models.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_routing.test.ts
  • baml_language/sdk_tests/harness_setup/src/templates/package.json
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_tracing.test.ts
  • baml_language/sdk_tests/crates/typescript_node/function_calls/customizable/stdlib_entrypoints.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tsconfig.json
  • baml_language/sdks/nodejs/bridge_nodejs/vitest.config.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_media.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/host_callable.test.ts
  • baml_language/sdks/nodejs/codegen_nodejs/src/routing.rs
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/copy-proto.js
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_typemap.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_optional.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_generics.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_stream.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_class_refs.test.ts
  • baml_language/sdk_tests/harness_setup/src/templates/tsconfig.json
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_primitives.test.ts
  • baml_language/sdk_tests/harness_runner/src/lib.rs
  • baml_language/sdks/nodejs/codegen_nodejs/src/emit/typemap_file.rs
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_forward_refs.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_aliases.test.ts
  • baml_language/sdks/nodejs/codegen_nodejs/src/lib.rs
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_recursion.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/native.js
  • baml_language/sdks/nodejs/bridge_nodejs/define_function.js
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/main.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/index.js
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/tag-generated-files.js
  • baml_language/sdk_tests/harness_setup/src/typescript_node.rs
  • baml_language/sdks/nodejs/bridge_nodejs/exit_hook.js
  • baml_language/sdks/nodejs/codegen_nodejs/src/leaf.rs

@sxlijin sxlijin changed the title nodejs: start esm-only bridge package feat: generate ESM for nodejs sdk Jun 3, 2026
@sxlijin sxlijin changed the title feat: generate ESM for nodejs sdk feat: make nodejs follow best practices (e.g. ESM) Jun 3, 2026
@sxlijin sxlijin changed the title feat: make nodejs follow best practices (e.g. ESM) feat(sdk): make typescript/node follow best practices (e.g. ESM) Jun 3, 2026
@vercel
vercel Bot temporarily deployed to Preview – beps June 3, 2026 01:05 Inactive
@vercel
vercel Bot temporarily deployed to Preview – beps June 3, 2026 01:08 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 June 3, 2026 01:13 Inactive
coderabbitai[bot]
coderabbitai Bot previously requested changes Jun 3, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@baml_language/sdks/nodejs/bridge_nodejs/package.json`:
- Around line 38-39: The test script is not self-sufficient because many tests
import built artifacts from ../dist (e.g., tests/test_tracing.test.ts and
tests/test_decode_call_result.test.ts), so update the package.json "test" script
to run the build step before running Vitest (invoke the existing build:debug
script or equivalent) so pnpm test builds the project and then runs "vitest
run"; modify the "test" script entry accordingly to chain the build (ensuring it
fails fast on build errors) and keep the existing "attw" and other scripts
untouched.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 5be2d1f3-f251-4ca8-ad87-a7e4deca3ed9

📥 Commits

Reviewing files that changed from the base of the PR and between af02c2c and 46c3229.

⛔ Files ignored due to path filters (54)
  • baml_language/sdks/nodejs/bridge_nodejs/ctx_manager.d.ts.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/ctx_manager.js.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/define_function.d.ts.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/define_function.js.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/dist/ctx_manager.d.ts is excluded by !**/dist/**
  • baml_language/sdks/nodejs/bridge_nodejs/dist/ctx_manager.d.ts.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/dist/ctx_manager.js is excluded by !**/dist/**
  • baml_language/sdks/nodejs/bridge_nodejs/dist/ctx_manager.js.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/dist/define_function.d.ts is excluded by !**/dist/**
  • baml_language/sdks/nodejs/bridge_nodejs/dist/define_function.d.ts.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/dist/define_function.js is excluded by !**/dist/**
  • baml_language/sdks/nodejs/bridge_nodejs/dist/define_function.js.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/dist/errors.d.ts is excluded by !**/dist/**
  • baml_language/sdks/nodejs/bridge_nodejs/dist/errors.d.ts.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/dist/errors.js is excluded by !**/dist/**
  • baml_language/sdks/nodejs/bridge_nodejs/dist/errors.js.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/dist/exit_hook.d.ts is excluded by !**/dist/**
  • baml_language/sdks/nodejs/bridge_nodejs/dist/exit_hook.d.ts.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/dist/exit_hook.js is excluded by !**/dist/**
  • baml_language/sdks/nodejs/bridge_nodejs/dist/exit_hook.js.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/dist/index.d.ts is excluded by !**/dist/**
  • baml_language/sdks/nodejs/bridge_nodejs/dist/index.d.ts.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/dist/index.js is excluded by !**/dist/**
  • baml_language/sdks/nodejs/bridge_nodejs/dist/index.js.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/dist/native.d.ts is excluded by !**/dist/**
  • baml_language/sdks/nodejs/bridge_nodejs/dist/native.js is excluded by !**/dist/**
  • baml_language/sdks/nodejs/bridge_nodejs/dist/proto.d.ts is excluded by !**/dist/**
  • baml_language/sdks/nodejs/bridge_nodejs/dist/proto.d.ts.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/dist/proto.js is excluded by !**/dist/**
  • baml_language/sdks/nodejs/bridge_nodejs/dist/proto.js.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/dist/proto/baml_cffi.d.ts is excluded by !**/dist/**
  • baml_language/sdks/nodejs/bridge_nodejs/dist/proto/baml_cffi.js is excluded by !**/dist/**
  • baml_language/sdks/nodejs/bridge_nodejs/dist/stream.d.ts is excluded by !**/dist/**
  • baml_language/sdks/nodejs/bridge_nodejs/dist/stream.d.ts.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/dist/stream.js is excluded by !**/dist/**
  • baml_language/sdks/nodejs/bridge_nodejs/dist/stream.js.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/dist/typemap.d.ts is excluded by !**/dist/**
  • baml_language/sdks/nodejs/bridge_nodejs/dist/typemap.d.ts.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/dist/typemap.js is excluded by !**/dist/**
  • baml_language/sdks/nodejs/bridge_nodejs/dist/typemap.js.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/errors.d.ts.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/errors.js.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/exit_hook.d.ts.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/exit_hook.js.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/index.d.ts.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/index.js.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • baml_language/sdks/nodejs/bridge_nodejs/proto.d.ts.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/proto.js.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/stream.d.ts.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/stream.js.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/typemap.d.ts.map is excluded by !**/*.map
  • baml_language/sdks/nodejs/bridge_nodejs/typemap.js.map is excluded by !**/*.map
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (68)
  • baml_language/Cargo.toml
  • baml_language/sdk_tests/README.md
  • baml_language/sdk_tests/crates/typescript_node/docstrings_etc/customizable/main.test.ts
  • baml_language/sdk_tests/crates/typescript_node/function_calls/customizable/methods_on_classes.test.ts
  • baml_language/sdk_tests/crates/typescript_node/function_calls/customizable/stdlib_entrypoints.test.ts
  • baml_language/sdk_tests/crates/typescript_node/llm_functions/customizable/main.test.ts
  • baml_language/sdk_tests/crates/typescript_node/setup.ps1
  • baml_language/sdk_tests/crates/typescript_node/setup.sh
  • baml_language/sdk_tests/crates/typescript_node/src/lib.rs
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/main.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_aliases.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_class_refs.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_complex_models.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_enums.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_forward_refs.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_generics.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_handles.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_lists.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_literals.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_maps.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_media.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_optional.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_primitives.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_recursion.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_routing.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_streams.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_symbol_collisions.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_unions.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_void.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/test_generic.test.ts
  • baml_language/sdk_tests/harness_runner/src/lib.rs
  • baml_language/sdk_tests/harness_setup/src/templates/package.json
  • baml_language/sdk_tests/harness_setup/src/templates/tsconfig.json
  • baml_language/sdk_tests/harness_setup/src/typescript_node.rs
  • baml_language/sdks/nodejs/bridge_nodejs/.gitignore
  • baml_language/sdks/nodejs/bridge_nodejs/index.js
  • baml_language/sdks/nodejs/bridge_nodejs/native.js
  • baml_language/sdks/nodejs/bridge_nodejs/package.json
  • baml_language/sdks/nodejs/bridge_nodejs/tests/call_function.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/host_callable.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/run_vitest.rs
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_collector.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_decode_call_result.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_decode_handle.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_engine.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_media.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_stream.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_tracing.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_typemap.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tsconfig.json
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/clean-dist.js
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/copy-native-dts.js
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/copy-proto.js
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/ctx_manager.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/define_function.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/exit_hook.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/index.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/proto.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/proto/baml_cffi.d.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/proto/baml_cffi.js
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/stream.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/tag-generated-files.js
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/typemap.ts
  • baml_language/sdks/nodejs/bridge_nodejs/vitest.config.ts
  • baml_language/sdks/nodejs/codegen_nodejs/src/emit/typemap_file.rs
  • baml_language/sdks/nodejs/codegen_nodejs/src/leaf.rs
  • baml_language/sdks/nodejs/codegen_nodejs/src/lib.rs
  • baml_language/sdks/nodejs/codegen_nodejs/src/routing.rs
💤 Files with no reviewable changes (2)
  • baml_language/sdks/nodejs/bridge_nodejs/native.js
  • baml_language/sdks/nodejs/bridge_nodejs/index.js
✅ Files skipped from review due to trivial changes (16)
  • baml_language/sdks/nodejs/bridge_nodejs/.gitignore
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_handles.test.ts
  • baml_language/sdk_tests/crates/typescript_node/src/lib.rs
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_class_refs.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_decode_handle.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/call_function.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/stream.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_collector.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_decode_call_result.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/run_vitest.rs
  • baml_language/sdks/nodejs/codegen_nodejs/src/routing.rs
  • baml_language/sdk_tests/crates/typescript_node/docstrings_etc/customizable/main.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_typemap.test.ts
  • baml_language/sdks/nodejs/codegen_nodejs/src/lib.rs
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/proto.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/exit_hook.ts
🚧 Files skipped from review as they are similar to previous changes (35)
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_generics.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_stream.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_engine.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_maps.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_streams.test.ts
  • baml_language/sdk_tests/crates/typescript_node/function_calls/customizable/stdlib_entrypoints.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/host_callable.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_optional.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/proto/baml_cffi.d.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/main.test.ts
  • baml_language/sdk_tests/crates/typescript_node/llm_functions/customizable/main.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_primitives.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_unions.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/define_function.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_literals.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/tests/test_media.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_complex_models.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_recursion.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_forward_refs.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_symbol_collisions.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/vitest.config.ts
  • baml_language/sdk_tests/harness_setup/src/templates/tsconfig.json
  • baml_language/sdk_tests/README.md
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_aliases.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/copy-native-dts.js
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_media.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_enums.test.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/typemap.ts
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/tag-generated-files.js
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/ctx_manager.ts
  • baml_language/sdks/nodejs/codegen_nodejs/src/emit/typemap_file.rs
  • baml_language/sdk_tests/harness_setup/src/templates/package.json
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/roundtrip_lists.test.ts
  • baml_language/sdk_tests/crates/typescript_node/type_shapes/customizable/test_generic.test.ts
  • baml_language/sdks/nodejs/codegen_nodejs/src/leaf.rs

Comment on lines +38 to +39
"attw": "attw --pack",
"test": "vitest run"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Make pnpm test self-sufficient again.

The suites now import built artifacts from ../dist/... (for example, tests/test_tracing.test.ts Line 3 and tests/test_decode_call_result.test.ts Lines 8-9), but the package script only runs vitest. On a clean checkout, pnpm test will fail unless build:debug was run manually first; tests/run_vitest.rs currently hides that by building before it calls the script.

Suggested fix
+    "pretest": "pnpm build:debug",
-    "test": "vitest run"
+    "test": "vitest run"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@baml_language/sdks/nodejs/bridge_nodejs/package.json` around lines 38 - 39,
The test script is not self-sufficient because many tests import built artifacts
from ../dist (e.g., tests/test_tracing.test.ts and
tests/test_decode_call_result.test.ts), so update the package.json "test" script
to run the build step before running Vitest (invoke the existing build:debug
script or equivalent) so pnpm test builds the project and then runs "vitest
run"; modify the "test" script entry accordingly to chain the build (ensuring it
fails fast on build errors) and keep the existing "attw" and other scripts
untouched.

@vercel
vercel Bot temporarily deployed to Preview – promptfiddle June 3, 2026 01:26 Inactive
- Run cargo fmt --all -- --config imports_granularity=Crate --config group_imports=StdExternalCrate
- Add --profile esm-only flag to attw test to ignore CJS resolution failures
- Update package.json attw script to match

Co-authored-by: Sam Lijin <[email protected]>
@vercel
vercel Bot temporarily deployed to Preview – beps June 3, 2026 01:32 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 June 3, 2026 01:37 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle June 3, 2026 01:50 Inactive
@sxlijin
sxlijin dismissed coderabbitai[bot]’s stale review June 3, 2026 01:59

not about the pr purpose

@sxlijin
sxlijin added this pull request to the merge queue Jun 3, 2026
Merged via the queue into canary with commit 2b671bd Jun 3, 2026
48 of 49 checks passed
@sxlijin
sxlijin deleted the sam/node-esm branch June 3, 2026 02:05

This branch was previously deployed

4 inactive (1 outdated) deployments
Preview – promptfiddle — b7797bc5 Deployed Jun 3, 2026 by vercel[bot]
Preview – promptfiddle2 — b7797bc5 Deployed Jun 3, 2026 by vercel[bot]
Preview – beps — b7797bc5 Deployed Jun 3, 2026 by vercel[bot]
Preview – new-baml-website — c727fe0e Deployed Jun 3, 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