Skip to content

feat(esm): packages/vite api side vitest support (take 2)#363

Merged
Tobbe merged 1 commit into
mainfrom
tobbe-esm-prep-5
Aug 10, 2025
Merged

feat(esm): packages/vite api side vitest support (take 2)#363
Tobbe merged 1 commit into
mainfrom
tobbe-esm-prep-5

Conversation

@Tobbe
Copy link
Copy Markdown
Member

@Tobbe Tobbe commented Aug 10, 2025

Re-applying #359

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

netlify Bot commented Aug 10, 2025

Deploy Preview for cedarjs canceled.

Name Link
🔨 Latest commit a2e884b
🔍 Latest deploy log https://app.netlify.com/projects/cedarjs/deploys/6897e8d4ed73f300087313de

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 introduces API-side Vitest support to the @cedarjs/vite package as part of the ongoing ESM migration effort. The changes add a new Vite plugin preset specifically designed for CedarJS API testing with Vitest.

The core addition is the cedarVitestPreset() function in vite-plugin-cedar-vitest-api-preset.ts, which bundles together four essential plugins needed for API testing:

  • cedarVitestApiConfigPlugin() for test environment configuration
  • autoImportsPlugin() for automatic test utility imports
  • cedarjsDirectoryNamedImportPlugin() for directory-based module resolution (following CedarJS conventions)
  • trackDbImportsPlugin() for database import tracking and test isolation

The preset is exposed through a new ./api export path in the package.json, making it easily consumable by CedarJS projects transitioning from Jest to Vitest for API testing. This follows the established pattern of specialized exports like ./client and ./build already present in the package.

The implementation integrates seamlessly with the existing CedarJS testing infrastructure by importing plugins from the @cedarjs/testing package and combining them with local Vite plugins. The plugin ordering is intentional, with configuration plugins loaded first, followed by import resolution plugins, and finally specialized tracking functionality.

Confidence score: 5/5

  • This PR is extremely safe to merge with minimal risk as it only adds new functionality without modifying existing code
  • Score reflects simple, well-structured changes that follow established patterns and integrate cleanly with existing infrastructure
  • No files require special attention as the changes are straightforward and properly structured

2 files reviewed, 1 comment

Edit Code Review Bot Settings | Greptile

Comment on lines +24 to +27
"./api": {
"types": "./dist/api/vite-plugin-cedar-vitest-api-preset.d.ts",
"default": "./dist/api/vite-plugin-cedar-vitest-api-preset.js"
},
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.

style: The new API export only provides a default export without import/require conditions like other exports. Consider adding import/require conditions for consistency.

@Tobbe Tobbe merged commit d2b0a41 into main Aug 10, 2025
50 of 52 checks passed
@Tobbe Tobbe deleted the tobbe-esm-prep-5 branch August 10, 2025 00:47
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