oblador / react-native-esbuild

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

Could not resolve "@react-native/assets/registry.js" #30

Closed Jinho1011 closed 1 year ago

Jinho1011 commented 1 year ago

In the file src/plugins/asset-loader.js at line 33, the assetLoaderPlugin function includes a default value for the assetRegistryPath parameter. However, this default value is outdated and needs to be updated.

Current line: assetRegistryPath = '@react-native/assets/registry.js'

Expected line: assetRegistryPath = '@react-native/assets-registry/registry.js'

Since the release of version 0.72.1 of the react-native, the correct path to the asset registry file should include an additional directory called assets-registry. The current default value causes an error as below.

✘ [ERROR] Could not resolve "@react-native/assets/registry.js"

    react-native-asset:/Users/jeonjinho/Development/projects/sullog-app/sullog/node_modules/react-native/Libraries/LogBox/UI/LogBoxImages/alert-triangle.png:1:25:
      1 │ module.exports = require('@react-native/assets/registry.js').registerAsset({"__packager_asset":true,"scales":[1],"name":"alert-triangle","type":"png","hash":"4f355ba1efca4b9c0e7a6271af047f61","httpServerLocation":"/assets/node_modu...
        ╵                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  You can mark the path "@react-native/assets/registry.js" as external to exclude it from the
  bundle, which will remove this error. You can also surround this "require" call with a try/catch
  block to handle this failure at run-time instead of bundle-time.

I would suggest updating the default value of assetRegistryPath to '@react-native/assets-registry/registry.js' to resolve this issue.

Please let me know if any further information is required. Thank you!

oblador commented 1 year ago

Fixed in https://github.com/oblador/react-native-esbuild/pull/31