Skip to content

Commit d7af4a7

Browse files
clydinjosephperrott
authored andcommitted
fix(@angular-devkit/build-angular): enable custom es2020 and es2015 conditional exports
By adding the `es2020` and `es2015` condition names, the build process will now use ES2020 or ES2015 specific files if a package's exports entries contain files for either of those conditions. This allows packages to provide multiple variants of the code that the bundler can then use based on the bundler's configuration. As of Angular v13, ES2020 code is preferred. However, some packages may prefer to export other variants by default but provide an `es2020`/`es2015` condition to allow other variants if requested. The server configuration is intentional not altered since the server output executes on Node.js and should use the `node` condition which is automatically added by Webpack based on the output target.
1 parent 5e435ff commit d7af4a7

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

packages/angular_devkit/build_angular/src/builders/browser/specs/lazy-module_spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,6 @@ describe('Browser Builder lazy modules', () => {
165165
const { files } = await browserBuild(architect, host, target, { commonChunk: false });
166166
expect(files['src_one_ts.js']).not.toBeUndefined();
167167
expect(files['src_two_ts.js']).not.toBeUndefined();
168-
expect(
169-
files['default-node_modules_angular_common___ivy_ngcc___fesm2015_http_js.js'],
170-
).toBeUndefined();
168+
expect(files['default-node_modules_angular_common_fesm2020_http_mjs.js']).toBeUndefined();
171169
});
172170
});

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export function getBrowserConfig(wco: WebpackConfigOptions): webpack.Configurati
5555
devtool: false,
5656
resolve: {
5757
mainFields: ['es2020', 'es2015', 'browser', 'module', 'main'],
58+
conditionNames: ['es2020', 'es2015', '...'],
5859
},
5960
output: {
6061
crossOriginLoading,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export function getTestConfig(
5555
target: wco.tsConfig.options.target === ScriptTarget.ES5 ? ['web', 'es5'] : 'web',
5656
resolve: {
5757
mainFields: ['es2020', 'es2015', 'browser', 'module', 'main'],
58+
conditionNames: ['es2020', 'es2015', '...'],
5859
},
5960
devtool: false,
6061
entry: {

0 commit comments

Comments
 (0)