feat(esm): Add vitest bin to core#351
Conversation
✅ Deploy Preview for cedarjs canceled.
|
There was a problem hiding this comment.
Greptile Summary
This PR adds vitest binary support to the CedarJS core package as part of ongoing ESM preparation work. The change introduces a new vitest binary wrapper at packages/core/src/bins/vitest.ts and updates the core package.json to expose it as an executable binary.
The implementation follows the established architectural pattern used by other binary wrappers in the codebase (like jest and eslint). The vitest wrapper uses Node.js ESM's createRequire to dynamically resolve and execute the vitest binary from the user's installed vitest package. When users install vitest in their Cedar projects, they'll be able to run yarn vitest from their project root, which will delegate to their locally installed vitest version.
This change integrates with Cedar's broader tooling ecosystem by maintaining consistency in how third-party development tools are exposed through the core package. It prepares the framework for future ESM app generation where vitest will be the default testing framework instead of Jest, providing better ESM compatibility.
Confidence score: 2/5
- This PR has potential runtime issues that could cause immediate failures in production
- Score reflects a critical dependency resolution problem where vitest is not listed as a dependency but the binary attempts to resolve it
- Pay close attention to the vitest binary implementation and consider adding proper dependency management
2 files reviewed, 1 comment
|
@greptileai review this again please |
There was a problem hiding this comment.
Greptile Summary
This review covers only the changes made since the last review (commit e2e852a), not the entire PR.
The developer has addressed the previous review feedback by implementing a defensive fallback mechanism for handling vitest's bin field. The updated code now uses bin['vitest'] || bin instead of just bin['vitest'], which handles both object-style bin definitions ({"vitest": "./dist/cli.mjs"}) and string-style bin definitions ("./dist/cli.mjs") that vitest actually uses.
This change adds vitest binary support to Cedar's core package, allowing users to run yarn vitest directly in their project root when vitest is installed. The implementation follows a similar pattern to other binary wrappers in Cedar's core package and includes comprehensive comments explaining the two supported package.json bin structures. This is part of Cedar's broader ESM preparation work where vitest will become the default test runner for ESM projects.
The fallback approach ensures compatibility with different vitest versions or potential future changes to vitest's package.json structure, making the code more robust than the original implementation that assumed only object-style bin definitions.
Confidence score: 5/5
- This change is safe to merge with minimal risk of runtime issues
- Score reflects the defensive programming approach that handles both known bin formats correctly
- No files require special attention as this is a straightforward binary wrapper implementation
1 file reviewed, no comments
With this PR, if a user installs vitest, they can run it with
yarn vitestin the root of their project.When we add support for generating ESM Cedar apps vitest will be installed by default
This PR is part of the ESM prep work started in #349