repack icon indicating copy to clipboard operation
repack copied to clipboard

Unable to find MiniApp.container.bundle for iOS in compilation assets

Open paaber opened this issue 2 years ago • 3 comments

Environment

Operating System: Mac OS Node.js version: 20.10.0 repack version:3.7.0

Description

I am using the super app example and following the article posted on Medium. Both the host app and mini app server run fine, when i attempt to load mini app, into the host app, i encountered an error related to the MiniApp.container.bundle file not being found in the compilation assets

[``` mini-app] ✖ [01:23:39.098Z][DevServer] File MiniApp.container.bundle for ios not found in compilation assets { [mini-app] reqId: 'req-1', [mini-app] stack: 'Error: File MiniApp.container.bundle for ios not found in compilation assets\n' + [mini-app] ' at /super-app-example/packages/mini-app/node_modules/@callstack/repack/dist/webpack/Compiler.js:174:20\n' + [mini-app] ' at /super-app-example/packages/mini-app/node_modules/@callstack/repack/dist/webpack/Compiler.js:83:52\n' + [mini-app] ' at Array.forEach ()\n' + [mini-app] ' at callPendingResolvers (/super-app-example/packages/mini-app/node_modules/@callstack/repack/dist/webpack/Compiler.js:83:32)\n' + [mini-app] ' at Worker. (/super-app-example/packages/mini-app/node_modules/@callstack/repack/dist/webpack/Compiler.js:104:9)\n' + [mini-app] ' at Worker.emit (node:events:514:28)\n' + [mini-app] ' at MessagePort. (node:internal/worker:263:53)\n' + [mini-app] ' at [nodejs.internal.kHybridDispatch] (node:internal/event_target:814:20)\n' + [mini-app] ' at exports.emitMessage (node:internal/per_context/messageport:23:28)', [mini-app] type: 'Error' [mini-app] }

paaber avatar Apr 17 '24 11:04 paaber

@paaber please share your ScriptManager config in the host app, ideally also provide a reproduction repository so I can have a look at the code, thanks

jbroma avatar Apr 17 '24 11:04 jbroma

thanks for your swift response, @jbroma here is the ScriptManager snippet

import {AppRegistry} from 'react-native'; import App from './src/App'; import {name as appName} from './app.json'; import { ScriptManager, Federated ,} from "@callstack/repack/client"; import { Platform } from 'react-native'; AppRegistry.registerComponent(appName, () => App);

ScriptManager.shared.addResolver(async (scriptId, caller) => { const resolveURL = Federated.createURLResolver({ containers: { MiniApp: "http://localhost:9000/[name][ext]", }, });

const url = resolveURL(scriptId, caller);
if (url) {
  return {
    url,
    query: {
      platform: Platform.OS
    },
  };
}

});

https://github.com/paaber/superapp-repack-reprod.git. this is reproduction repository

paaber avatar Apr 17 '24 12:04 paaber

@paaber few things to make it work:

  1. your Repack.plugins.ModuleFederationPlugin is outside of the plugins array in both webpack.config.mjs files, in host-app and mini-app packages, that's why it's not working as expected.
  2. in mini-app config, inside of exposes you should use ./MiniAppNavigator instead of ./MiniApp because thats what you import in the host-app in packages/host-app/src/screens/MiniAppScreen.tsx on line 5:
const MiniAppNavigator = React.lazy(() =>
  Federated.importModule("MiniApp", "./MiniAppNavigator")
);

Closing this issue since it's not a problem with the library, but rather a configuration error on user's part.

jbroma avatar Apr 17 '24 13:04 jbroma