remoteEntry.js wrongly generated
Describe the bug
When remote is built it's remoteEntry.js seem to have some issues. The solution for it is to turn minimize to false in webpack config.
To view whole log, just use npm install, build remote1 and start it in production and go to page: http://localhost:3001/_next/static/ssr/remoteEntry.js
Unable to use the ${e}'s '${n}' URL with ${r}'s globalName to get remoteEntry exports.
Possible reasons could be:
1. '${n}' is not the correct URL, or the remoteEntry resource or name is incorrect.
2. ${r} cannot be used to get remoteEntry exports in the window object.
`),o}).catch(e=>e):(0,eZ.k0)(n,{attrs:{},createScriptHook:r}).then(()=>{let{remoteEntryKey:r,entryExports:o}=C(e,t);return s(o,`
Unable to use the ${e}'s '${n}' URL with ${r}'s globalName to get remoteEntry exports.
Possible reasons could be:
1. '${n}' is not the correct URL, or the remoteEntry resource or name is incorrect.
2. ${r} cannot be used to get remoteEntry exports in the window object._
Cannot get remoteSnapshot with the name: '${e.name}', version: '${e.version}' from __FEDERATION__.moduleInfo. The following reasons may be causing the problem:
1. The Deploy platform did not deliver the correct data. You can use __FEDERATION__.moduleInfo to check the remoteInfo.
2. The remote '${e.name}' version '${e.version}' is not released.
The transformed module info: ${JSON.stringify(s)}
The loadShareSync function was unable to load ${e}. The ${e} could not be found in ${n.options.name}.
Possible reasons for failure:
1. The ${e} share was registered with the 'get' attribute, but loadShare was not used beforehand.
2. The ${e} share was not registered with the 'lib' attribute.
`);return r.lib=t,this.setShared({pkgName:e,loaded:!0,from:n.options.name,lib:r.lib,shared:r}),r.lib}throw Error(`
The loadShareSync function was unable to load ${e}. The ${e} could not be found in ${n.options.name}.
Possible reasons for failure:
1. The ${e} share was registered with the 'get' attribute, but loadShare was not used beforehand.
2. The ${e} share was not registered with the 'lib' attribute.
Unable to locate ${o} in ${n.options.name}. Potential reasons for failure include:
1. ${o} was not included in the 'remotes' parameter of ${n.options.name||"the host"}.
2. ${o} could not be found in the 'remotes' of ${n.options.name} with either 'name' or 'alias' attributes.
3. ${o} is not online, injected, or loaded.
4. ${o} cannot be accessed on the expected.
5. The 'beforeRequest' hook was provided but did not return the correct 'remoteInfo' when attempting to load ${o}.
`
Reproduction
https://github.com/Keitar6/reproMF-chunks
Used Package Manager
npm
System Info
-
Validations
- [X] Read the docs.
- [X] Read the common issues list.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Make sure this is a Module federation issue and not a framework-specific issue.
- [X] The provided reproduction is a minimal reproducible example of the bug.
@ScriptedAlchemy Can you take a look at this
Yes I'll investigate
@Keitar6 your repo gives me a 404. https://github.com/Keitar6/reproMF-chunks/blob/main/host doesnt exist. Only 2 folders in the repo but clicking on them does not take me anywhere.
Yes, you are right, i will fix it, sorry
Should be okay right now
@Keitar6 i am unable to reproduce the issue in the repo, please provide exact steps or add a npm script that starts everything in the order and what page to go to. seems to work with minimize enabled
Getting this same error after switching to the this MF plugin from the webpack MF plugin
[ Federation Runtime ]: Unable to use the XXX's 'http://localhost:3001/remoteEntry.js' URL with XXX's globalName to get remoteEntry exports. Possible reasons could be:
1. 'http://localhost:3001/remoteEntry.js' is not the correct URL, or the remoteEntry resource or name is incorrect.
2. XXX cannot be used to get remoteEntry exports in the window object.
It's giving me a CORs issue... which I wasn't getting before...I've add a header entry to the webpack config but still the same?? Is the CORs a red herring?
remoteEntry files load fine if I access them direct
Any ideas @ScriptedAlchemy ?
Getting this same error after switching to the this MF plugin from the webpack MF plugin
[ Federation Runtime ]: Unable to use the XXX's 'http://localhost:3001/remoteEntry.js' URL with XXX's globalName to get remoteEntry exports. Possible reasons could be:
1. 'http://localhost:3001/remoteEntry.js' is not the correct URL, or the remoteEntry resource or name is incorrect. 2. XXX cannot be used to get remoteEntry exports in the window object.It's giving me a CORs issue... which I wasn't getting before...I've add a header entry to the webpack config but still the same?? Is the CORs a red herring?
remoteEntry files load fine if I access them direct
Any ideas @ScriptedAlchemy ?
For some reason I had to add CORs headers to all webpack configs.. which seems odd as at runtime I'm only consuming from the host
Which then leads to a bunch of other issues around types... mainly caused by the ouput value.... what worked for me
Host : output: { publicPath: '/', },
Other mfes delete this value if you have it
'auto' doesn't work
we added getPublicPath support now
Stale issue message