Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recommended Namespace Shortcuts With Minify Can Cause Error #1621

Open
cnanders opened this issue Nov 25, 2024 · 0 comments
Open

Recommended Namespace Shortcuts With Minify Can Cause Error #1621

cnanders opened this issue Nov 25, 2024 · 0 comments

Comments

@cnanders
Copy link

cnanders commented Nov 25, 2024

Observed behavior

The source code declares a namespace rather than exporting a module. The source code recommends using namespace shortcuts

* const {store, ProductType, Platform, LogLevel} = CdvPurchase;

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 #1419

@cnanders cnanders changed the title Namespace Destructuring Recommended Namespace Shortcuts With Minify Can Cause Error Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant