Comments (7)
The value seems correct. It looks to me that React Native app is configured to make requests using package/appX
. Can you check AppDelegate.m
and make sure it's not setting package/appX
in URL somewhere. You can also do project-wide search for package/app
.
from repack.
Can you paste your webpack.config.js
for either of there apps?
Also from which directory are you running the react-native webpack-start
/Webpack CLI - is it from the monorepo root or from inside packages/appX
?
from repack.
Im running it from packages/appX
Webpack config:
const path = require("path");
const webpack = require("webpack");
const ReactNative = require("@callstack/repack");
const TerserPlugin = require("terser-webpack-plugin");
const mode = ReactNative.getMode();
const dev = mode === "development";
const context = ReactNative.getContext();
const entry = ReactNative.getEntry();
const platform = ReactNative.getPlatform({ fallback: process.env.PLATFORM });
const minimize = ReactNative.isMinimizeEnabled({ fallback: !dev });
const devServer = ReactNative.getDevServerOptions();
const reactNativePath = ReactNative.getReactNativePath({ fallback: "../../node_modules/react-native" });
const babelConfig = {
presets: ["module:metro-react-native-babel-preset"],
plugins: ["react-native-reanimated/plugin"],
env: {
production: {
plugins: [
"transform-remove-console",
[
"babel-plugin-jsx-remove-data-test-id",
{
attributes: ["testID", "testId"],
},
],
],
},
},
};
process.env.BABEL_ENV = mode;
/**
* Webpack configuration.
*/
module.exports = {
mode,
devtool: false,
context,
entry: [
...ReactNative.getInitializationEntries(reactNativePath, {
hmr: devServer.hmr,
}),
entry,
],
resolve: {
...ReactNative.getResolveOptions(platform),
alias: {
"react-native": reactNativePath,
},
},
output: {
clean: true,
path: path.join(__dirname, "build", platform),
filename: "index.bundle",
chunkFilename: "[name].chunk.bundle",
publicPath: ReactNative.getPublicPath(devServer),
},
optimization: {
minimize,
minimizer: [
new TerserPlugin({
test: /\.(js)?bundle(\?.*)?$/i,
extractComments: false,
}),
],
},
module: {
rules: [
{
test: /\.[jt]sx?$/,
include: [
/node_modules(.*[/\\])+react/,
/node_modules(.*[/\\])+@react-native/,
/node_modules(.*[/\\])+@react-navigation/,
/node_modules(.*[/\\])+@react-native-community/,
/node_modules(.*[/\\])+@expo/,
/node_modules(.*[/\\])+pretty-format/,
/node_modules(.*[/\\])+metro/,
/node_modules(.*[/\\])+abort-controller/,
/node_modules(.*[/\\])+@callstack[/\\]repack/,
],
use: {
loader: "babel-loader",
options: babelConfig,
},
},
{
test: /\.[jt]sx?$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
...babelConfig,
plugins: devServer.hmr ? ["module:react-refresh/babel", ...babelConfig.plugins] : babelConfig.plugins,
},
},
},
],
},
plugins: [
new webpack.DefinePlugin({
__DEV__: JSON.stringify(dev),
}),
new ReactNative.AssetsPlugin({
platform,
devServerEnabled: devServer.enabled,
}),
new ReactNative.TargetPlugin(),
new ReactNative.OutputPlugin({
devServerEnabled: devServer.enabled,
}),
new ReactNative.DevServerPlugin({
platform,
...devServer,
}),
new webpack.SourceMapDevToolPlugin({
test: /\.(js)?bundle$/,
exclude: /\.chunk\.(js)?bundle$/,
filename: "[file].map",
append: `//# sourceMappingURL=[url]?platform=${platform}`,
}),
new webpack.SourceMapDevToolPlugin({
test: /\.(js)?bundle$/,
include: /\.chunk\.(js)?bundle$/,
filename: "[file].map",
append: `//# sourceMappingURL=[url]?platform=${platform}`,
}),
new ReactNative.LoggerPlugin({
platform,
devServerEnabled: devServer.enabled,
output: {
console: true,
},
}),
],
};
from repack.
Can you add console.log({ context })
to this webpack.config.js
and check what it's printing?
from repack.
Here's every variable:
{
"mode": "development",
"dev": true,
"context": "path_to_root/packages/app1",
"entry": "./index.js",
"platform": "ios",
"minimize": false,
"devServer": { "enabled": true, "hmr": true, "host": "localhost", "port": 52019 },
"reactNativePath": "path_to_root/node_modules/react-native"
}
from repack.
Thanks, this did the trick.
For other folks out there using monorepo and migrating to Repack these are the changes that solved this:
- In
AppDelegate.m
find thesourceURLForBridge
section and change it so it looks like the following:
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; // I had jsBundleURLForBundleRoot:@"packages/appX"
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
- In
MainApplication.java
findgetJSMainModuleName
, it should be:
@Override
protected String getJSMainModuleName() {
return "index"; // I had "packages/appX"
}
- In
app/build.gradle
findproject.ext.react
and remove the folllowing fields if they are present:
entryFile
,cliPath
,composeSourceMapsPath
- In xCode open
Build phases
and expandBundle React Native Code And Images
. You don't needEXTRA_PACKAGER_ARGS
if its there.
Also If you get errors in the bundle after the build in xCode ( some classes were not transpiled ) you need to add them in the webpack.config
. ( https://github.com/callstack/repack/blob/main/templates/webpack.config.js#L147 )
from repack.
I'm closing this issue since it seems to be resolved. If there are any more problems with it, feel free to reopen.
from repack.
Related Issues (20)
- Can't find variable: __wepack_require__ in ScriptManager.js HOT 10
- Unable to load script. Make sure you're either running Metro HOT 3
- Facing issue while implementing Offline Bundling. HOT 5
- Error in bundling micro apps with react-native-svg packages HOT 3
- [RFC] Override `start` command in `react-native.config.js` HOT 8
- Unhandled error in Webpack Compiler when doing `rpm run ios` HOT 2
- Cannot Resole React Hook Form correctly HOT 7
- repack monorepo deployment help
- Android is crashing when "onMessage" props is accessed in "react-native-webview" library HOT 1
- [RFC] sync API HOT 10
- Improve types for `prefetchScript` and `loadScript` HOT 3
- Is it possible to load a remote module before it is requested by the user?
- callstack_repack-Swift.h file not found HOT 11
- Repack app fails with "could not find react-redux context value" for the latest versions of react-redux and @reduxjs/toolkit HOT 3
- Property 'HMRClient' doesn't exist HOT 4
- Challenge Integrating Repack in React Native Mono Repo: App1 Loads Successfully, App2 Fails to Load from Server Bundles HOT 3
- Extract runtime into separate package in monorepo & publish it separately HOT 2
- Migrate ObjC code parts to Swift HOT 2
- How do i use react-native-gesture-handler in both my mini app and host app? HOT 5
- Repack Navigation From Mini App To Main APP HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from repack.