babel-plugin-module-resolver
babel-plugin-module-resolver copied to clipboard
Doesn't work in Production
I am using this package in my ReactNative project. It works well in simulator but when I publish app to app store, it doesn't work. (To be more exact, only assets folder doesn't work. Other folders work.)
jsconfig.json
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs",
"allowSyntheticDefaultImports": true,
"baseUrl": "./",
"paths": {
"assets/*": ["src/assets/*"],
"components/*": ["src/components/*"],
"navigators/*": ["src/navigators/*"],
"screens/*": ["src/screens/*"],
"core/*": ["src/core/*"],
"questions/*": ["src/questions/*"],
"redux/*": ["src/redux/*"]
}
}
}
environment
"babel-plugin-module-resolver": "^4.0.0",
"react": "16.13.1",
"react-native": "0.63.0",
npm - 4.2.0
node - 10.21.0
Similar issues here - I get a bundle error when attempting distribution: error Unable to resolve module components/root from index.js: components/root could not be found within the project.
Possibly related: https://github.com/facebook/react-native/issues/29351 https://stackoverflow.com/questions/62806319/main-jsbundle-does-not-exist-this-must-be-a-bug-with-main-jsbundle-issue-afte/62914788#62914788
This answer in the same stackoverflow thread worked for me: https://stackoverflow.com/a/62872851/1873778
babel.config.js
-> .babelrc.js
Have same issue in Production.... Guys, could you please check, we are really blocked. It happens in [email protected], [email protected] works fine. Looks like they have changed some mechanism for babel
For me, the solution was a combination of the following suggestions:
https://stackoverflow.com/a/62914788 https://github.com/facebook/react-native/issues/29351#issuecomment-657929014
@afestein It doesn't work for me... Did you try production builds for iOS successfully?
@tleunen Could you please help with this issue? It is related to [email protected]+ versions.... and this is really big blocker for all production projects with this babel plugin.. Thanks a lot
@oleksandr-dziuban I've never used this plugin with React Native so I unfortunately cannot help. So hopefully some other users and RN devs can help with this issue, and if there's something to be fixed, feel free to send a PR.
have the same issue
@oleksandr-dziuban I've never used this plugin with React Native so I unfortunately cannot help. So hopefully some other users and RN devs can help with this issue, and if there's something to be fixed, feel free to send a PR.
Issue not in this library, but in react-native code.. Possibly this PR will solve the issue: https://github.com/facebook/react-native/pull/29477
faced the same issue after updating RN to 0.63.0 :(
Additionally raised this issue for react native repo: https://github.com/facebook/react-native/issues/29636
It is critical issue for projects with this babel plugin
Yes, I can confirm, this PR fixes the issue! facebook/react-native#29477
I have assembled release iOS build locally with this change and it works!
~Maybe this is an unrelated issue, but it appears that this plugin will pick the first key that starts with the alias. eg~
// babel.config.js
{
"plugins": [
[
"module-resolver",
{
"root": ["."],
"alias": {
"a/b": "./src/a/b/index",
"a/b/c": "./src/a/b/c/index"
}
}
]
]
}
// src/app.js
import x from "a/b/c"; // resolves to "./a/b/index/c"
Maybe this is an unrelated issue, but it appears that this plugin will pick the first key that starts with the alias. eg
// babel.config.js { "plugins": [ [ "module-resolver", { "root": ["."], "alias": { "a/b": "./src/a/b/index", "a/b/c": "./src/a/b/c/index" } } ] ] } // src/app.js import x from "a/b/c"; // resolves to "./a/b/index/c"
No, it doesn't work. I use alias and release builds failed for iOS. The reason in react-native 0.63.2 change for react-native-xcode.sh file.
Thank you very much for pointing to the PR that fixes the bug @oleksandr-dziuban
I used https://www.npmjs.com/package/patch-package to patch react-native with the PR changes after installing packages. It worked for me.
Thank you very much for pointing to the PR that fixes the bug @oleksandr-dziuban
I used https://www.npmjs.com/package/patch-package to patch react-native with the PR changes after installing packages. It worked for me.
Hi, yes, I'm using this workaround too, but we need this PR to be merged anyway as it is critical iOS issue on react-native platform
I'm still seeing this issue in a 0.66 react native build. It all works correctly in dev on android and ios, as well as a production android build. But when I try to bundle for iOS in production it can't resolve any of the aliases.
Is anyone else still seeing this? I've scoured and tested everyone's previous solutions outlined through the many linked issues in this thread to no avail
I'm still seeing this issue in a 0.66 react native build. It all works correctly in dev on android and ios, as well as a production android build. But when I try to bundle for iOS in production it can't resolve any of the aliases.
Is anyone else still seeing this? I've scoured and tested everyone's previous solutions outlined through the many linked issues in this thread to no avail
I also have the problem, do you resolve it?
https://github.com/tleunen/babel-plugin-module-resolver/issues/332#issuecomment-439346463
@tbakerx @314new Have you tried this config? It works for me.