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.
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 ofnode_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
andyarn test
.The following error is thrown:
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: https://github.com/expo/expo/issues/28222 https://github.com/vercel/storage/issues/505