You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, when using shortcuts in combination with a minify routine, for example Terser, the minify routine may attempt to reassign the shortcuts. This will cause an error in the minified build. Here is a hypothetical destructure + reassignment that would come out of Terser
The recommend pattern is to not recommend shortcuts. Instead folks should use CdvPurchase.store, CdvPurchase.LogLevel etc. directly. Another fix would be #1419
The text was updated successfully, but these errors were encountered:
cnanders
changed the title
Namespace Destructuring
Recommended Namespace Shortcuts With Minify Can Cause Error
Nov 25, 2024
Observed behavior
The source code declares a namespace rather than exporting a module. The source code recommends using namespace shortcuts
cordova-plugin-purchase/src/ts/store.ts
Line 27 in c5cb3db
import "cordova-plugin-purchase";
const { store, ProductType, Platform, LogLevel } = CdvPurchase
However, when using shortcuts in combination with a minify routine, for example Terser, the minify routine may attempt to reassign the shortcuts. This will cause an error in the minified build. Here is a hypothetical destructure + reassignment that would come out of Terser
const { store: EY, ProductType: _Y, Platform: vY, LogLevel: TY } = CdvPurchase
Recommendation
The recommend pattern is to not recommend shortcuts. Instead folks should use
CdvPurchase.store
,CdvPurchase.LogLevel
etc. directly. Another fix would be #1419The text was updated successfully, but these errors were encountered: