-
Notifications
You must be signed in to change notification settings - Fork 331
migrate to esm only, minus vitest for now #2725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: canary
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
|
need to migrate to vitest or add .js extensions in our test files like we do in https://github.com/BoundaryML/baml/pull/2489/files |
|
🌿 Preview your docs: https://boundary-preview-c39c57da-84df-4456-8bce-dc380d7a1f74.docs.buildwithfern.com |
There was a problem hiding this comment.
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.
ℹ️ 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".
| #!/usr/bin/env node | ||
|
|
||
| if (require.main === module) { | ||
| if (!process.env.BAML_LOG) { | ||
| process.env.BAML_LOG = 'info' | ||
| } | ||
| import { invoke_runtime_cli } from './native.js' | ||
|
|
||
| const baml = require('./native') | ||
| baml.invoke_runtime_cli(process.argv.slice(1)) | ||
| if (!process.env.BAML_LOG) { | ||
| process.env.BAML_LOG = 'info' | ||
| } | ||
|
|
||
| invoke_runtime_cli(process.argv.slice(1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Execute CLI every time module is imported
The new ESM version of cli.js always calls invoke_runtime_cli(process.argv.slice(1)) at module load. Previously this logic lived under if (require.main === module) so it only ran when the file was invoked as a binary. Removing the guard means any consumer that imports @boundaryml/baml/cli.js for programmatic reuse or for bundling now immediately executes the CLI, which can spawn the native runtime and alter process state unexpectedly. Consider re‑introducing a main‑module check using import.meta.url to ensure the CLI runs only when invoked directly from the command line.
Useful? React with 👍 / 👎.
Note
Migrate the TypeScript client and generated SDKs to ESM, add .js import rewriting (incl. @boundaryml/baml/*), export watcher APIs, and update tests/configs accordingly.
package.jsontype=module); convert runtime files to ESM (native.js, index.js, logging.js, errors.js, async_context_vars.js, stream.js, browser.js, cli.js).Image/Audio/Video/Pdfimplementations and SSR warning proxies inbrowser.*.native.js; addBamlCtxManager,BamlStream, and typedBamlLogEventexports..jssuffixed imports for relative and@boundaryml/baml/*paths; extend regex and tests insrc/lib.rs.watchers,resetBamlEnvVars, and error types; add newwatchers.tsfiles.0.213.0.type_buildertemplate to ESM paths and exportTypeBuilder.Written by Cursor Bugbot for commit 414599d. This will update automatically on new commits. Configure here.