jakearchibald / idb

IndexedDB, but with promises
https://www.npmjs.com/package/idb
ISC License
6.34k stars 357 forks source link

Issue when using the latest firebase version #267

Closed crunchytoast closed 2 years ago

crunchytoast commented 2 years ago

Android Bundling failed 4326ms While trying to resolve moduleidbfrom fileD:###\node_modules\@firebase\app\dist\esm\index.esm2017.js, the packageD:###\node_modules\idb\package.jsonwas successfully found. However, this package itself specifies amainmodule field that could not be resolved (D:###\node_modules\idb\build\index.cjs. Indeed, none of these files exist:

To reproduce, initialize an expo project, npm install the latest firebase version, and import any module from firebase in the App.js file.

jakearchibald commented 2 years ago

I'm not familiar with Firebase. Can you give me step by step instructions. I don't know what an 'expo project' is.

crunchytoast commented 2 years ago

ok I'm sorry, I'll write out the full details to recreate this issue...

expo is just a helper to make react-native apps, and firebase is a popular no-sql database hosting service

npm install --global expo-cli

then clone the repo I just shared with you called testfirebase

to start, you run expo install, then expo start

It should show the error...

crunchytoast commented 2 years ago

I have a hunch it's more of a firebase error... since they had stopped using idb as a dependency, then just recently started using it again and have run into this issue. So I'm not sure which part of the equation has changed.

jakearchibald commented 2 years ago

Yeah, I think so. Can you file an issue with them and link to it here?

crunchytoast commented 2 years ago

https://github.com/firebase/firebase-js-sdk/issues/6253

Here's a link to an existing issue there, where people are suggesting it's a problem with metro recognizing .cjs files. Seems to be an error merry-go-round...

If this is the case, the metro is working on a fix, and has a PR already in the works...

https://github.com/facebook/metro/pull/770

SohelIslamImran commented 2 years ago

Same issue image

crunchytoast commented 2 years ago

If you want a workaround, you can either downgrade your firebase version for now... or add a cjs reference in your metro.config file @SohelIslamImran

SohelIslamImran commented 2 years ago

@crunchytoast Thank you. Resolved.

Create a metro.config.js file in the project root. In the file add the file extension cjs. details

const { getDefaultConfig } = require("@expo/metro-config");

const defaultConfig = getDefaultConfig(__dirname);

defaultConfig.resolver.assetExts.push("cjs");

module.exports = defaultConfig;

image

skinsation89 commented 2 years ago

Adding the cjs reference in metro.config.js DID NOT WORK for me. Still receiving the same failed to resolve idb error. I tried all variations of it with sourceExt and still didn't work.

crunchytoast commented 2 years ago

If adding the cjs reference doesn't work, then just roll back firebase

npm uninstall firebase
npm install firebase@9.6.11
crunchytoast commented 2 years ago

This isn't an idb issue... it's an error in the metro bundler not recognizing cjs files, combined with idb being added as a dependency for the latest firebase version.

skinsation89 commented 2 years ago

Resolved! Thank you. I keep forgetting that version of Firebase exists.

On Thu, May 19, 2022, 10:46 AM crunchytoast @.***> wrote:

This isn't an idb issue... it's an error in the metro bundler not recognizing cjs files, combined with idb being added as a dependency for the latest firebase version.

— Reply to this email directly, view it on GitHub https://github.com/jakearchibald/idb/issues/267#issuecomment-1131891818, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMSPZ5U6HV5YA4ENAYOHJ4LVKZO63ANCNFSM5VQRLKLA . You are receiving this because you commented.Message ID: @.***>

mfellner commented 2 years ago

Just commenting here for folks that may still run into the same issue as I do:

Error thrown when reading from storage. Original error: (0 , _idb.openDB) is not a function. (app/storage-get).

https://github.com/firebase/firebase-js-sdk/issues/6253#issuecomment-1159733409

crunchytoast commented 1 year ago

ok I'm sorry, I'll write out the full details to recreate this issue...

expo is just a helper to make react-native apps, and firebase is a popular no-sql database hosting service

npm install --global expo-cli

then clone the repo I just shared with you called testfirebase

to start, you run expo install, then expo start

It should show the error...

On Tue, May 10, 2022 at 4:09 PM Jake Archibald @.***> wrote:

I'm not familiar with Firebase. Can you give me step by step instructions. I don't know what an 'expo project' is.

— Reply to this email directly, view it on GitHub https://github.com/jakearchibald/idb/issues/267#issuecomment-1122068197, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQWXFYLVS6TDCHWRELUCSNLVJIKU7ANCNFSM5VQRLKLA . You are receiving this because you authored the thread.Message ID: @.***>