metro icon indicating copy to clipboard operation
metro copied to clipboard

Bundling for Web attempts to import node.js modules from dependencies due to improper compiler environment selection

Open ryanhornberger opened this issue 1 year ago • 1 comments

Do you want to request a feature or report a bug?

Report a Bug

What is the current behavior?

When importing libraries like 'firebase' who depend use 'browser' as the main target and compiling for a metro 'browser' / web target the compiler still attempts to load node.js dependencies when it should not.

This has been previously reported to firebase-js-sdk but their staff believe this is a metro compiler issue.

See https://github.com/firebase/firebase-js-sdk/issues/7849#issuecomment-1857889012

If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can yarn install and yarn test.

I will attempt to build you a repository for testing this as soon as I can.

This is easily reproduce when importing [email protected] and attempting to access the firebase/auth package.

What is the expected behavior?

Only browser dependencies should load in a browser-based build.

Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.

ryanhornberger avatar May 28 '24 02:05 ryanhornberger

Bumping this. I'm facing the same issue with algoliasearch:

 "algoliasearch": "^5.18.0",
  "expo": "^52.0.37",
  "metro": "0.81.1",

edwinvrgs avatar Feb 24 '25 19:02 edwinvrgs