oblador / react-native-esbuild

Fast bundler and dev server for react-native using esbuild
MIT License
595 stars 11 forks source link

[ERROR] [plugin react-native-asset-loader] Could not resolve "../images/bg_data_empty.png" #20

Closed luogao closed 2 years ago

luogao commented 2 years ago

I'm using react-native-esbuild v0.3.1 and I met this error when try react-native esbuild-start

image

here is my start script:

"start:es": "react-native esbuild-start  --reset-cache --port=8989 --host=127.0.0.1 --projectRoot=/Users/luogao/Documents/work/rn_content_pool_list",

and my react-native.config.js

const {
  createEsbuildCommands,
  esmCustomMainFieldResolverPlugin,
} = require('react-native-esbuild');

const commands = createEsbuildCommands(({ plugins, ...rest }) => ({
  ...rest,
  plugins: plugins.concat(esmCustomMainFieldResolverPlugin()),
}));

module.exports = {
  commands,
};

Any idea to solve this problem?

luogao commented 2 years ago

BTW, I follow the doc and add the simple script react-native esbuild-start to my package.json, will throw this Error

image

seems like the default options do not work... any idea?

oblador commented 2 years ago

Hi, very odd, what versions of react-native and @react-native-community/cli-* are you running? Could you set up a minimal reproducible example repo that I can try out? Since I see this is a TS file, can you try using an import instead of a require statement?

luogao commented 2 years ago

Hi, I'm using react-native 0.63.2 @react-native-community/cli-*

image
oblador commented 2 years ago

Aha, that’s a very outdated version. This lib supports 0.68 and up,

luogao commented 2 years ago

okay I see. But my project fixed version. Thanks anyway!

Great work Btw, I always want to tree shaking when build a bundle. hahhaaa