Skip to content

Commit 7dcfa0c

Browse files
YanPesyannik.peschke
andauthored
docs: add docs for @mf-types related errors (#3090)
Co-authored-by: yannik.peschke <[email protected]>
1 parent 55eb275 commit 7dcfa0c

File tree

1 file changed

+58
-2
lines changed

1 file changed

+58
-2
lines changed

apps/website-new/docs/en/guide/basic/error-catalog.mdx

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ Undefined factory webpack/container/remote/`remote-name`/`name-of-exposed-file`
122122

123123
#### Solution 1
124124

125-
**Example scenario**: You have an npm package with `eager` remote imports (such as `import Button from 'myRemote/button'`) and share this npm package with `eager: true`.
125+
**Example scenario**: You have an npm package with `eager` remote imports (such as `import Button from 'myRemote/button'`) and share this npm package with `eager: true`.
126126
**Example scenario**: You're sharing a mix of packages, some with `eager: true` and others with `eager: false`, and the `eager: true` packages import the `eager: false` shared packages.
127127

128128
This error occurs when a remote (often a library-like shared module) contains unwanted circular dependencies between the `shared dependencies` of the remote and other consumers or the host application. If the environment is using the Module Federation config `shared: { "package-name": { eager: true } }`, the Rspack/Webpack builder runtime will break with this error.
@@ -133,7 +133,63 @@ Since eager consumption wraps all dependencies inside the entry file of the remo
133133

134134
#### Solution 2
135135

136-
You are missing an "async boundary" in your application. Ensure that you have a dynamic import at the top of the application.
136+
You are missing an "async boundary" in your application. Ensure that you have a dynamic import at the top of the application.
137137
For example, if your entry point is `index.js`, copy the contents of `index.js` into a new file called `bootstrap.js`. Then, in `index.js`, replace the code with `import('./bootstrap.js')`.
138138

139139
Alternatively, you can try the hoisted runtime experiment, which removes the need for an async boundary in user code. Learn more here: [Hoisted Runtime Experiment](https://module-federation.io/configure/experiments.html#federationruntime).
140+
141+
## Unable to compile federated types, Error: compile TS failed
142+
143+
#### Error Message
144+
:::danger Browser Error Message
145+
Unable to compile federated types, Error: compile TS failed, the original command is 'npx tsc --project file-path.json'.
146+
:::
147+
148+
:::danger Browser Error Message
149+
Error: ENOENT: no such file or directory, open 'project-path/rspack_hmr/application-name/dist/@mf-types.zip'
150+
:::
151+
152+
#### Solution
153+
154+
Credits to [@2heal1](https://github.com/2heal1), [@pganster](https://github.com/pganster) and [@jeremy-leclerc](https://github.com/jeremy-leclerc) for the support.
155+
156+
1. Make sure all errors and warnings of your Typescript compiler are resolved!
157+
2. Check your `ModuleFederationPlugin` config field `exposes`:
158+
159+
```ts title="[modern|rspack|rsbuild|webpack].config.[js,ts]"
160+
new ModuleFederationPlugin({
161+
...
162+
// Make sure both key and value start with "./"
163+
exposes: { './Foo': './src/<path-to-file>/Foo.tsx' },
164+
...
165+
})
166+
```
167+
## Unable to use the **remote_name**'s "remote-origin/remoteEntry.js' URL with **remote_name**'s globalName to get remoteEntry exports.
168+
169+
#### Error Message
170+
:::danger Browser Error Message
171+
[ Federation Runtime ]:
172+
173+
Unable to use the remote_name's 'http://localhost:3001/remoteEntry.js' URL with remote_name's globalName to get remoteEntry exports.
174+
Possible reasons could be:
175+
176+
1 'http://localhost:3001/remoteEntry.js' is not the correct URL, or the remoteEntry resource or name is incorrect.
177+
178+
2 cannot be used to get remoteEntry exports in the window object.
179+
at error (http://localhost:3000/main.js:2176:11)
180+
at Object.assert (http://localhost:3000/main.js:2168:9)
181+
at http://localhost:3000/main.js:196:15:
182+
:::
183+
184+
#### Solution
185+
186+
Credits to [@2heal1](https://github.com/2heal1) for the support.
187+
188+
1. Add the `shareStrategy` field to your build config.
189+
```ts title="[modern|rspack|rsbuild|webpack].config.[js,ts]"
190+
new ModuleFederationPlugin({
191+
...
192+
shareStrategy: 'loaded-first',
193+
...
194+
})
195+
```

0 commit comments

Comments
 (0)