| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: f4e49890-8a26-4143-90de-7ee12361fc6d 📥 CommitsReviewing files that changed from the base of the PR and between 423e256 and 9014374. 📒 Files selected for processing (2)
📝 Walkthrough WalkthroughAdded a utility to unescape resource paths and applied it in webpack and rspack loaders so resource IDs are unescaped before normalization; added cross-bundler test fixtures to validate handling of paths containing #. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem🚥 Pre-merge checks | ✅ 4 | ❌ 1 ❌ Failed checks (1 warning)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches 🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. ❤️ ShareComment @coderabbitai help to get the list of available commands and usage tips. Tip CodeRabbit can generate a title for your PR based on the changes with custom instructions.Set the reviews.auto_title_instructions setting to generate a title for your PR based on the changes in the PR with custom instructions. |
Sorry, something went wrong.
npm i https://pkg.pr.new/unplugin@592 commit: 9014374 |
Sorry, something went wrong.
There was a problem hiding this comment.
test/fixtures/hash-path/unplugin.js (1)🤖 Prompt for all review comments with AI agentstest/fixtures/hash-path/__test__/build.test.ts (1)40-43: Optionally add explicit token-not-found guards for clearer test failures.
Right now overwrite(...) relies on implicit failure behavior when tokens are missing. A direct guard would make fixture failures more diagnosable.
♻️ Suggested small robustness tweakconst s = new MagicString(code) const index = code.indexOf('msg#hash') + if (index === -1) + throw new Error(`load expected token "msg#hash" in ${JSON.stringify(id)}`) s.overwrite(index, index + 'msg#hash'.length, 'msg -> through the load hook -> __unplugin__#hash') return s.toString() @@ const s = new MagicString(code) const index = code.indexOf('__unplugin__') + if (index === -1) + throw new Error(`transform expected token "__unplugin__" in ${JSON.stringify(id)}`) s.overwrite(index, index + '__unplugin__'.length, 'transform') return {Also applies to: 57-60
🤖 Prompt for AI AgentsVerify each finding against the current code and only fix it if needed. In `@test/fixtures/hash-path/unplugin.js` around lines 40 - 43, The test fixture silently assumes the token exists before calling s.overwrite; add explicit guards that check the result of code.indexOf('msg#hash') (and similarly the other occurrence around lines 57-60) and throw a clear error if indexOf returns -1 so failures show a descriptive message; locate the token search using code.indexOf('msg#hash') and the mutation via s.overwrite(...) (and the paired s.toString() return) and validate the index before calling s.overwrite to produce a meaningful test-failure message when the token is missing.10-38: Optional: collapse repeated bundler assertions into a table-driven loop.
Current tests are solid; this is just a maintainability cleanup to reduce duplication and ease future fixture additions.
♻️ Proposed refactor🤖 Prompt for AI Agentsdescribe('hash-path hooks', () => { - it('vite', async () => { - const content = await fs.readFile(r('vite/main.js.mjs'), 'utf-8') - expect(content).toContain(expected) - }) - - it('rollup', async () => { - const content = await fs.readFile(r('rollup/main.js'), 'utf-8') - expect(content).toContain(expected) - }) - - it('webpack', async () => { - const content = await fs.readFile(r('webpack/main.js'), 'utf-8') - expect(content).toContain(expected) - }) - - it('esbuild', async () => { - const content = await fs.readFile(r('esbuild/main.js'), 'utf-8') - expect(content).toContain(expected) - }) - - it('rspack', async () => { - const content = await fs.readFile(r('rspack/main.js'), 'utf-8') - expect(content).toContain(expected) - }) - - it('farm', async () => { - const content = await fs.readFile(r('farm/main.js'), 'utf-8') - expect(content).toContain(expected) - }) + const cases: Array<[string, string]> = [ + ['vite', 'vite/main.js.mjs'], + ['rollup', 'rollup/main.js'], + ['webpack', 'webpack/main.js'], + ['esbuild', 'esbuild/main.js'], + ['rspack', 'rspack/main.js'], + ['farm', 'farm/main.js'], + ] + + for (const [name, file] of cases) { + it(name, async () => { + const content = await fs.readFile(r(file), 'utf-8') + expect(content).toContain(expected) + }) + }Verify each finding against the current code and only fix it if needed. In `@test/fixtures/hash-path/__test__/build.test.ts` around lines 10 - 38, Tests repeat the same assertion for multiple bundlers; refactor by replacing the repeated it(...) blocks with a table-driven loop: create an array of bundler names (e.g., ['vite','rollup','webpack','esbuild','rspack','farm']), iterate over it and for each name call it(bundleName, async () => { const content = await fs.readFile(r(`${bundleName}/main.js${bundleName === 'vite' ? '.mjs' : ''}`), 'utf-8'); expect(content).toContain(expected); }); use the existing r helper, fs.readFile, and expected variable so behavior is unchanged but duplication is removed.
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@test/fixtures/hash-path/__test__/build.test.ts`:
- Around line 10-38: Tests repeat the same assertion for multiple bundlers;
refactor by replacing the repeated it(...) blocks with a table-driven loop:
create an array of bundler names (e.g.,
['vite','rollup','webpack','esbuild','rspack','farm']), iterate over it and for
each name call it(bundleName, async () => { const content = await
fs.readFile(r(`${bundleName}/main.js${bundleName === 'vite' ? '.mjs' : ''}`),
'utf-8'); expect(content).toContain(expected); }); use the existing r helper,
fs.readFile, and expected variable so behavior is unchanged but duplication is
removed.
In `@test/fixtures/hash-path/unplugin.js`:
- Around line 40-43: The test fixture silently assumes the token exists before
calling s.overwrite; add explicit guards that check the result of
code.indexOf('msg#hash') (and similarly the other occurrence around lines 57-60)
and throw a clear error if indexOf returns -1 so failures show a descriptive
message; locate the token search using code.indexOf('msg#hash') and the mutation
via s.overwrite(...) (and the paired s.toString() return) and validate the index
before calling s.overwrite to produce a meaningful test-failure message when the
token is missing.
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 4df8609d-b47d-49b1-b362-eb9c98c3ae02
📥 CommitsReviewing files that changed from the base of the PR and between 111a437 and 32b8256.
📒 Files selected for processing (17)
Sorry, something went wrong.
|
Tests are failing, would you also check them? Thanks |
Sorry, something went wrong.
|
I fixed one error caused by this PR, caused by added normalization. The other error is currently on main. Codex says "Bun does not currently invoke hooks for modules that are only reached through re-exports." and suggests updating some counts on Bun. I don't yet fully understand the issue, but if you'd like a commit to review for this (either in this PR or another), let me know. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Resolves #591 by unescaping paths before passing into load and transform.
I'm open to better / less redundant ways to test. I wanted to test that all hooks unescape (or never escape), on all platforms.
Summary by CodeRabbit
Bug Fixes
Tests