fix: improve oxc sourcemaps and cssnano options#2778
Conversation
|
📝 WalkthroughWalkthroughTwo minification/optimization packages are enhanced: cssnano now accepts settings to forward preset options during CSS minification, and oxc now returns source maps when available instead of always returning undefined. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @packages/oxc/src/index.ts:
- Around line 31-34: The returned source map is being double-encoded: change the
returned object so the map field uses the raw result.map instead of
JSON.stringify(result.map); replace the current ternary `map: result.map ?
JSON.stringify(result.map) : undefined` with a direct assignment `map:
result.map` (preserving undefined when absent) so the string produced by
oxc-minify is not double-JSON-encoded.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/cssnano/src/index.tspackages/oxc/src/index.ts
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx,js,jsx}: Use 4 spaces for indentation
Use double quotes for strings
Always include semicolons at end of statements
Use ES5 trailing commas in objects and arrays
Usenode:prefix for Node.js built-in imports (e.g.,node:child_process)
Use camelCase for function and variable names
Usetry/catchwithif (err instanceof Error)checks for error handling
UsePromise.allfor parallel operations where all must succeed, orPromise.allSettledwhen you need results regardless of individual failures
Limit concurrency to 5-10 for file operations and 2-4 for CPU-intensive compressions to avoid resource exhaustion
Use file operation utilities from@node-minify/utils:readFile,writeFile,getFilesizeInBytes,getContentFromFilesAsync,isValidFileAsync
Use deprecation warnings viawarnDeprecationfrom@node-minify/utilsfor deprecated packages
UseresolveCompressorandisBuiltInCompressorutilities from@node-minify/utilsfor dynamic compressor resolution
Files:
packages/cssnano/src/index.tspackages/oxc/src/index.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx}: Usetypekeyword for type-only imports in TypeScript
Include.tsfile extension in local imports (e.g.,./setup.ts)
Use PascalCase for type and interface names
Files:
packages/cssnano/src/index.tspackages/oxc/src/index.ts
packages/*/src/index.ts
📄 CodeRabbit inference engine (AGENTS.md)
Include copyright header
/*! node-minify ... MIT Licensed */in source files
Files:
packages/cssnano/src/index.tspackages/oxc/src/index.ts
packages/{esbuild,google-closure-compiler,oxc,swc,terser,uglify-js,clean-css,cssnano,csso,lightningcss,html-minifier,jsonminify,no-compress}/src/index.ts
📄 CodeRabbit inference engine (AGENTS.md)
Compressor functions must export an async function matching the
Compressortype that receives{ settings, content }and returns{ code, map? }
Files:
packages/cssnano/src/index.tspackages/oxc/src/index.ts
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
Repo: srod/node-minify PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-09T07:41:29.716Z
Learning: Applies to packages/{esbuild,google-closure-compiler,oxc,swc,terser,uglify-js,clean-css,cssnano,csso,lightningcss,html-minifier,jsonminify,no-compress}/src/index.ts : Compressor functions must export an async function matching the `Compressor` type that receives `{ settings, content }` and returns `{ code, map? }`
Learnt from: CR
Repo: srod/node-minify PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-09T07:41:29.716Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use `resolveCompressor` and `isBuiltInCompressor` utilities from `node-minify/utils` for dynamic compressor resolution
Learnt from: CR
Repo: srod/node-minify PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-09T07:41:29.716Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use deprecation warnings via `warnDeprecation` from `node-minify/utils` for deprecated packages
📚 Learning: 2026-01-09T07:41:29.716Z
Learnt from: CR
Repo: srod/node-minify PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-09T07:41:29.716Z
Learning: Applies to packages/{esbuild,google-closure-compiler,oxc,swc,terser,uglify-js,clean-css,cssnano,csso,lightningcss,html-minifier,jsonminify,no-compress}/src/index.ts : Compressor functions must export an async function matching the `Compressor` type that receives `{ settings, content }` and returns `{ code, map? }`
Applied to files:
packages/cssnano/src/index.tspackages/oxc/src/index.ts
📚 Learning: 2026-01-09T07:41:29.716Z
Learnt from: CR
Repo: srod/node-minify PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-09T07:41:29.716Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use `resolveCompressor` and `isBuiltInCompressor` utilities from `node-minify/utils` for dynamic compressor resolution
Applied to files:
packages/cssnano/src/index.ts
🧬 Code graph analysis (1)
packages/cssnano/src/index.ts (3)
packages/types/src/types.d.ts (2)
MinifierOptions(206-226)CompressorResult(45-70)packages/utils/src/ensureStringContent.ts (1)
ensureStringContent(15-30)packages/core/src/index.ts (1)
minify(21-27)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
- GitHub Check: cubic · AI code reviewer
- GitHub Check: Greptile Review
- GitHub Check: test (windows-latest, 22.x)
- GitHub Check: test (windows-latest, 20.x)
- GitHub Check: test (ubuntu-latest, 24.x)
- GitHub Check: test (ubuntu-latest, 20.x)
- GitHub Check: test (ubuntu-latest, 22.x)
- GitHub Check: test (windows-latest, 24.x)
🔇 Additional comments (1)
packages/cssnano/src/index.ts (1)
19-31: LGTM!The changes correctly forward
settings.optionsto the cssnano preset, enabling users to customize minification behavior. The implementation follows the expectedCompressortype signature and is consistent with other compressors in this monorepo. Based on learnings, the function properly receives{ settings, content }and returns{ code, map? }.
Greptile SummaryThis PR fixes two issues in the oxc and cssnano minifier packages. The oxc package now correctly returns source maps by stringifying Key Changes:
Both changes align with existing patterns in other compressor packages (terser, esbuild, clean-css) and maintain backward compatibility. Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Core as minify()
participant OXC as oxc compressor
participant CSSNANO as cssnano compressor
participant OXCLib as oxc-minify
participant PostCSS as postcss/cssnano
Note over User,PostCSS: OXC Source Map Flow
User->>Core: minify({ compressor: oxc, options: { sourceMap: true } })
Core->>OXC: oxc({ settings, content })
OXC->>OXCLib: minify("input.js", content, { sourcemap: true })
OXCLib-->>OXC: { code, map }
OXC->>OXC: JSON.stringify(result.map)
OXC-->>Core: { code, map: stringified }
Core-->>User: minified result with source map
Note over User,PostCSS: CSSNano Options Flow
User->>Core: minify({ compressor: cssnano, options: { preset: [...] } })
Core->>CSSNANO: cssnano({ settings, content })
CSSNANO->>CSSNANO: extract settings.options
CSSNANO->>PostCSS: postcss([minify(options)])
PostCSS-->>CSSNANO: { css }
CSSNANO-->>Core: { code: css }
Core-->>User: minified CSS
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2778 +/- ##
========================================
Coverage 99.58% 99.58%
========================================
Files 62 62
Lines 1199 1201 +2
Branches 367 369 +2
========================================
+ Hits 1194 1196 +2
Misses 5 5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
settings.optionsto the cssnano preset for better configuration support.Summary by cubic
Return source maps from the oxc minifier and pass settings.options to the cssnano preset. This fixes missing JS sourcemaps and enables custom cssnano configuration via settings.options.
Written for commit 24b2fde. Summary will update on new commits.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.