fix: prevent UnexpectedBuildError misclassification and add SWC loader for TS/JSX/CJS - #100
Merged
Merged
Conversation
pastelsky
force-pushed
the
codex/stale-while-revalidate-badge
branch
from
August 10, 2026 13:21
81912ba to
999f01d
Compare
…handle non-missing compilation errors
…rify BuildError (422) for syntax/template failures
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a critical bug in
_parseMissingModuleswhere non-missing-module compilation errors (such as Rspack/SWC syntax parse errors) were blindly passed to_parseMissingModules, causing them to fail regex matching and crash with anUnexpectedBuildError("Expected to find a file path in the module not found error...").Additionally, adds
.jsx,.ts,.tsx,.cjsto Rspack'sresolve.extensionsand configuresbuiltin:swc-loaderfor/\.(js|mjs|jsx|ts|tsx|cjs)$/ so packages publishing raw TypeScript or JSX compile cleanly.Before vs. After Comparison
Example 1: Non-missing-module compilation error (e.g.
slim-ui)Before:
getPackageStats('slim-ui')threw an unhandled crash:{ "name": "UnexpectedBuildError", "originalError": "Expected to find a file path in the module not found error, but found none. Regex for this might be out of date." }This misclassified syntax errors as server unexpected errors (500s).
After:
getPackageStats('slim-ui')cleanly catches and returns structured compilation error details:{ "name": "BuildError", "originalError": [ { "message": "Module parse failed: JavaScript parse error: Expression expected in <RadioGroup.vue>", "code": "ModuleParseError" } ] }Example 2: Published TypeScript / JSX / ES2022 syntax
builtin:swc-loadertranspiles TS/JSX/ES2022+ features down to ES2017 seamlessly.Testing & Verification
tests/fast/build.utils.test.tsverifying_parseMissingModuleshandles non-missing-module compilation errors cleanly.corepack yarn test: 33/33 tests passing.corepack yarn check: 0 errors (TypeScript type check passed, Oxlint passed, Prettier format checked)..changeset/fix-module-parse-errors.md.