core icon indicating copy to clipboard operation
core copied to clipboard

remoteEntry.js wrongly generated

Open Keitar6 opened this issue 1 year ago • 10 comments

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

Keitar6 avatar May 31 '24 12:05 Keitar6

@ScriptedAlchemy Can you take a look at this

zhoushaw avatar Jun 03 '24 02:06 zhoushaw

Yes I'll investigate

ScriptedAlchemy avatar Jun 03 '24 07:06 ScriptedAlchemy

@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.

ScriptedAlchemy avatar Jun 03 '24 14:06 ScriptedAlchemy

Yes, you are right, i will fix it, sorry

Keitar6 avatar Jun 04 '24 07:06 Keitar6

Should be okay right now

Keitar6 avatar Jun 04 '24 08:06 Keitar6

@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

ScriptedAlchemy avatar Jun 11 '24 22:06 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 ?

72gm avatar Jun 12 '24 09:06 72gm

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

72gm avatar Jun 12 '24 11:06 72gm

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

72gm avatar Jun 12 '24 12:06 72gm

we added getPublicPath support now

ScriptedAlchemy avatar Jun 27 '24 18:06 ScriptedAlchemy

Stale issue message

github-actions[bot] avatar Aug 27 '24 15:08 github-actions[bot]