chore(vitest): fix native config-loader compatibility warnings - #1338
Open
gabrielseco wants to merge 2 commits into
Open
gabrielseco wants to merge 2 commits into
gabrielseco wants to merge 2 commits into
Conversation
Vite's upcoming `configLoader: 'native'` mode loads config files through Node's real ESM resolver instead of bundling them first, which surfaced two issues in vitest.config.ts: - relative import of scripts/coverage-utils had no extension, which Node's ESM resolver doesn't infer - __dirname is a CJS global, unavailable under native ESM Add the .ts extension and swap to import.meta.dirname. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
|
Deploy preview for adp-cost-calculator ready!
Deployed with vercel-action |
Contributor
|
Deploy preview for remote-flows ready!
Deployed with vercel-action |
Contributor
📊 Coverage Report⚪ Coverage unchanged
Detailed BreakdownLines Coverage
Statements Coverage
Functions Coverage
Branches Coverage
✅ Coverage check passed |
Contributor
📦 Bundle Size Report
Size Limits
Largest Files (Top 5)
View All Files (74 total)
✅ Bundle size check passed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
configLoader: 'native'mode loadsvitest.config.tsthrough Node's real ESM resolver instead of bundling it first, and running the suite currently prints a compatibility warning about two things this config does that won't work once that becomes the default..tsextension to the relative import ofscripts/coverage-utils— Node's ESM resolver doesn't infer extensions the way the current bundled loader does.path.resolve(__dirname, './')withimport.meta.dirname—__dirnameis a CJS global that doesn't exist in a real ESM module.Changes
vitest.config.ts: import extension +__dirname→import.meta.dirname, drops the now-unusedpathimport.Test plan
npx vitest runno longer prints theconfigLoader: 'native'warning.npm run type-checkandnpm run lintpass with no new issues.🤖 Generated with Claude Code
Note
Low Risk
Changes are limited to Vitest config and dev-only test dependencies; production runtime is unaffected, with main risk being CI/local test behavior on older Node versions if engines are not met.
Overview
Prepares Vitest for Vite’s upcoming
configLoader: 'native'by makingvitest.config.tsvalid under Node’s real ESM resolver: the coverage thresholds import now includes a.tsextension, the@alias usesimport.meta.dirnameinstead ofpath/__dirname, and the unusedpathimport is removed.Dev test stack is bumped in lockstep with the jsdom upgrade:
jsdom30,@types/jsdom30,@testing-library/jest-dom7, and a patch on@testing-library/user-event, withpackage-lock.jsonrefreshed for the transitive dependency graph (including stricter Node engine ranges on jsdom/jest-dom-related packages).Reviewed by Cursor Bugbot for commit fe48732. Bugbot is set up for automated code reviews on this repo. Configure here.