Skip to content

Commit 4be6537

Browse files
clydinfilipesilva
authored andcommitted
fix(@angular-devkit/build-angular): update TS/JS regexp checks to latest extensions
The regular expressions based checks for TypeScript and JavaScript files used by Webpack module rules have been updated to include all current extension variations. JavaScript files can be either `.js`, `.mjs`, or `.cjs`. TypeScript files as of the upcoming version 4.5 can be either `.ts`, `.mts`, or `.cts`. Also while not officially supported by Angular, the TypeScript compiler can attempt to process any of the previous extensions with an `x` suffix which indicates a JSX/TSX file.
1 parent d4eafe5 commit 4be6537

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

packages/angular_devkit/build_angular/src/builders/dev-server/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ async function setupLocalize(
321321
};
322322

323323
const i18nRule: webpack.RuleSetRule = {
324-
test: /\.(?:[cm]?js|ts)$/,
324+
test: /\.[cm]?[tj]sx?$/,
325325
enforce: 'post',
326326
use: [
327327
{

packages/angular_devkit/build_angular/src/builders/extract-i18n/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ export async function execute(
249249
module: {
250250
rules: [
251251
{
252-
test: /\.[t|j]s$/,
252+
test: /\.[cm]?[tj]sx?$/,
253253
loader: require.resolve('./ivy-extract-loader'),
254254
options: {
255255
messageHandler: (messages: LocalizeMessage[]) => ivyMessages.push(...messages),

packages/angular_devkit/build_angular/src/webpack/configs/common.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ export async function getCommonConfig(wco: WebpackConfigOptions): Promise<Config
290290

291291
if (scriptsSourceMap || stylesSourceMap) {
292292
extraRules.push({
293-
test: /\.m?js$/,
293+
test: /\.[cm]?jsx?$/,
294294
enforce: 'pre',
295295
loader: require.resolve('source-map-loader'),
296296
options: {
@@ -381,7 +381,7 @@ export async function getCommonConfig(wco: WebpackConfigOptions): Promise<Config
381381
sideEffects: true,
382382
},
383383
{
384-
test: /\.[cm]?js$|\.tsx?$/,
384+
test: /\.[cm]?[tj]sx?$/,
385385
// The below is needed due to a bug in `@babel/runtime`. See: https://github.com/babel/babel/issues/12824
386386
resolve: { fullySpecified: false },
387387
exclude: [/[/\\](?:core-js|@babel|tslib|web-animations-js|web-streams-polyfill)[/\\]/],

packages/angular_devkit/build_angular/src/webpack/configs/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function getTestConfig(
3737
}
3838

3939
extraRules.push({
40-
test: /\.(jsx?|tsx?)$/,
40+
test: /\.[cm]?[tj]sx?$/,
4141
loader: require.resolve('@jsdevtools/coverage-istanbul-loader'),
4242
options: { esModules: true },
4343
enforce: 'post',

0 commit comments

Comments
 (0)