react-native-esbuild icon indicating copy to clipboard operation
react-native-esbuild copied to clipboard

[ERROR] No matching export in "node_modules/react-native-screens/src/index.native.tsx" for import "isSearchBarAvailableForCurrentPlatform"

Open ko-devHong opened this issue 11 months ago • 8 comments

I tried to run it after changing thereact-native-config.js setting after a normal installation, but an error occurs during compilation.

스크린샷 2023-09-20 오전 9 16 28
  • 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.

ko-devHong avatar Sep 20 '23 00:09 ko-devHong

I changed library code.

스크린샷 2023-09-20 오전 11 47 55

But it is not work

ko-devHong avatar Sep 20 '23 02:09 ko-devHong

@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

ko-devHong avatar Sep 21 '23 23:09 ko-devHong

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!

LeoInCode avatar Dec 06 '23 20:12 LeoInCode

To my understanding this is rooted in re-exporting types. I believe replacing them with explicit export/import type where needed solves it.

oblador avatar Dec 07 '23 07:12 oblador

Regardless, if you want my help i need a minimal code example reproducing the error

oblador avatar Dec 07 '23 07:12 oblador

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.

LeoInCode avatar Dec 10 '23 03:12 LeoInCode

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.

oblador avatar Dec 10 '23 07:12 oblador

But a patch-package for one by one of the erros, in the start of the project, is a shot in the foot.

LeoInCode avatar Dec 10 '23 18:12 LeoInCode