diff --git a/packages/angular-rspack-compiler/src/utils/regex-filters.spec.ts b/packages/angular-rspack-compiler/src/utils/regex-filters.spec.ts index 7ed3cd2201f..223a0f975e0 100644 --- a/packages/angular-rspack-compiler/src/utils/regex-filters.spec.ts +++ b/packages/angular-rspack-compiler/src/utils/regex-filters.spec.ts @@ -16,7 +16,7 @@ describe('TS_ALL_EXT_REGEX', () => { expect(filename).toMatch(TS_ALL_EXT_REGEX); }); - it.each([['file.js'], ['file.cjs'], ['file.mjs'], ['file']])( + it.each([['file.js'], ['file.cjs'], ['file.mjs'], ['file'], ['file.json']])( 'should not match other files', (filename) => { expect(filename).not.toMatch(TS_ALL_EXT_REGEX); @@ -35,12 +35,17 @@ describe('JS_ALL_EXT_REGEX', () => { expect(filename).toMatch(JS_ALL_EXT_REGEX); }); - it.each([['file.tsx'], ['file.ts'], ['file.cts'], ['file.mts'], ['file']])( - 'should not match other files', - (filename) => { - expect(filename).not.toMatch(JS_ALL_EXT_REGEX); - } - ); + it.each([ + ['file.tsx'], + ['file.ts'], + ['file.cts'], + ['file.mts'], + ['file'], + ['file.json'], + ['package.json'], + ])('should not match other files', (filename) => { + expect(filename).not.toMatch(JS_ALL_EXT_REGEX); + }); }); describe('isStandardJsFile', () => { diff --git a/packages/angular-rspack-compiler/src/utils/regex-filters.ts b/packages/angular-rspack-compiler/src/utils/regex-filters.ts index f5159885407..f346e5b2783 100644 --- a/packages/angular-rspack-compiler/src/utils/regex-filters.ts +++ b/packages/angular-rspack-compiler/src/utils/regex-filters.ts @@ -1,5 +1,5 @@ -export const TS_ALL_EXT_REGEX = /\.[cm]?(ts)[^x]?\??/; -export const JS_ALL_EXT_REGEX = /\.[cm]?(js)[^x]?\??/; +export const TS_ALL_EXT_REGEX = /\.[cm]?tsx?(\?|$)/; +export const JS_ALL_EXT_REGEX = /\.[cm]?jsx?(\?|$)/; export const JS_EXT_REGEX = /\.[cm]?js$/; export function isStandardJsFile(filename: string) {