feat(esm): packages/vite api side vitest support (take 2)#363
Conversation
✅ Deploy Preview for cedarjs canceled.
|
There was a problem hiding this comment.
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 configurationautoImportsPlugin()for automatic test utility importscedarjsDirectoryNamedImportPlugin()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
| "./api": { | ||
| "types": "./dist/api/vite-plugin-cedar-vitest-api-preset.d.ts", | ||
| "default": "./dist/api/vite-plugin-cedar-vitest-api-preset.js" | ||
| }, |
There was a problem hiding this comment.
style: The new API export only provides a default export without import/require conditions like other exports. Consider adding import/require conditions for consistency.
Re-applying #359