Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(@angular-devkit/build-angular): enable custom
es2015
conditiona…
…l exports By adding the `es2015` condition name, the build process will now use ES2015 specific files if a package's exports entries contain files for this condition. This allows packages to provide multiple variants of the code that the bundler can then use based on the bundler's configuration. For Angular v12, ES2015 code is preferred. However, some packages may prefer to export other variants by default but provide an `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
1 parent
8925674
commit 7b01a00
Showing
6 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -354,6 +354,7 @@ LARGE_SPECS = { | |
"@npm//font-awesome", | ||
"@npm//jquery", | ||
"@npm//popper.js", | ||
"@npm//rxjs-7", | ||
], | ||
}, | ||
} | ||
|
43 changes: 43 additions & 0 deletions
43
...es/angular_devkit/build_angular/src/browser/tests/behavior/rxjs-export-conditions_spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import { buildWebpackBrowser } from '../../index'; | ||
import { BASE_OPTIONS, BROWSER_BUILDER_INFO, describeBuilder } from '../setup'; | ||
|
||
describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => { | ||
describe('Behavior: "RxJS ES2015 exports condition"', () => { | ||
it('uses the rxjs ES2015 distribution files with rxjs 7.x', async () => { | ||
// The `es2015` export condition is enabled by the browser webpack configuration partial. | ||
// This should cause the application output to contain the ES2015 code and not the ES5 code. | ||
|
||
// Add rxjs usage to ensure it is present in the application output | ||
// The `rxjs-7` module specifier (and accompanying root package.json entry) is required to | ||
// support testing rxjs 7 while the actual CLI dependencies are still using rxjs 6 since | ||
// bazel unit test setup uses the main package.json dependencies during test. | ||
await harness.modifyFile( | ||
'src/main.ts', | ||
(content) => `import { of } from 'rxjs-7';\n` + content + '\nof(1, 2, 3);', | ||
); | ||
|
||
harness.useTarget('build', { | ||
...BASE_OPTIONS, | ||
vendorChunk: true, | ||
}); | ||
|
||
const { result } = await harness.executeOnce(); | ||
|
||
expect(result?.success).toBe(true); | ||
harness | ||
.expectFile('dist/vendor.js') | ||
.content.not.toContain('./node_modules/rxjs-7/dist/esm5/'); | ||
harness.expectFile('dist/vendor.js').content.toContain('./node_modules/rxjs-7/dist/esm/'); | ||
harness.expectFile('dist/vendor.js').content.not.toContain('var Observable'); | ||
harness.expectFile('dist/vendor.js').content.toContain('class Observable'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters