Invalid "exports" paths in zrender v6 cause Metro warnings in React Native 0.79
When using echarts@^6.0.0 (which depends on zrender@^6) inside a React Native project ([email protected]), Metro shows repeated warnings about invalid package.json configuration in zrender.
Example warnings:
WARN The package .../node_modules/zrender contains an invalid package.json configuration.
Reason: The resolution for ".../node_modules/zrender/lib/core/platform" defined in "exports"
is .../node_modules/zrender/lib/core/platform, however this file does not exist.
Falling back to file-based resolution.
...
This happens for several subpaths such as:
- lib/core/platform
- lib/zrender
- lib/svg/helper
- lib/graphic/Path
- lib/graphic/Image
- lib/graphic/TSpan
- lib/canvas/dashStyle
- lib/svg/mapStyleToAttrs
Metro (the React Native bundler) now validates the "exports" field by default and warns when subpaths point to non-existent files. It then falls back to file-based resolution so the app still works, but the warnings are noisy and could break if Metro ever removes the fallback.
Steps to reproduce
- Create a RN 0.79 project.
- Install @wuba/react-native-echarts@^2.0.3 and echarts@^6.0.0.
- Run react-native start.
- Observe Metro warnings about invalid exports in zrender.
Expected "exports" paths in zrender should match actual published files, so Metro (and other bundlers) resolve cleanly without warnings.
Environment
React Native: 0.79.4 echarts: 6.0.0 zrender: 6.x (installed via echarts) @wuba/react-native-echarts: 2.0.3
Had a bit of time to look into this. Not 100% sure if this causes actual breakage, but worth mentioning. happy to open a PR if this wasn't intentional.
In #1056 the package.json changed the wildcard export from "./*": "./*.js" to "./*": "./*"
from what I can tlell, and someone can say otherwise if not. since metro now validates package.json exports by default, it complains because the export paths dont map to real files (e.g. lib/graphic/Path doesn't exist without .js). Metro falls back to file resolution so things still run, but it spams the console as a result
simplest fix is to patch-package / pnpm patch (what we've done)
diff --git a/package.json b/package.json
index 26e4c59d0f7d26a49c9129c78aa6469228fce64a..4d563847cb6637e5f420cd474ff26cbef5d5cd0b 100644
--- a/package.json
+++ b/package.json
@@ -84,6 +84,6 @@
"./lib/tool/color": "./lib/tool/color.js",
"./lib/graphic/LinearGradient": "./lib/graphic/LinearGradient.js",
"./lib/graphic/RadialGradient": "./lib/graphic/RadialGradient.js",
- "./*": "./*"
+ "./*": "./*.js"
}
}
Alternatively, I assume you could turn off unstable_enablePackageExports in your metro.config.js to hide the warnings, but this isn't something I have tested.