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
This commit is contained in:
Alan Agius
2024-05-16 14:16:41 +00:00
committed by Andrew Scott
parent a768c90ee7
commit 3055b924af
2 changed files with 20 additions and 7 deletions
+13 -7
View File
@@ -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',
@@ -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', () => {