Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): update TS/JS regexp checks to lat…
Browse files Browse the repository at this point in the history
…est 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.
  • Loading branch information
clydin authored and filipesilva committed Oct 5, 2021
1 parent d4eafe5 commit 4be6537
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Expand Up @@ -321,7 +321,7 @@ async function setupLocalize(
};

const i18nRule: webpack.RuleSetRule = {
test: /\.(?:[cm]?js|ts)$/,
test: /\.[cm]?[tj]sx?$/,
enforce: 'post',
use: [
{
Expand Down
Expand Up @@ -249,7 +249,7 @@ export async function execute(
module: {
rules: [
{
test: /\.[t|j]s$/,
test: /\.[cm]?[tj]sx?$/,
loader: require.resolve('./ivy-extract-loader'),
options: {
messageHandler: (messages: LocalizeMessage[]) => ivyMessages.push(...messages),
Expand Down
Expand Up @@ -290,7 +290,7 @@ export async function getCommonConfig(wco: WebpackConfigOptions): Promise<Config

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

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

0 comments on commit 4be6537

Please sign in to comment.