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

Browser field not resolved correctly if in a sub package #1273

Open
luismeyer opened this issue May 14, 2024 · 1 comment
Open

Browser field not resolved correctly if in a sub package #1273

luismeyer opened this issue May 14, 2024 · 1 comment

Comments

@luismeyer
Copy link

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

bug

What is the current behavior?

When importing a module that redirects another import using the browser field in the package.json and the module is a sub package (like @foo/module) the import is not resolved correctly.

Metro is looking for the module in node_modules/@foo instead of node_modules/@foo/module

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.

npm init -y
npm i @vercel/blob metro
echo 'require("@vercel/blob");' >> index.js
npx metro build index.js --out bundle.js

The following error is thrown:

None of these files exist:
  * node_modules/@vercel/dist/undici-browser.js(.web.js|.native.js|.js|.web.jsx|.native.jsx|.jsx|.web.json|.native.json|.json|.web.ts|.native.ts|.ts|.web.tsx|.native.tsx|.tsx)
  * node_modules/@vercel/dist/undici-browser.js/index(.web.js|.native.js|.js|.web.jsx|.native.jsx|.jsx|.web.json|.native.json|.json|.web.ts|.native.ts|.ts|.web.tsx|.native.tsx|.tsx)

What is the expected behavior?

The module should be resolved to node_modules/@vercel/blob/dist/undici-browser.js

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

Node: v20.11.1
npm: 10.2.4
OS: macOS Sonoma 14.4.1

Related Issues:
expo/expo#28222
vercel/storage#505

@luismeyer luismeyer changed the title Module browser field not resolved correctly if it's is a sub package Browser field not resolved correctly if it's is a sub package May 14, 2024
@luismeyer luismeyer changed the title Browser field not resolved correctly if it's is a sub package Browser field not resolved correctly if it is a sub package May 14, 2024
@luismeyer luismeyer changed the title Browser field not resolved correctly if it is a sub package Browser field not resolved correctly if in a sub package May 25, 2024
@60pfennig
Copy link

I have the same issue here and hoping for a fix soon.

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

2 participants