Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remoteEntry.js wrongly generated #2558

Closed
5 tasks done
Keitar6 opened this issue May 31, 2024 · 11 comments
Closed
5 tasks done

remoteEntry.js wrongly generated #2558

Keitar6 opened this issue May 31, 2024 · 11 comments
Assignees
Labels
nextjs-mf nextjs-mf package identifier no-issue-activity

Comments

@Keitar6
Copy link

Keitar6 commented May 31, 2024

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

@zhoushaw
Copy link
Collaborator

zhoushaw commented Jun 3, 2024

@ScriptedAlchemy Can you take a look at this

@zhoushaw zhoushaw added the nextjs-mf nextjs-mf package identifier label Jun 3, 2024
@ScriptedAlchemy
Copy link
Member

Yes I'll investigate

@ScriptedAlchemy
Copy link
Member

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

@Keitar6
Copy link
Author

Keitar6 commented Jun 4, 2024

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

@Keitar6
Copy link
Author

Keitar6 commented Jun 4, 2024

Should be okay right now

@ScriptedAlchemy
Copy link
Member

@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

@72gm
Copy link

72gm commented Jun 12, 2024

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
Copy link

72gm commented Jun 12, 2024

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
Copy link

72gm commented Jun 12, 2024

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

@ScriptedAlchemy
Copy link
Member

we added getPublicPath support now

Copy link
Contributor

Stale issue message

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nextjs-mf nextjs-mf package identifier no-issue-activity
Projects
None yet
Development

No branches or pull requests

4 participants