From 3055b924afcb2d94ace11072beffa196882b77df Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Thu, 16 May 2024 14:16:41 +0000 Subject: [PATCH] fix(zone.js): correctly bundle `zone-patch-rxjs` (#55826) https://github.com/angular/angular/pull/53443 caused the a local `rxjs` file to be imported from an entry-point which caused this to be excluded from being bundled due to the name matching `rxjs`. Closes #55825 PR Close #55826 --- packages/zone.js/rollup.config.js | 20 ++++++++++++------- .../test/npm_package/npm_package.spec.ts | 7 +++++++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/packages/zone.js/rollup.config.js b/packages/zone.js/rollup.config.js index efc8abc78b7..e137778cea5 100644 --- a/packages/zone.js/rollup.config.js +++ b/packages/zone.js/rollup.config.js @@ -54,6 +54,19 @@ const banner = `'use strict'; */`; module.exports = { + external: (id) => { + if (id[0] === '.') { + // Relative paths are always non external. + return false; + } + + if (/zone\.js[\\/]lib/.test(id)) { + return false; + } + + return /rxjs|electron/.test(id); + }, + plugins: [ node({ mainFields: ['es2015', 'module', 'jsnext:main', 'main'], @@ -61,13 +74,6 @@ module.exports = { commonjs(), stripBannerPlugin, ], - external: (id) => { - if (/zone\.js[\\/]lib/.test(id)) { - return false; - } - - return /rxjs|^electron/.test(id); - }, output: { globals: { electron: 'electron', diff --git a/packages/zone.js/test/npm_package/npm_package.spec.ts b/packages/zone.js/test/npm_package/npm_package.spec.ts index a45bd6b65c0..ff7b9b3095b 100644 --- a/packages/zone.js/test/npm_package/npm_package.spec.ts +++ b/packages/zone.js/test/npm_package/npm_package.spec.ts @@ -116,6 +116,13 @@ describe('Zone.js npm_package', () => { expect(shx.cat('zone.js')).toMatch(/^\s*'use strict';/); }); }); + + it('zone-patch-rxjs.js should have rxjs external', () => { + checkInSubFolder('./fesm2015', () => { + expect(shx.cat('zone-patch-rxjs.js')).toContain(` from 'rxjs'`); + expect(shx.cat('zone-patch-rxjs.js')).toContain(`Zone.__load_patch('rxjs',`); + }); + }); }); describe('bundles file list', () => {