Open JacobDel opened 1 year ago
I had the same problem this morning, it was because I forget to add the extensions
property. Is your file is like somefile.ios.ts
, in that case, you should add put this in your extensions
property : ["android.tsx", "ios.tsx", ".tsx", "android.ts", "ios.ts", ".ts", ".json"]
He is my full babel.config.js (I use expo and ts) :
const whiteLabel = process.env.WHITE_LABEL;
const brandPath = `./src/brands/${whiteLabel}`;
function generateAlias(name) {
return [`${brandPath}/${name}`, `./src/${name}`];
}
module.exports = function (api) {
api.cache(true);
return {
presets: ["babel-preset-expo"],
plugins: [
[
"module-resolver",
{
root: ["."],
extensions: ["android.tsx", "ios.tsx", ".tsx", "android.ts", "ios.ts", ".ts", ".json"],
alias: {
components: generateAlias("components"),
},
},
],
],
};
};
In https://github.com/tleunen/babel-plugin-module-resolver/issues/261 it was discussed there could be two paths defined for one alias (if one path fails, there other could be used). Is it possible that this implementation is broken? https://github.com/tleunen/babel-plugin-module-resolver/pull/376
used versions:
This does not work for me (
babel.config.js
):This does work (difference is the path after
'@brand'
alias):