Repository navigation
Conversation
The constructor rewrites `result.css` to append a generated source map annotation or to strip a stale one, but `toString()` returned the untouched input, so `String(result)` disagreed with `result.css`.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthrough
ChangesNoWorkResult stringification
Priority: ⬇️ Low Estimated code review effort: 1 (Trivial) | ~5 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The change aligns NoWorkResult stringification with its processed CSS output, with source-map cases covered by tests. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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. Comment |
|
Good idea. But I prefer to keep to 9.0 release soon since it could create some breaking changes. |
|
Understood, and 9.0 is the right place for it. Returning the processed CSS changes what a lazy result prints once map options are involved, so anyone relying on the current output would see a difference. The branch still merges cleanly on |
When
Processor#process()gets no plugins it returns aNoWorkResult. Itsconstructor runs the map generator and rewrites
this.result.css: it appends agenerated
sourceMappingURLannotation, or strips a stale one left in theinput.
toString()skipped all of that and returned the raw input string, soString(result)andresult.cssdisagreed whenever the constructor hadchanged anything.
lib/no-work-result.d.tsdeclaresNoWorkResult_ implements LazyResult<Root>,and
LazyResult#toString()is documented as "Alias for theLazyResult#cssproperty.
lazy + '' === lazy.css".LazyResult#toString()returnsthis.css;NoWorkResulthadcssandcontentreadingthis.result.csswhile
toString()read the untouchedthis._css.Reproduction:
With one plugin registered the same calls take the
LazyResultpath and bothvalues agree.
The fix makes
toString()returnthis.result.css, matchingcss,contentand
LazyResult#toString(). This is residue from #1909, which converged theNoWorkResultconstructor withLazyResultbut lefttoString()reading thepre-map string.
The three new tests sit next to the
no work result matches lazy result...tests that #1909 added; those compare
.css, these comparetoString(). Theycover the two branches of the constructor separately: a generated inline map, a
generated external map (which also sets
result.map), and a stale inline mapbeing stripped. The existing
stringifies csstest already asserted`${result}` === result.css, but only on input the constructor nevertouches, so it passed throughout.
Reverting the one-line change turns all three red; a patch that fixes only the
map-generating branch, only the annotation-stripping branch, or that trims the
result is caught too. Full
pnpm testis green, 704 tests (701 before), c8line coverage still at 100%.
Summary by CodeRabbit
Bug Fixes
Tests