diff --git a/frontend/app-config/webpack.config.js b/frontend/app-config/webpack.config.js index d8f55b6c3..b80e8e8a7 100644 --- a/frontend/app-config/webpack.config.js +++ b/frontend/app-config/webpack.config.js @@ -49,7 +49,6 @@ module.exports = function calculateConfig(env) { const isDevServer = env.WEBPACK_SERVE; const isTestCoverage = env && env.coverage; const isTests = env && env.target === 'tests'; - const isAot = !isDevServer && !isTests && !isTestCoverage; const configFile = isTests ? 'tsconfig.spec.json' : 'tsconfig.app.json'; @@ -202,6 +201,15 @@ module.exports = function calculateConfig(env) { {}, ), + new plugins.NgToolsWebpack.AngularWebpackPlugin({ + tsconfig: configFile, + // Load directly from file system and skip webpack. + directTemplateLoading: true, + + // Only run in aot compiler in production. + jitMode: !isProduction, + }), + /* * Puts each bundle into a file and appends the hash of the file to the path. * @@ -362,16 +370,6 @@ module.exports = function calculateConfig(env) { } } - if (!isTestCoverage) { - config.plugins.push( - new plugins.NgToolsWebpack.AngularWebpackPlugin({ - directTemplateLoading: true, - jitMode: !isAot, - tsconfig: configFile, - }), - ); - } - if (isProduction) { config.optimization = { minimizer: [ @@ -408,23 +406,23 @@ module.exports = function calculateConfig(env) { if (isTestCoverage) { // Do not instrument tests. config.module.rules.push({ - test: /\.ts$/, + test: /\.[jt]sx?$/, use: [{ - loader: 'ts-loader', + loader: '@ngtools/webpack', }], include: [/\.(e2e|spec)\.ts$/], }); // Use instrument loader for all normal files. config.module.rules.push({ - test: /\.ts$/, + test: /\.[jt]sx?$/, use: [{ loader: 'istanbul-instrumenter-loader', options: { esModules: true, }, }, { - loader: 'ts-loader', + loader: '@ngtools/webpack', }], exclude: [/\.(e2e|spec)\.ts$/], }); diff --git a/frontend/package.json b/frontend/package.json index 801c01cc8..3115331f5 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -14,8 +14,8 @@ "build": "node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js --config app-config/webpack.config.js --env production", "build:clean": "rimraf wwwroot/build", "build:analyze": "node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js --config app-config/webpack.config.js --env production --env analyze", - "postinstall": "npx patch-package && ngcc --properties es2015 browser module main --create-ivy-entry-points", - "ngcc": "ngcc --properties es2015 browser module main --create-ivy-entry-points" + "postinstall": "npx patch-package && ngcc", + "ngcc": "ngcc" }, "dependencies": { "@angular/animations": "12.0.2",