Repository navigation
fix(webpack): surface resolveId errors and emit Uint8Array assets byte-exactly - #632
Conversation
|
Caution Review failedThe pull request is closed. No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Preserve emitted asset bytes src/webpack/context.ts, test/unit-tests/webpack/context.test.ts |
getSource passes the Uint8Array itself to Buffer.from. A test checks that emitted asset bytes match the original Buffer view. |
Propagate resolveId errors src/webpack/index.ts, test/unit-tests/resolve-id/resolve-id.test.ts, plans/README.md |
resolveId processing now catches failures and passes an Error to the callback, converting non-Error values. Webpack and Rspack tests check that builds reject with the expected error. The execution-order table marks Plan 003 as DONE. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Suggested reviewers: antfu
Merge Risk: 
Minimal · previous review 36b4b
-
The reported asset-byte and resolver-error fixes have no identified merge-blocking issue; merge after normal checks.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passedFull details: Docstring Coverage
-
Explanation
Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 4 files. (1 skipped: 1 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Comment @coderabbitai help to get the list of available commands.
commit: |
Summary
Implements
plans/003-webpack-resolveid-errors-and-emitfile-bytes.md: two small, independent webpack adapter bugs.resolveIdnow fails the build instead of hanging it. The resolver tap is registered withtapAsyncbut was given anasyncfunction with notry/catch. Tapable ignores the returned promise, so when a hook threw, thecallbackwas never called: a one-shot build hung until the test timeout, and in watch mode it surfaced as an unhandled rejection. rspack usestapPromiseand already propagated the error; fix(webpack): forward async load hook errors to the loader callback #610 fixed the same gap in the webpack load loader but not in the resolver. The body after the two early-return guards is now wrapped intry/catch, and errors are normalised toErrorthe same way the loaders do.emitFilewith aUint8Arrayemits exactly those bytes.getSourcedidBuffer.from(fileSource.buffer), which wraps the entire backingArrayBufferand ignoresbyteOffset/byteLength. Node pools small Buffers, sothis.emitFile({ source: Buffer.from('tiny') })emitted the whole 8 KiB pool. NowBuffer.from(fileSource), matchingsrc/rspack/context.ts.Tests
resolve-id.test.ts: webpack and rspack builds reject with the hook's message whenresolveIdthrows. Onmain, the webpack case times out (10 s).webpack/context.test.ts: emitting a pooled 4-byte Buffer produces a 4-byte asset. Onmain, the emittedRawSource.buffer()is the pool.pnpm test→ 215 passed; lint/typecheck green. The diff insrc/webpack/index.tsis one indentation level;git diff -wshows the 8 real lines.Created with the help of an agent.
Summary by CodeRabbit