Skip to content

fix: improve oxc sourcemaps and cssnano options#2778

Merged
srod merged 2 commits intodevelopfrom
refactor/compressor-fixes
Jan 13, 2026
Merged

fix: improve oxc sourcemaps and cssnano options#2778
srod merged 2 commits intodevelopfrom
refactor/compressor-fixes

Conversation

@srod
Copy link
Owner

@srod srod commented Jan 13, 2026

Summary

  • oxc: Correctly return the generated source map from the minification result.
  • cssnano: Forward settings.options to 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

  • New Features
    • cssnano minifier now supports customizable preset options through configurable settings
    • oxc compressor now returns source maps in output when available for debugging

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot
Copy link

changeset-bot bot commented Jan 13, 2026

⚠️ No Changeset found

Latest commit: 24b2fde

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 13, 2026

📝 Walkthrough

Walkthrough

Two 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

Cohort / File(s) Summary
Minifier options forwarding
packages/cssnano/src/index.ts
Added settings parameter to function signature; derives options object from settings?.options ?? {} and passes it to PostCSS minify call for preset configuration.
Source map generation
packages/oxc/src/index.ts
Modified map return value from always undefined to stringified source map (JSON.stringify(result.map)) when available; updated JSDoc accordingly.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A rabbit hops through code so neat,
Settings dance where CSS and oxc meet!
Source maps emerge from shadows deep,
Options flow where minifiers sweep.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the two main changes: improving oxc sourcemaps and adding cssnano options forwarding, matching the core objectives and file modifications.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6878365 and 24b2fde.

📒 Files selected for processing (2)
  • packages/cssnano/src/index.ts
  • packages/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
Use node: prefix for Node.js built-in imports (e.g., node:child_process)
Use camelCase for function and variable names
Use try/catch with if (err instanceof Error) checks for error handling
Use Promise.all for parallel operations where all must succeed, or Promise.allSettled when 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 via warnDeprecation from @node-minify/utils for deprecated packages
Use resolveCompressor and isBuiltInCompressor utilities from @node-minify/utils for dynamic compressor resolution

Files:

  • packages/cssnano/src/index.ts
  • packages/oxc/src/index.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use type keyword for type-only imports in TypeScript
Include .ts file extension in local imports (e.g., ./setup.ts)
Use PascalCase for type and interface names

Files:

  • packages/cssnano/src/index.ts
  • packages/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.ts
  • packages/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 Compressor type that receives { settings, content } and returns { code, map? }

Files:

  • packages/cssnano/src/index.ts
  • packages/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.ts
  • packages/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.options to the cssnano preset, enabling users to customize minification behavior. The implementation follows the expected Compressor type signature and is consistent with other compressors in this monorepo. Based on learnings, the function properly receives { settings, content } and returns { code, map? }.

@greptile-apps
Copy link

greptile-apps bot commented Jan 13, 2026

Greptile Summary

This PR fixes two issues in the oxc and cssnano minifier packages. The oxc package now correctly returns source maps by stringifying result.map instead of hardcoding undefined, and the cssnano package now forwards settings.options to the cssnano preset for custom configuration support.

Key Changes:

  • oxc: Changed from map: undefined to map: result.map ? JSON.stringify(result.map) : undefined to properly return generated source maps
  • cssnano: Added settings parameter extraction and forwards settings.options to minify(options) call, enabling users to pass custom cssnano preset configurations

Both changes align with existing patterns in other compressor packages (terser, esbuild, clean-css) and maintain backward compatibility.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Both changes are straightforward bug fixes that follow established patterns in the codebase. The oxc change correctly returns source maps that were previously discarded, and the cssnano change enables proper configuration forwarding. No breaking changes, proper type safety maintained, and changes align with similar implementations in terser and esbuild packages.
  • No files require special attention

Important Files Changed

Filename Overview
packages/oxc/src/index.ts Returns source map from oxc minification result by stringifying result.map instead of hardcoded undefined
packages/cssnano/src/index.ts Forwards settings.options to cssnano preset, enabling custom configuration support

Sequence Diagram

sequenceDiagram
    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
Loading

@srod srod merged commit ed39b84 into develop Jan 13, 2026
10 checks passed
@srod srod deleted the refactor/compressor-fixes branch January 13, 2026 21:45
@codecov
Copy link

codecov bot commented Jan 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.58%. Comparing base (6878365) to head (24b2fde).
⚠️ Report is 3 commits behind head on develop.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant