Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): enable custom es2020 and `es201…
Browse files Browse the repository at this point in the history
…5` 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.
  • Loading branch information
clydin authored and josephperrott committed Oct 6, 2021
1 parent 5e435ff commit d7af4a7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Expand Up @@ -165,8 +165,6 @@ describe('Browser Builder lazy modules', () => {
const { files } = await browserBuild(architect, host, target, { commonChunk: false });
expect(files['src_one_ts.js']).not.toBeUndefined();
expect(files['src_two_ts.js']).not.toBeUndefined();
expect(
files['default-node_modules_angular_common___ivy_ngcc___fesm2015_http_js.js'],
).toBeUndefined();
expect(files['default-node_modules_angular_common_fesm2020_http_mjs.js']).toBeUndefined();
});
});
Expand Up @@ -55,6 +55,7 @@ export function getBrowserConfig(wco: WebpackConfigOptions): webpack.Configurati
devtool: false,
resolve: {
mainFields: ['es2020', 'es2015', 'browser', 'module', 'main'],
conditionNames: ['es2020', 'es2015', '...'],
},
output: {
crossOriginLoading,
Expand Down
Expand Up @@ -55,6 +55,7 @@ export function getTestConfig(
target: wco.tsConfig.options.target === ScriptTarget.ES5 ? ['web', 'es5'] : 'web',
resolve: {
mainFields: ['es2020', 'es2015', 'browser', 'module', 'main'],
conditionNames: ['es2020', 'es2015', '...'],
},
devtool: false,
entry: {
Expand Down

0 comments on commit d7af4a7

Please sign in to comment.