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

Problem between ionic storage and localForage #264

Open
Mohamed-78 opened this issue Oct 22, 2022 · 2 comments
Open

Problem between ionic storage and localForage #264

Mohamed-78 opened this issue Oct 22, 2022 · 2 comments

Comments

@Mohamed-78
Copy link

when i build my ionic app i receive this message in my CMD: C:\APP_MOBILE\MUSCOPCI\node_modules@ionic\storage\dist\esm\index.js depends on 'localforage'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

@thiboot
Copy link

thiboot commented Jan 21, 2023

This is a warning because the package localforage (wich is used by ionic-storage) does not use completely ECMA Script Modules.
localforage is not maintained since last release : Aug 18, 2021 ...

Maybe it's time for ionic team to find a better alternative

@Samuel-Therrien-Beslogic

localForage/localForage#977 was reverted due to IE11 support breakage.
In the mean time you can re-apply it yourself using patch-package. Doing the modification yourself and running npx patch-package localforage --exclude 'nothing' should produce the following patch:
patches/localforage+1.10.0.patch

diff --git a/node_modules/localforage/package.json b/node_modules/localforage/package.json
index f3c8fbc..27b0627 100644
--- a/node_modules/localforage/package.json
+++ b/node_modules/localforage/package.json
@@ -63,6 +63,7 @@
         "webpack-dev-server": "^1.10.1"
     },
     "main": "dist/localforage.js",
+    "module": "src/localforage.js",
     "typings": "typings/localforage.d.ts",
     "bugs": {
         "url": "http://github.com/localForage/localForage/issues"

Then add npx patch-package to scripts.postinstall in your package.json to always re-apply the patch on install.

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

3 participants