You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our RN app of which we want to create a web version from fails to serve due to DynamicFonts using react-native-fs.
➜ momo-app git:(staging) ✗ yarn web
yarn run v1.22.19
$ webpack serve --mode=development --config webpack.config.js
<w> [webpack-dev-server] "hot: true" automatically applies HMR plugin, you don't have to add it manually to your webpack configuration.
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: http://localhost:9001/, http://[::1]:9001/
<i> [webpack-dev-server] On Your Network (IPv4): http://169.254.168.41:9001/
<i> [webpack-dev-server] Content not from webpack is served from '/Users/theobouwman/dev/projects/momo/momo-app/dist' directory
asset rnw.bundle.js 7.57 MiB [emitted] (name: app)
asset index.html 430 bytes [emitted]
runtime modules 26.5 KiB 13 modules
orphan modules 234 bytes [orphan] 1 module
modules by path ./node_modules/ 5.99 MiB 1368 modules
./index.web.js 697 bytes [built] [code generated]
./app.json 49 bytes [built] [code generated]
./terminal-highlight (ignored) 15 bytes [built] [code generated]
path (ignored) 15 bytes [built] [code generated]
source-map-js (ignored) 15 bytes [built] [code generated]
url (ignored) 15 bytes [built] [code generated]
fs (ignored) 15 bytes [built] [code generated]
WARNING in ./node_modules/react-native-ui-lib/lib/components/DynamicFonts/RNFSPackage.js 1:98-124
Module not found: Error: Can't resolve 'react-native-fs' in '/Users/theobouwman/dev/projects/momo/momo-app/node_modules/react-native-ui-lib/lib/components/DynamicFonts'
@ ./node_modules/react-native-ui-lib/lib/components/DynamicFonts/FontDownloader.js 1:571-595
@ ./node_modules/react-native-ui-lib/lib/components/DynamicFonts/index.js 1:670-697
@ ./node_modules/react-native-ui-lib/lib/components/index.js 1:1199-1224
@ ./node_modules/react-native-ui-lib/src/index.js 1:34001-34029
@ ./index.web.js 1:230-260
1 warning has detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.
webpack 5.95.0 compiled with 1 warning in 17943 ms
webpack.config.js
constpath=require("path");constwebpack=require("webpack");constHtmlWebpackPlugin=require("html-webpack-plugin");constappDirectory=path.resolve(__dirname);const{ presets, plugins }=require(`${appDirectory}/babel.config.js`);constcompileNodeModules=[// Add every react-native package that needs compiling// 'react-native-gesture-handler','@react-native-community/netinfo','react-native-ui-lib','react-native-reanimated','react-native-shimmer-placeholder','react-native-linear-gradient','react-native-haptic-feedback','react-native-animatable','react-native-reanimated','react-native-svg','react-native-svg-transformer','@react-native-community/netinfo','@react-native-community/datetimepicker','react-native-color','react-native-ui-lib','postcss','postcss-js',].map((moduleName)=>path.resolve(appDirectory,`node_modules/${moduleName}`));constbabelLoaderConfiguration={test: /\.(js|jsx|ts|tsx)$/,// Updated to include .jsx// Add every directory that needs to be compiled by Babel during the build.include: [path.resolve(__dirname,"index.web.js"),// Entry to your application// path.resolve(__dirname, "App.tsx"), // Updated to .jsx// path.resolve(__dirname, "src"),
...compileNodeModules,],use: {loader: "babel-loader",options: {cacheDirectory: true,
presets,
plugins,},},};constsvgLoaderConfiguration={test: /\.svg$/,use: [{loader: "@svgr/webpack",},],};constimageLoaderConfiguration={test: /\.(gif|jpe?g|png|svg)$/,use: {loader: "url-loader",options: {name: "[name].[ext]",},},};consttsLoaderConfiguration={test: /\.(ts)x?$/,exclude: /node_modules|\.d\.ts$/,// this line as welluse: {loader: 'ts-loader',options: {compilerOptions: {noEmit: false,// this option will solve the issue},},},};module.exports={entry: {app: path.join(__dirname,"index.web.js"),},output: {path: path.resolve(appDirectory,"dist"),publicPath: "/",filename: "rnw.bundle.js",},resolve: {extensions: [".web.tsx",".web.ts",".tsx",".ts",".web.js",".js"],alias: {"react-native$": "react-native-web",},},module: {rules: [babelLoaderConfiguration,imageLoaderConfiguration,svgLoaderConfiguration,tsLoaderConfiguration,],},devServer: {static: path.resolve(appDirectory,'./dist'),compress: true,port: 9001},plugins: [newHtmlWebpackPlugin({template: path.join(__dirname,"index.html"),}),newwebpack.HotModuleReplacementPlugin(),newwebpack.DefinePlugin({__DEV__: JSON.stringify(true),}),],};
Hi, @theobouwman have you tried to add react-native-fs to the compileNodeModules ?
I haven't managed to reproduce it on our webDemo yet, if you have a snippet of the usage of DynamicFonts that recreates the error please paste it here.
Our RN app of which we want to create a web version from fails to serve due to
DynamicFonts
usingreact-native-fs
.webpack.config.js
package.json
The text was updated successfully, but these errors were encountered: