Skip to content

feat(esm): Add vitest bin to core#351

Merged
Tobbe merged 2 commits into
mainfrom
tobbe-esm-prep-3
Aug 9, 2025
Merged

feat(esm): Add vitest bin to core#351
Tobbe merged 2 commits into
mainfrom
tobbe-esm-prep-3

Conversation

@Tobbe
Copy link
Copy Markdown
Member

@Tobbe Tobbe commented Aug 9, 2025

With this PR, if a user installs vitest, they can run it with yarn vitest in 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

@Tobbe Tobbe added this to the next-release milestone Aug 9, 2025
@netlify
Copy link
Copy Markdown

netlify Bot commented Aug 9, 2025

Deploy Preview for cedarjs canceled.

Name Link
🔨 Latest commit 3480eab
🔍 Latest deploy log https://app.netlify.com/projects/cedarjs/deploys/68974c908d63fc00080e0431

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

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

Edit Code Review Bot Settings | Greptile

Comment thread packages/core/src/bins/vitest.ts Outdated
@Tobbe
Copy link
Copy Markdown
Member Author

Tobbe commented Aug 9, 2025

@greptileai review this again please

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

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

Edit Code Review Bot Settings | Greptile

@Tobbe Tobbe merged commit eb08c27 into main Aug 9, 2025
50 checks passed
@Tobbe Tobbe deleted the tobbe-esm-prep-3 branch August 9, 2025 13:43
Tobbe added a commit that referenced this pull request Aug 22, 2025
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.

1 participant