Skip to content

Commit 248ed48

Browse files
clydinfilipesilva
authored andcommitted
refactor(@angular-devkit/build-angular): remove unneeded @angular/core System.import workarounds
With the removal of support for the string form of `loadChildren` within the Angular router, the usage of `System.import` has also been removal from `@angular/core`. This removal allows for the additional removal of all workarounds within the Angular CLI due to the `System.import` usage. Webpack's deprecated support for `System.import` was previously required to be enabled which resulted in warnings that then needed to be suppressed. A Webpack context dependency replacement was also previously required to prevent Webpack from failing due to the otherwise unknown behavior of the `System.import` call. All of these workarounds have now been removed.
1 parent eac18ae commit 248ed48

File tree

3 files changed

+3
-22
lines changed

3 files changed

+3
-22
lines changed

packages/angular_devkit/build_angular/src/builders/browser/tests/options/named-chunks_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { BASE_OPTIONS, BROWSER_BUILDER_INFO, describeBuilder } from '../setup';
1111

1212
const MAIN_OUTPUT = 'dist/main.js';
1313
const NAMED_LAZY_OUTPUT = 'dist/src_lazy-module_ts.js';
14-
const UNNAMED_LAZY_OUTPUT = 'dist/339.js';
14+
const UNNAMED_LAZY_OUTPUT = 'dist/629.js';
1515

1616
describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
1717
describe('Option: "namedChunks"', () => {

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

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,6 @@ export async function getCommonConfig(wco: WebpackConfigOptions): Promise<Config
355355
hints: false,
356356
},
357357
ignoreWarnings: [
358-
// Webpack 5+ has no facility to disable this warning.
359-
// System.import is used in @angular/core for deprecated string-form lazy routes
360-
/System.import\(\) is deprecated and will be removed soon/i,
361358
// https://github.com/webpack-contrib/source-map-loader/blob/b2de4249c7431dd8432da607e08f0f65e9d64219/src/index.js#L83
362359
/Failed to parse source map from/,
363360
// https://github.com/webpack-contrib/postcss-loader/blob/bd261875fdf9c596af4ffb3a1a73fe3c549befda/src/index.js#L153-L158
@@ -367,12 +364,6 @@ export async function getCommonConfig(wco: WebpackConfigOptions): Promise<Config
367364
// Show an error for missing exports instead of a warning.
368365
strictExportPresence: true,
369366
rules: [
370-
{
371-
// Mark files inside `@angular/core` as using SystemJS style dynamic imports.
372-
// Removing this will cause deprecation warnings to appear.
373-
test: /[/\\]@angular[/\\]core[/\\].+\.js$/,
374-
parser: { system: true },
375-
},
376367
{
377368
// Mark files inside `rxjs/add` as containing side effects.
378369
// If this is fixed upstream and the fixed version becomes the minimum
@@ -414,17 +405,7 @@ export async function getCommonConfig(wco: WebpackConfigOptions): Promise<Config
414405
chunkIds: buildOptions.namedChunks ? 'named' : 'deterministic',
415406
emitOnErrors: false,
416407
},
417-
plugins: [
418-
// Always replace the context for the System.import in angular/core to prevent warnings.
419-
// https://github.com/angular/angular/issues/11580
420-
new ContextReplacementPlugin(
421-
/@angular[\\/]core[\\/]/,
422-
path.join(projectRoot, '$_lazy_route_resources'),
423-
{},
424-
),
425-
new DedupeModuleResolvePlugin({ verbose: buildOptions.verbose }),
426-
...extraPlugins,
427-
],
408+
plugins: [new DedupeModuleResolvePlugin({ verbose: buildOptions.verbose }), ...extraPlugins],
428409
};
429410
}
430411

tests/legacy-cli/e2e/tests/build/worker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default async function () {
3333
await expectFileToMatch('dist/test-project/main.js', 'src_app_app_worker_ts');
3434

3535
await ng('build', '--output-hashing=none');
36-
const chunkId = '151';
36+
const chunkId = '310';
3737
await expectFileToExist(`dist/test-project/${chunkId}.js`);
3838
await expectFileToMatch('dist/test-project/main.js', chunkId);
3939

0 commit comments

Comments
 (0)