react-native-esbuild
react-native-esbuild copied to clipboard
[ERROR] No matching export in "node_modules/react-native-screens/src/index.native.tsx" for import "isSearchBarAvailableForCurrentPlatform"
I tried to run it after changing thereact-native-config.js setting after a normal installation, but an error occurs during compilation.
- react-native.config.js
const { createEsbuildCommands, defaultHasFlowSyntax, syntaxAwareLoaderPlugin } = require("react-native-esbuild");
const FLOW_MODULES_WITHOUT_PRAGMA = ["react-native-appsflyer"];
const commands = createEsbuildCommands((config, args) => ({
...config,
plugins: config.plugins
.filter(plugin => plugin.name !== "syntax-aware-loader")
.concat(
syntaxAwareLoaderPlugin({
filter: /\.([mc]js|[tj]sx?)$/,
cache: args.dev,
hasFlowSyntax: (contents, filePath) =>
defaultHasFlowSyntax(contents, filePath) ||
FLOW_MODULES_WITHOUT_PRAGMA.find(m => filePath.includes(`node_modules/${m}/`))
})
)
}));
module.exports = {
commands,
project: {
ios: {},
android: {}
},
assets: ["./src/assets/fonts/"],
dependencies: {
...(process.env.NO_FLIPPER ? { "react-native-flipper": { platforms: { ios: null } } } : {})
}
};
- package.json
{
...
"react-native-screens": "^3.19.0",
"@react-navigation/bottom-tabs": "^6.3.1",
"@react-navigation/elements": "^1.3.13",
"@react-navigation/material-top-tabs": "^6.2.2",
"@react-navigation/native": "^6.1.2",
"@react-navigation/native-stack": "^6.9.8",
"react-native": "0.71.1",
}
My guess is that I don't support esm.
I changed library code.
But it is not work
@oblador how can I solve this problem?
I think it's a similar situation to the link issue below but I have too much to change the code in the library.
https://github.com/evanw/esbuild/issues/890
I have the same experience. Idk more what I have to do. I think could be:
- When run "react-native esbuild-start", they cannot see tsconfig.json
- After running, "react-native-.config.js" file don't execute metro, so, they cannot understand this modules
I visited many sites, looked all files of this library, and other projects who used this library, but no one could resolve.
@oblador , we need an answer about that!
To my understanding this is rooted in re-exporting types. I believe replacing them with explicit export/import type where needed solves it.
Regardless, if you want my help i need a minimal code example reproducing the error
Yeah, I understand your explanation, but I cannot modify all my files of node_modules to adapt to this. Also, I discovered that this error is originally from esbuild. So, as you use that, you inherited this error.
node_modules in absolute majority of cases will ship transpiled code. I've worked in very large code bases and encountered this problem (which is not specific to just esbuild actually), but never in a third party lib. If it indeed is the case that they are only shipping TS, it's possible to patch it with patch-package or similar.
But a patch-package for one by one of the erros, in the start of the project, is a shot in the foot.