|
| 1 | +/** |
| 2 | + * @license |
| 3 | + * Copyright Google LLC All Rights Reserved. |
| 4 | + * |
| 5 | + * Use of this source code is governed by an MIT-style license that can be |
| 6 | + * found in the LICENSE file at https://angular.io/license |
| 7 | + */ |
| 8 | + |
| 9 | +import { buildWebpackBrowser } from '../../index'; |
| 10 | +import { BASE_OPTIONS, BROWSER_BUILDER_INFO, describeBuilder } from '../setup'; |
| 11 | + |
| 12 | +describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => { |
| 13 | + describe('Behavior: "RxJS ES2015 exports condition"', () => { |
| 14 | + it('uses the rxjs ES2015 distribution files with rxjs 7.x', async () => { |
| 15 | + // The `es2015` export condition is enabled by the browser webpack configuration partial. |
| 16 | + // This should cause the application output to contain the ES2015 code and not the ES5 code. |
| 17 | + |
| 18 | + // Add rxjs usage to ensure it is present in the application output |
| 19 | + // The `rxjs-7` module specifier (and accompanying root package.json entry) is required to |
| 20 | + // support testing rxjs 7 while the actual CLI dependencies are still using rxjs 6 since |
| 21 | + // bazel unit test setup uses the main package.json dependencies during test. |
| 22 | + await harness.modifyFile( |
| 23 | + 'src/main.ts', |
| 24 | + (content) => `import { of } from 'rxjs-7';\n` + content + '\nof(1, 2, 3);', |
| 25 | + ); |
| 26 | + |
| 27 | + harness.useTarget('build', { |
| 28 | + ...BASE_OPTIONS, |
| 29 | + vendorChunk: true, |
| 30 | + }); |
| 31 | + |
| 32 | + const { result } = await harness.executeOnce(); |
| 33 | + |
| 34 | + expect(result?.success).toBe(true); |
| 35 | + harness |
| 36 | + .expectFile('dist/vendor.js') |
| 37 | + .content.not.toContain('./node_modules/rxjs-7/dist/esm5/'); |
| 38 | + harness.expectFile('dist/vendor.js').content.toContain('./node_modules/rxjs-7/dist/esm/'); |
| 39 | + harness.expectFile('dist/vendor.js').content.not.toContain('var Observable'); |
| 40 | + harness.expectFile('dist/vendor.js').content.toContain('class Observable'); |
| 41 | + }); |
| 42 | + }); |
| 43 | +}); |
0 commit comments