Skip to content

fix(oxc): report oxc parse errors instead of an empty result - #2954

Merged
srod merged 1 commit into
developfrom
advisor/001-oxc-report-parse-errors
Nov 23, 2026
Merged

srod merged 1 commit into
developfrom
advisor/001-oxc-report-parse-errors

Conversation

@srod

@srod srod commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

oxc-minify does not throw on a syntax error. It returns code: "" and puts the error in result.errors. The compressor ignored errors, so a syntax error came out as No content provided, or as a silent empty success with allowEmptyOutput.

 oxc()
   result = oxcMinify(…)
+  if result.errors has severity "Error"
+    throw messages joined by "; "        # wrapped as "oxc minification failed: …"
   validateMinifyResult(result)

Warnings and advice still pass through. String(error.severity) is used because Severity is an ambient const enum, which isolatedModules cannot read.

Evidence

Real oxc on tests/fixtures/js-errors:

Before After
default No content provided oxc minification failed: Cannot assign to this expression
allowEmptyOutput: true resolves "" oxc minification failed: Cannot assign to this expression

New tests in oxc-error.test.ts: an Error severity rejects, a warning alone resolves. oxc.test.ts "should throw" now checks the message. bun run test packages/oxc: 24 pass.

Merge Danger

Door: two-way

Blast Radius: oxc users

Input oxc cannot parse now fails loudly instead of producing an empty file. Changeset: @node-minify/oxc patch.


Summary by cubic

Fixes the oxc compressor silently succeeding on unparseable input. oxc-minify does not throw on a syntax error; it returns empty code and puts the error in result.errors, which the compressor previously ignored. The compressor now throws oxc minification failed: <error messages> when oxc reports an error severity, so invalid JavaScript fails loudly instead of yielding "No content provided" or silently passing with allowEmptyOutput. Warnings and advice still pass through.

Testing

  • New tests cover an error severity rejecting and warnings alone resolving.
  • The existing "should throw" test now asserts the new message.

Written for commit 5b87896. Summary will update on new commits.

View guided diff Turn on auto-fix

@changeset-bot

changeset-bot Bot commented Nov 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5b87896

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 25 packages
Name Type
@node-minify/oxc Patch
@node-minify/action Patch
@node-minify/cli Patch
@node-minify/examples Patch
@node-minify/docs Patch
@node-minify/benchmark Patch
@node-minify/clean-css Patch
@node-minify/core Patch
@node-minify/cssnano Patch
@node-minify/csso Patch
@node-minify/esbuild Patch
@node-minify/google-closure-compiler Patch
@node-minify/html-minifier Patch
@node-minify/imagemin Patch
@node-minify/jsonminify Patch
@node-minify/lightningcss Patch
@node-minify/minify-html Patch
@node-minify/no-compress Patch
@node-minify/sharp Patch
@node-minify/svgo Patch
@node-minify/swc Patch
@node-minify/terser Patch
@node-minify/types Patch
@node-minify/uglify-js Patch
@node-minify/utils Patch

Not sure what this means? Click here to learn what changesets are.

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

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 4 files

View guided diff | Turn on auto-fix | Re-trigger cubic

@codecov

codecov Bot commented Nov 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.63%. Comparing base (34a46a1) to head (5b87896).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #2954   +/-   ##
========================================
  Coverage    98.63%   98.63%           
========================================
  Files           70       70           
  Lines         2052     2056    +4     
  Branches       625      626    +1     
========================================
+ Hits          2024     2028    +4     
  Misses          28       28           

☔ View full report in Codecov by Harness.
📢 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.

@srod
srod merged commit ce1a1c2 into develop Nov 23, 2026
6 checks passed
@srod
srod deleted the advisor/001-oxc-report-parse-errors branch November 23, 2026 16:55
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