fix(oxc): report oxc parse errors instead of an empty result
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.