fix(angular-rspack): exclude .json files from JS/TS regex patterns#34195
Merged
leosvelperez merged 1 commit intonrwl:masterfrom Feb 25, 2026
Merged
fix(angular-rspack): exclude .json files from JS/TS regex patterns#34195leosvelperez merged 1 commit intonrwl:masterfrom
leosvelperez merged 1 commit intonrwl:masterfrom
Conversation
| The latest updates on your projects. Learn more about Vercel for GitHub.
|
✅ Deploy Preview for nx-docs canceled.
|
… angular-rspack-compiler
daab960 to c51d2c6 Compare ✅ Deploy Preview for nx-dev canceled.
|
Contributor
| View your CI Pipeline Execution ↗ for commit c51d2c6
☁️ Nx Cloud last updated this comment at |
FrozenPandaz pushed a commit that referenced this pull request Feb 26, 2026
…34195) ## Current Behavior When importing a `package.json` file in an Angular application built with `@nx/angular-rspack`, the build fails with a Babel syntax error if the `package.json` contains `@angular/*` dependencies: ``` SyntaxError: /path/to/package.json: Missing semicolon. (2:10) 1 | { > 2 | "name": "@org/app", | ^ 3 | "version": "4.0.2", 4 | "dependencies": { 5 | "@angular/platform-browser": "20.3.7", ``` This happens because the `JS_ALL_EXT_REGEX` pattern `/\.[cm]?(js)[^x]?\??/` incorrectly matches `.json` files. When the JSON file content contains `@angular` strings, the `angular-partial-transform-loader` attempts to process it through Babel, which fails because JSON is not valid JavaScript. **Root cause:** The regex `[^x]?` (optional character that is NOT 'x') allows `.json` to match because 'o' is not 'x'. ## Expected Behavior - `.json` files should NOT match `JS_ALL_EXT_REGEX` or `TS_ALL_EXT_REGEX` - Importing `package.json` in Angular applications should work correctly - All existing matches for `.js`, `.jsx`, `.mjs`, `.cjs` (and TypeScript equivalents) should continue to work ## Related Issue(s) #32649 (cherry picked from commit 7365515)
FrozenPandaz pushed a commit that referenced this pull request Feb 26, 2026
…34195) ## Current Behavior When importing a `package.json` file in an Angular application built with `@nx/angular-rspack`, the build fails with a Babel syntax error if the `package.json` contains `@angular/*` dependencies: ``` SyntaxError: /path/to/package.json: Missing semicolon. (2:10) 1 | { > 2 | "name": "@org/app", | ^ 3 | "version": "4.0.2", 4 | "dependencies": { 5 | "@angular/platform-browser": "20.3.7", ``` This happens because the `JS_ALL_EXT_REGEX` pattern `/\.[cm]?(js)[^x]?\??/` incorrectly matches `.json` files. When the JSON file content contains `@angular` strings, the `angular-partial-transform-loader` attempts to process it through Babel, which fails because JSON is not valid JavaScript. **Root cause:** The regex `[^x]?` (optional character that is NOT 'x') allows `.json` to match because 'o' is not 'x'. ## Expected Behavior - `.json` files should NOT match `JS_ALL_EXT_REGEX` or `TS_ALL_EXT_REGEX` - Importing `package.json` in Angular applications should work correctly - All existing matches for `.js`, `.jsx`, `.mjs`, `.cjs` (and TypeScript equivalents) should continue to work ## Related Issue(s) #32649 (cherry picked from commit 7365515)
Contributor
| This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
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 subscribe to this conversation on GitHub. Already have an account? Sign in.
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.
Current Behavior
When importing a
package.jsonfile in an Angular application built with@nx/angular-rspack, the build fails with a Babel syntax error if thepackage.jsoncontains@angular/*dependencies:This happens because the
JS_ALL_EXT_REGEXpattern/\.[cm]?(js)[^x]?\??/incorrectly matches.jsonfiles. When the JSON file content contains@angularstrings, theangular-partial-transform-loaderattempts to process it through Babel, which fails because JSON is not valid JavaScript.Root cause: The regex
[^x]?(optional character that is NOT 'x') allows.jsonto match because 'o' is not 'x'.Expected Behavior
.jsonfiles should NOT matchJS_ALL_EXT_REGEXorTS_ALL_EXT_REGEXpackage.jsonin Angular applications should work correctly.js,.jsx,.mjs,.cjs(and TypeScript equivalents) should continue to workRelated Issue(s)
#32649