facebook / metro

🚇 The JavaScript bundler for React Native
https://metrobundler.dev
MIT License
5.25k stars 627 forks source link

Haste could not resolve module with dot folder in the path (.build) #325

Open tuanmai opened 6 years ago

tuanmai commented 6 years ago

Do you want to request a feature or report a bug? It's a bug

What is the current behavior? I added a package with the path to the main file is .build/index.js. I can run the project on local successfully, but when I try to build. It shows this error.

While trying to resolve module `redux-api-call-adapter-dedupe` from file `/Users/tuanmai/code/MetroExample/index.js`, the package `/Users/tuanmai/code/MetroExample/node_modules/redux-api-call-adapter-dedupe/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/Users/tuanmai/code/MetroExample/node_modules/redux-api-call-adapter-dedupe/.build/index.js`. Indeed, none of these files exist:

  * `/Users/tuanmai/code/MetroExample/node_modules/redux-api-call-adapter-dedupe/.build/index.js(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)`
  * `/Users/tuanmai/code/MetroExample/node_modules/redux-api-call-adapter-dedupe/.build/index.js/index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)`

I tried to change the path on package.json and the folder name to build/index.js and it works normally.

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. Repo: https://github.com/tuanmai/metro-error-example (just created by react-native init then add the lib with /.build/index.js path. Steps:

What is the expected behavior? It should work with the .build/index.js Old metro version (0.30.2) with react native 0.55 works.

Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system. Current metro version: 0.48.3 node: v8.9.0 yarn: 1.10.1 OS: MacOS 10.14.1

toan2406 commented 5 years ago

I experienced this too. It's annoying that I have to clone the dependencies and change build path.