-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible Breaking Change on Web in 15.5.0 #2418
Comments
Can reproduce this issue on RNSVG 15.6.0 |
Can reproduce. I'm using this in a nextjs project that worked before. Now its throwing errors about reading flowtypes. Example here: https://github.com/shawnmclean/sovoli/actions/runs/10548468653/job/29222414744#step:7:64 |
I've gotta say, seems like we could have a test added to make sure web support isn't broken on release right? |
Hey! 👋 The issue doesn't seem to contain a minimal reproduction. Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem? |
@jonstuebe , I'm sure the maintainers would welcome a PR from you adding such a test 😄 |
It seems like the same problem as here. Install this dependency. |
@shawnmclean If you have any questions let us know ;) |
FYI: I tried transpiling via next.js, but that doesn't seem to work. I think it's because it's a flow file with a .js extension and not typescript. I ended up patching registry.js instead. |
Can you share an example of how you tried transpiling via next.js? |
I added the package to transpilePackages in next.config.mjs (I already have other entire in there so I know it's working). I tried a couple of options
None of these made any difference. |
Hello @johnf, sorry it took a while. I found the solution to your problem. /** @type {import('next').NextConfig} */
const path = require("path");
const nextConfig = {
experimental: {
turbo: {
resolveAlias: {
"react-native": "react-native-web",
},
resolveExtensions: [
".web.js",
".web.jsx",
".web.ts",
".web.tsx",
".mdx",
".tsx",
".ts",
".jsx",
".js",
".mjs",
".json",
],
},
},
webpack: (config) => {
config.module.rules.push({
test: /\.(js|jsx|ts|tsx)$/,
include: [
path.resolve(__dirname, "src"),
path.resolve(
__dirname,
"node_modules/@react-native/assets-registry/registry"
),
],
use: {
loader: "babel-loader",
options: {
cacheDirectory: true,
presets: ["module:metro-react-native-babel-preset"],
plugins: ["react-native-web"],
},
},
});
config.resolve.alias = {
...(config.resolve.alias || {}),
// Transform all direct `react-native` imports to `react-native-web`
"react-native$": "react-native-web",
};
config.resolve.extensions = [
".web.js",
".web.jsx",
".web.ts",
".web.tsx",
...config.resolve.extensions,
];
return config;
},
};
module.exports = nextConfig; |
@bohdanprog Thank you for posting your fix. However, even with the next.config.js you recommended, I'm still running into this issue. I was wondering if you could share the versions of all of the relevant packages you are using, like react-native-web, react-native, nextjs, etc. Thank you! |
Description
This commit which was released on
v15.5.0
introduces a dependency on@react-native/assets-registry
which previously didn't exist.@react-native/assets-registry
is a transitive dependency ofreact-native
but is NOT a transitive dependency ofreact-native-web
. Therefore, in web contexts, an error is thrown due to the missing dependency.Steps to reproduce
Setup a bare
react-native-web
project that depends on[email protected]
and does NOT installreact-native
. This seems to only happen in non-expo contexts.Snack or a link to a repository
working on it
SVG version
15.5.0
React Native version
0.74.5
Platforms
Web
JavaScript runtime
None
Workflow
None
Architecture
None
Build type
None
Device
None
Device model
No response
Acknowledgements
Yes
The text was updated successfully, but these errors were encountered: