ionic-team / ionic-storage

Ionic Storage module for Ionic apps
MIT License
436 stars 99 forks source link

Problem between ionic storage and localForage #264

Open Mohamed-78 opened 1 year ago

Mohamed-78 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

https://github.com/localForage/localForage/pull/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.

broomfn commented 4 months ago

I get the following results:

npx patch-package localforage --exclude 'nothing' patch-package 8.0.0 • Creating temporary folder • Installing localforage@1.10.0 with npm • Diffing your files with clean files ⁉️ Not creating patch file for package 'localforage' ⁉️ There don't appear to be any changes.