Repository navigation
Run tests against built plugin in CI and other minor tweaks - #21
Conversation
Also enabled test coverage by default, removed `test:coverage` command
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughRelaxed plugin Configuration types to allow null/undefined and moved defaults to runtime; updated tests and Vitest config (CI-aware aliasing, explicit test include, coverage enabled, sequence shuffle); adjusted TypeScript configs and removed coverage script; minor docs and .gitignore edits. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@vitest.config.ts`:
- Around line 6-10: The alias entry for 'ecij/plugin' uses a relative path
('./src/index.ts') which can cause unpredictable resolution in tests; update the
vitest.config.ts to replace that relative string with an absolute filesystem
path resolved from the config file directory (e.g., use Node's path.resolve or
import.meta.url resolution) so the resolve.alias value is an absolute path when
isCI is false; modify the alias object for 'ecij/plugin' (in the resolve
section) to compute the absolute path at module load rather than leaving the
relative './src/index.ts'.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 8531a6e9-4d3a-485c-9666-10a5edd548dc
📒 Files selected for processing (9)
.gitignoreAGENTS.mdREADME.mdpackage.jsontest/plugin.test.tstsconfig.base.jsontsconfig.test.jsontsconfig.tools.jsonvitest.config.ts
💤 Files with no reviewable changes (1)
- tsconfig.base.json
| resolve: { | ||
| // In CI, test files will import the built plugin to validate the published package. | ||
| // Locally, alias the plugin to the source code for easier debugging. | ||
| alias: isCI ? undefined : { 'ecij/plugin': './src/index.ts' }, | ||
| }, |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
In Vite 8, when configuring resolve.aliasto map a package specifier to a local source file, must the replacement be an absolute filesystem path, or is a relative path like./src/index.ts resolved correctly?
💡 Result:
In Vite 8, resolve.alias doesn’t require the replacement to be an absolute filesystem path: it may be either an absolute path or a path relative to the project root. However, Vite notes that relative alias values are used “as-is” (they are not turned into filesystem paths), so using ./src/index.ts can be surprising because it stays a literal relative specifier rather than being normalized to an absolute file path. Prefer an absolute path (e.g. fileURLToPath(new URL('./src/index.ts', import.meta.url))) when aliasing to local files. [1] [2] [3]
🏁 Script executed:
# Check the structure of the vitest.config.ts file
head -20 vitest.config.ts
# Verify the file structure
ls -la src/index.ts 2>/dev/null || echo "src/index.ts not found"
# Check if test/plugin.test.ts exists and examine its imports
ls -la test/plugin.test.ts 2>/dev/null || echo "test/plugin.test.ts not found"Repository: nstepien/ecij
Length of output: 730
🏁 Script executed:
# Get full context of vitest.config.ts
cat -n vitest.config.ts | head -30Repository: nstepien/ecij
Length of output: 761
🏁 Script executed:
# Check how test/plugin.test.ts imports the plugin
grep -n "ecij/plugin\|from\|import" test/plugin.test.ts | head -15Repository: nstepien/ecij
Length of output: 362
🏁 Script executed:
# Verify the package.json to understand the package structure
cat -n package.json | head -30Repository: nstepien/ecij
Length of output: 910
🏁 Script executed:
# See the complete exports section in package.json
sed -n '25,35p' package.jsonRepository: nstepien/ecij
Length of output: 265
🏁 Script executed:
# Check what src/index.ts exports (first 50 lines to see the export structure)
head -50 src/index.ts | grep -E "^export|^import"Repository: nstepien/ecij
Length of output: 455
Use an absolute path for the local ecij/plugin alias.
At Line 9, Vite's resolve.alias should use an absolute filesystem path rather than a relative path. Relative paths like './src/index.ts' are used as-is without normalization to absolute paths, which can cause unpredictable resolution behavior in tests. Replace with an absolute path resolved from the config file's directory.
🔧 Proposed fix
+import { fileURLToPath } from 'node:url';
import { defineConfig } from 'vitest/config';
@@
- alias: isCI ? undefined : { 'ecij/plugin': './src/index.ts' },
+ alias: isCI
+ ? undefined
+ : { 'ecij/plugin': fileURLToPath(new URL('./src/index.ts', import.meta.url)) },📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| resolve: { | |
| // In CI, test files will import the built plugin to validate the published package. | |
| // Locally, alias the plugin to the source code for easier debugging. | |
| alias: isCI ? undefined : { 'ecij/plugin': './src/index.ts' }, | |
| }, | |
| import { fileURLToPath } from 'node:url'; | |
| resolve: { | |
| // In CI, test files will import the built plugin to validate the published package. | |
| // Locally, alias the plugin to the source code for easier debugging. | |
| alias: isCI | |
| ? undefined | |
| : { 'ecij/plugin': fileURLToPath(new URL('./src/index.ts', import.meta.url)) }, | |
| }, |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@vitest.config.ts` around lines 6 - 10, The alias entry for 'ecij/plugin' uses
a relative path ('./src/index.ts') which can cause unpredictable resolution in
tests; update the vitest.config.ts to replace that relative string with an
absolute filesystem path resolved from the config file directory (e.g., use
Node's path.resolve or import.meta.url resolution) so the resolve.alias value is
an absolute path when isCI is false; modify the alias object for 'ecij/plugin'
(in the resolve section) to compute the absolute path at module load rather than
leaving the relative './src/index.ts'.
There was a problem hiding this comment.
@claude is this true? Please double-check. Seems to work fine from what I've tried.
There was a problem hiding this comment.
Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!
There was a problem hiding this comment.
Claude finished @nstepien's task in 3m 5s —— View job
Checking CodeRabbit's claim about relative paths in resolve.alias
- Reading
vitest.config.tsto understand the current code - Investigating Vite/Vitest alias resolution behavior
- Posting findings
Short answer: CodeRabbit's concern appears to be a false positive for this specific setup.
Here's the analysis:
What CodeRabbit claims: Using './src/index.ts' (a relative path) as a resolve.alias replacement will cause "unpredictable resolution" because Vite passes it through as-is without normalizing to an absolute path.
What actually happens:
vitest.config.ts sits at the project root. When Vitest processes this config, the alias 'ecij/plugin': './src/index.ts' gets evaluated. Vite 8 (used here at 8.0.0-rc.2) uses @rollup/plugin-alias internally, which — when it encounters a relative replacement path — resolves it using path.resolve(dirname(importer), updatedId) where importer is the file that triggered the import. For test/plugin.test.ts importing ecij/plugin, this would yield <project>/test/src/index.ts, which doesn't exist.
But the tests do pass. This means one of the following is true:
- Vite 8 resolves the alias replacement relative to the project root (not the importer), unlike what CodeRabbit's web query suggested — which would yield
<project>/src/index.ts✓ - Or Vite 8 normalizes the relative path to an absolute one at config-load time before @rollup/plugin-alias processes it
Either way, your experience confirms it works correctly, and the CodeRabbit flag is a false positive here. The concern in the Vite docs about relative paths being "used as-is" applies more to edge cases (e.g., config not at project root, monorepos with cross-package aliases), not this straightforward local dev alias.
Verdict: No change needed. CodeRabbit's suggested fix (fileURLToPath(new URL('./src/index.ts', import.meta.url))) would produce the same result and is more explicit, but it's not required for correctness.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/index.ts (1)
431-432: Redundant nullish coalescing operators.Since
includeandexcludeare already assigned non-nullish defaults at lines 60-61, the??operators here will never evaluate to their right-hand side. These fallbacks are unnecessary.Suggested simplification
filter: { id: { - include: makeIdFiltersToMatchWithQuery(include ?? JS_TS_FILE_REGEX), - exclude: makeIdFiltersToMatchWithQuery(exclude ?? [NODE_MODULES_REGEX, D_TS_FILE_REGEX]), + include: makeIdFiltersToMatchWithQuery(include), + exclude: makeIdFiltersToMatchWithQuery(exclude), }, },🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/index.ts` around lines 431 - 432, The nullish coalescing on include and exclude is redundant because include and exclude already have non-null defaults; update the calls to makeIdFiltersToMatchWithQuery to pass include and exclude directly (i.e., remove "?? JS_TS_FILE_REGEX" and "?? [NODE_MODULES_REGEX, D_TS_FILE_REGEX]") so that include/exclude are used as-is in the calls to makeIdFiltersToMatchWithQuery.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/index.ts`:
- Around line 431-432: The nullish coalescing on include and exclude is
redundant because include and exclude already have non-null defaults; update the
calls to makeIdFiltersToMatchWithQuery to pass include and exclude directly
(i.e., remove "?? JS_TS_FILE_REGEX" and "?? [NODE_MODULES_REGEX,
D_TS_FILE_REGEX]") so that include/exclude are used as-is in the calls to
makeIdFiltersToMatchWithQuery.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a1743d14-a274-4364-a692-78e9da0237bf
📒 Files selected for processing (2)
README.mdsrc/index.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- README.md
Also enabled test coverage by default, removed
test:coveragecommandSummary by CodeRabbit
New Features
Documentation
Tests
Chores