mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-16 02:24:10 +08:00
refactor(@angular-devkit/build-angular): exclude @angular/platform-server/init
from unsafe optimizations in esbuild
While currently esbuild is not use to bundle server bundles, it will in the future. This commit adds a check for the `@angular/platform-server/init` entry-point to be excluded from advanced optimizations.
This commit is contained in:
parent
bf4229da22
commit
4a38e8ab35
@ -43,10 +43,9 @@ describe('adjust-typescript-enums Babel plugin', () => {
|
||||
`,
|
||||
expected: `
|
||||
var ChangeDetectionStrategy = /*#__PURE__*/ (() => {
|
||||
(function (ChangeDetectionStrategy) {
|
||||
ChangeDetectionStrategy[ChangeDetectionStrategy["OnPush"] = 0] = "OnPush";
|
||||
ChangeDetectionStrategy[ChangeDetectionStrategy["Default"] = 1] = "Default";
|
||||
})(ChangeDetectionStrategy || (ChangeDetectionStrategy = {}));
|
||||
ChangeDetectionStrategy = ChangeDetectionStrategy || {};
|
||||
ChangeDetectionStrategy[(ChangeDetectionStrategy["OnPush"] = 0)] = "OnPush";
|
||||
ChangeDetectionStrategy[(ChangeDetectionStrategy["Default"] = 1)] = "Default";
|
||||
return ChangeDetectionStrategy;
|
||||
})();
|
||||
`,
|
||||
@ -64,10 +63,9 @@ describe('adjust-typescript-enums Babel plugin', () => {
|
||||
`,
|
||||
expected: `
|
||||
export var ChangeDetectionStrategy = /*#__PURE__*/ (() => {
|
||||
(function (ChangeDetectionStrategy) {
|
||||
ChangeDetectionStrategy[ChangeDetectionStrategy["OnPush"] = 0] = "OnPush";
|
||||
ChangeDetectionStrategy[ChangeDetectionStrategy["Default"] = 1] = "Default";
|
||||
})(ChangeDetectionStrategy || (ChangeDetectionStrategy = {}));
|
||||
ChangeDetectionStrategy = ChangeDetectionStrategy || {};
|
||||
ChangeDetectionStrategy[(ChangeDetectionStrategy["OnPush"] = 0)] = "OnPush";
|
||||
ChangeDetectionStrategy[(ChangeDetectionStrategy["Default"] = 1)] = "Default";
|
||||
return ChangeDetectionStrategy;
|
||||
})();
|
||||
`,
|
||||
@ -85,10 +83,9 @@ describe('adjust-typescript-enums Babel plugin', () => {
|
||||
`,
|
||||
expected: `
|
||||
export var ChangeDetectionStrategy = /*#__PURE__*/ (() => {
|
||||
(function (ChangeDetectionStrategy) {
|
||||
ChangeDetectionStrategy[ChangeDetectionStrategy["OnPush"] = 5] = "OnPush";
|
||||
ChangeDetectionStrategy[ChangeDetectionStrategy["Default"] = 8] = "Default";
|
||||
})(ChangeDetectionStrategy || (ChangeDetectionStrategy = {}));
|
||||
ChangeDetectionStrategy = ChangeDetectionStrategy || {};
|
||||
ChangeDetectionStrategy[(ChangeDetectionStrategy["OnPush"] = 5)] = "OnPush";
|
||||
ChangeDetectionStrategy[(ChangeDetectionStrategy["Default"] = 8)] = "Default";
|
||||
return ChangeDetectionStrategy;
|
||||
})();
|
||||
`,
|
||||
@ -98,20 +95,19 @@ describe('adjust-typescript-enums Babel plugin', () => {
|
||||
it('wraps string-based TypeScript enums', () => {
|
||||
testCase({
|
||||
input: `
|
||||
var NotificationKind;
|
||||
(function (NotificationKind) {
|
||||
NotificationKind["NEXT"] = "N";
|
||||
NotificationKind["ERROR"] = "E";
|
||||
NotificationKind["COMPLETE"] = "C";
|
||||
})(NotificationKind || (NotificationKind = {}));
|
||||
var NotificationKind;
|
||||
(function (NotificationKind) {
|
||||
NotificationKind["NEXT"] = "N";
|
||||
NotificationKind["ERROR"] = "E";
|
||||
NotificationKind["COMPLETE"] = "C";
|
||||
})(NotificationKind || (NotificationKind = {}));
|
||||
`,
|
||||
expected: `
|
||||
var NotificationKind = /*#__PURE__*/ (() => {
|
||||
(function (NotificationKind) {
|
||||
NotificationKind["NEXT"] = "N";
|
||||
NotificationKind["ERROR"] = "E";
|
||||
NotificationKind["COMPLETE"] = "C";
|
||||
})(NotificationKind || (NotificationKind = {}));
|
||||
NotificationKind = NotificationKind || {};
|
||||
NotificationKind["NEXT"] = "N";
|
||||
NotificationKind["ERROR"] = "E";
|
||||
NotificationKind["COMPLETE"] = "C";
|
||||
return NotificationKind;
|
||||
})();
|
||||
`,
|
||||
@ -165,15 +161,14 @@ describe('adjust-typescript-enums Babel plugin', () => {
|
||||
* @deprecated use @angular/common/http instead
|
||||
*/
|
||||
var RequestMethod = /*#__PURE__*/ (() => {
|
||||
(function (RequestMethod) {
|
||||
RequestMethod[RequestMethod["Get"] = 0] = "Get";
|
||||
RequestMethod[RequestMethod["Post"] = 1] = "Post";
|
||||
RequestMethod[RequestMethod["Put"] = 2] = "Put";
|
||||
RequestMethod[RequestMethod["Delete"] = 3] = "Delete";
|
||||
RequestMethod[RequestMethod["Options"] = 4] = "Options";
|
||||
RequestMethod[RequestMethod["Head"] = 5] = "Head";
|
||||
RequestMethod[RequestMethod["Patch"] = 6] = "Patch";
|
||||
})(RequestMethod || (RequestMethod = {}));
|
||||
RequestMethod = RequestMethod || {};
|
||||
RequestMethod[(RequestMethod["Get"] = 0)] = "Get";
|
||||
RequestMethod[(RequestMethod["Post"] = 1)] = "Post";
|
||||
RequestMethod[(RequestMethod["Put"] = 2)] = "Put";
|
||||
RequestMethod[(RequestMethod["Delete"] = 3)] = "Delete";
|
||||
RequestMethod[(RequestMethod["Options"] = 4)] = "Options";
|
||||
RequestMethod[(RequestMethod["Head"] = 5)] = "Head";
|
||||
RequestMethod[(RequestMethod["Patch"] = 6)] = "Patch";
|
||||
return RequestMethod;
|
||||
})();
|
||||
`,
|
||||
|
@ -55,7 +55,10 @@ async function transformWithBabel({
|
||||
return useInputSourcemap ? data : data.replace(/^\/\/# sourceMappingURL=[^\r\n]*/gm, '');
|
||||
}
|
||||
|
||||
const angularPackage = /[\\/]node_modules[\\/]@angular[\\/]/.test(filename);
|
||||
// @angular/platform-server/init entry-point has side-effects.
|
||||
const safeAngularPackage =
|
||||
/[\\/]node_modules[\\/]@angular[\\/]/.test(filename) &&
|
||||
!/@angular[\\/]platform-server[\\/]f?esm2022[\\/]init/.test(filename);
|
||||
|
||||
// Lazy load the linker plugin only when linking is required
|
||||
if (shouldLink) {
|
||||
@ -86,7 +89,7 @@ async function transformWithBabel({
|
||||
},
|
||||
forceAsyncTransformation,
|
||||
optimize: options.advancedOptimizations && {
|
||||
pureTopLevel: angularPackage,
|
||||
pureTopLevel: safeAngularPackage,
|
||||
},
|
||||
},
|
||||
],
|
||||
|
Loading…
x
Reference in New Issue
Block a user