From 9627a80f276521de5a86665e52077ff9aee02b09 Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Tue, 6 Jun 2023 11:54:25 -0300 Subject: [PATCH 1/4] fix(webpack): angular 16 build with terser (#10302) --- .../__snapshots__/angular.spec.ts.snap | 10 ++++++-- .../webpack5/src/configuration/angular.ts | 23 +++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/packages/webpack5/__tests__/configuration/__snapshots__/angular.spec.ts.snap b/packages/webpack5/__tests__/configuration/__snapshots__/angular.spec.ts.snap index eeabb1d9e..3b153662c 100644 --- a/packages/webpack5/__tests__/configuration/__snapshots__/angular.spec.ts.snap +++ b/packages/webpack5/__tests__/configuration/__snapshots__/angular.spec.ts.snap @@ -318,7 +318,10 @@ exports[`angular configuration for android 1`] = ` keep_infinity: true, drop_console: false, global_defs: { - __UGLIFIED__: true + __UGLIFIED__: true, + ngDevMode: false, + ngI18nClosureMode: false, + ngJitMode: false } }, keep_fnames: true, @@ -741,7 +744,10 @@ exports[`angular configuration for ios 1`] = ` keep_infinity: true, drop_console: false, global_defs: { - __UGLIFIED__: true + __UGLIFIED__: true, + ngDevMode: false, + ngI18nClosureMode: false, + ngJitMode: false } }, keep_fnames: true, diff --git a/packages/webpack5/src/configuration/angular.ts b/packages/webpack5/src/configuration/angular.ts index 0f2420fa4..c925f5e3a 100644 --- a/packages/webpack5/src/configuration/angular.ts +++ b/packages/webpack5/src/configuration/angular.ts @@ -13,6 +13,16 @@ import { getPlatformName, } from '../helpers/platform'; import base from './base'; +// until we can switch to async/await on the webpack config, copy this from '@angular/compiler-cli' +const GLOBAL_DEFS_FOR_TERSER = { + ngDevMode: false, + ngI18nClosureMode: false, +}; + +const GLOBAL_DEFS_FOR_TERSER_WITH_AOT = { + ...GLOBAL_DEFS_FOR_TERSER, + ngJitMode: false, +}; export default function (config: Config, env: IWebpackEnv = _env): Config { base(config, env); @@ -269,6 +279,19 @@ export default function (config: Config, env: IWebpackEnv = _env): Config { ]) ); + config.optimization.minimizer('TerserPlugin').tap((args) => { + args[0].terserOptions ??= {}; + args[0].terserOptions.compress ??= {}; + args[0].terserOptions.compress.global_defs ??= {}; + args[0].terserOptions.compress.global_defs = { + ...args[0].terserOptions.compress.global_defs, + ...(disableAOT + ? GLOBAL_DEFS_FOR_TERSER + : GLOBAL_DEFS_FOR_TERSER_WITH_AOT), + }; + return args; + }); + // todo: re-visit later, disabling by default now // config.plugin('DefinePlugin').tap((args) => { // args[0] = merge(args[0], { From 109dad13ade355f1ccfe41364ca2c2ba29474af8 Mon Sep 17 00:00:00 2001 From: Igor Randjelovic Date: Tue, 6 Jun 2023 16:56:30 +0200 Subject: [PATCH 2/4] release: @nativescript/webpack 5.0.15 --- packages/webpack5/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/webpack5/package.json b/packages/webpack5/package.json index 200e7ee6c..946fc6ff3 100644 --- a/packages/webpack5/package.json +++ b/packages/webpack5/package.json @@ -1,6 +1,6 @@ { "name": "@nativescript/webpack", - "version": "5.0.14", + "version": "5.0.15", "private": false, "main": "dist/index.js", "files": [ From 622f3659d8f531c35f790421a70cd927e4a52600 Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Mon, 12 Jun 2023 19:54:00 -0700 Subject: [PATCH 3/4] fix(animation): avoid uncaught reject on cancel (#10309) --- packages/core/ui/animation/index.android.ts | 2 +- packages/core/ui/animation/index.ios.ts | 29 +++++++++------------ 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/packages/core/ui/animation/index.android.ts b/packages/core/ui/animation/index.android.ts index ded8386fa..b335774af 100644 --- a/packages/core/ui/animation/index.android.ts +++ b/packages/core/ui/animation/index.android.ts @@ -248,7 +248,7 @@ export class Animation extends AnimationBase { private _onAndroidAnimationCancel() { // tslint:disable-line this._propertyResetCallbacks.forEach((v) => v()); - this._rejectAnimationFinishedPromise(); + this._resolveAnimationFinishedPromise(); if (this._target) { this._target._removeAnimation(this); diff --git a/packages/core/ui/animation/index.ios.ts b/packages/core/ui/animation/index.ios.ts index 03cd823f3..c5402be8b 100644 --- a/packages/core/ui/animation/index.ios.ts +++ b/packages/core/ui/animation/index.ios.ts @@ -7,7 +7,7 @@ import { AnimationBase, Properties, CubicBezierAnimationCurve } from './animatio import { Trace } from '../../trace'; import { opacityProperty, backgroundColorProperty, rotateProperty, rotateXProperty, rotateYProperty, translateXProperty, translateYProperty, scaleXProperty, scaleYProperty, heightProperty, widthProperty, PercentLength } from '../styling/style-properties'; -import { iOSNativeHelper } from '../../utils/native-helper'; +import { ios as iosHelper } from '../../utils/native-helper'; import { Screen } from '../../platform'; @@ -168,33 +168,28 @@ export class Animation extends AnimationBase { this._mergedPropertyAnimations = this._propertyAnimations; } - const that = this; const animationFinishedCallback = (cancelled: boolean) => { - if (that._playSequentially) { + if (this._playSequentially) { // This function will be called by the last animation when done or by another animation if the user cancels them halfway through. - if (cancelled) { - that._rejectAnimationFinishedPromise(); - } else { - that._resolveAnimationFinishedPromise(); - } + this._resolveAnimationFinishedPromise(); } else { // This callback will be called by each INDIVIDUAL animation when it finishes or is cancelled. if (cancelled) { - that._cancelledAnimations++; + this._cancelledAnimations++; } else { - that._finishedAnimations++; + this._finishedAnimations++; } - if (that._cancelledAnimations > 0 && that._cancelledAnimations + that._finishedAnimations === that._mergedPropertyAnimations.length) { + if (this._cancelledAnimations > 0 && this._cancelledAnimations + this._finishedAnimations === this._mergedPropertyAnimations.length) { if (Trace.isEnabled()) { - Trace.write(that._cancelledAnimations + ' animations cancelled.', Trace.categories.Animation); + Trace.write(this._cancelledAnimations + ' animations cancelled.', Trace.categories.Animation); } - that._rejectAnimationFinishedPromise(); - } else if (that._finishedAnimations === that._mergedPropertyAnimations.length) { + this._resolveAnimationFinishedPromise(); + } else if (this._finishedAnimations === this._mergedPropertyAnimations.length) { if (Trace.isEnabled()) { - Trace.write(that._finishedAnimations + ' animations finished.', Trace.categories.Animation); + Trace.write(this._finishedAnimations + ' animations finished.', Trace.categories.Animation); } - that._resolveAnimationFinishedPromise(); + this._resolveAnimationFinishedPromise(); } } }; @@ -719,7 +714,7 @@ function calculateTransform(view: View): CATransform3D { } expectedTransform = CATransform3DTranslate(expectedTransform, view.translateX, view.translateY, 0); - expectedTransform = iOSNativeHelper.applyRotateTransform(expectedTransform, view.rotateX, view.rotateY, view.rotate); + expectedTransform = iosHelper.applyRotateTransform(expectedTransform, view.rotateX, view.rotateY, view.rotate); expectedTransform = CATransform3DScale(expectedTransform, scaleX, scaleY, 1); return expectedTransform; From 0956cb0f919bc385664559c269c56892f3cd1b4e Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Mon, 12 Jun 2023 20:44:15 -0700 Subject: [PATCH 4/4] fix(shared-transitions): layer opacity set back to original on next tick (#10310) --- packages/core/utils/ios/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/core/utils/ios/index.ts b/packages/core/utils/ios/index.ts index c9170a656..f50999637 100644 --- a/packages/core/utils/ios/index.ts +++ b/packages/core/utils/ios/index.ts @@ -286,7 +286,10 @@ export function snapshotView(view: UIView, scale: number): UIImage { view.layer.renderInContext(UIGraphicsGetCurrentContext()); const image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); - view.layer.opacity = originalOpacity; + setTimeout(() => { + // ensure set back properly on next tick + view.layer.opacity = originalOpacity; + }); return image; }