Skip to content

fix(angular-rspack): exclude .json files from JS/TS regex patterns#34195

Merged
leosvelperez merged 1 commit intonrwl:masterfrom
faileon:fix/ng-rspack-json-regex
Feb 25, 2026
Merged

fix(angular-rspack): exclude .json files from JS/TS regex patterns#34195
leosvelperez merged 1 commit intonrwl:masterfrom
faileon:fix/ng-rspack-json-regex

Conversation

@faileon
Copy link
Contributor

@faileon faileon commented Jan 23, 2026

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

@faileon faileon requested a review from a team as a code owner January 23, 2026 09:44
@faileon faileon requested a review from leosvelperez January 23, 2026 09:44
@vercel
Copy link

vercel bot commented Jan 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
nx-dev Ready Ready Preview Jan 23, 2026 9:50am

Request Review

@netlify
Copy link

netlify bot commented Jan 23, 2026

Deploy Preview for nx-docs canceled.

Name Link
🔨 Latest commit c51d2c6
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/699ec502738c390008ba2086
@leosvelperez leosvelperez force-pushed the fix/ng-rspack-json-regex branch from daab960 to c51d2c6 Compare February 25, 2026 09:46
@netlify
Copy link

netlify bot commented Feb 25, 2026

Deploy Preview for nx-dev canceled.

Name Link
🔨 Latest commit c51d2c6
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/699ec5023220550008896c68
Copy link
Member

@leosvelperez leosvelperez left a comment

Choose a reason for hiding this comment

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

Thanks!

@leosvelperez leosvelperez enabled auto-merge (squash) February 25, 2026 09:47
@nx-cloud
Copy link
Contributor

nx-cloud bot commented Feb 25, 2026

View your CI Pipeline Execution ↗ for commit c51d2c6

Command Status Duration Result
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 3m 6s View ↗
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 1m 59s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 8s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-02-25 09:53:48 UTC

@leosvelperez leosvelperez merged commit 7365515 into nrwl:master Feb 25, 2026
14 of 16 checks passed
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)
@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

2 participants