question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using Remote Component with CRA

See original GitHub issue

Hi,

nice library and very well documented, thank you for your effort!

I am having trouble using it within a regular Create React App (without ejecting or rewiring) and would appreciate any advice…

I am getting an error when I start my app:

Module not found: Can't resolve 'remote-component.config.js' in '/path/to/my/app/node_modules/@paciolan/remote-component/dist/lib'

Which later results in: Could not require 'react'. 'react' does not exist in dependencies.

I assume this is because CRA doesn’t use webpack.config.js… Do you maybe know a way around it which would not require ejecting or rewiring the app?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
joelnetcommented, Dec 27, 2019

I updated the docs to include the changes required to get Remote Component working with Create React App.

https://github.com/Paciolan/remote-component#create-react-app

I also made a note about that Warning message that appears.

https://github.com/Paciolan/remote-component#you-may-see-some-warnings

0reactions
joelnetcommented, Dec 26, 2019

I was able to get CRA working with the RemoteComponent without using eject.

I followed the manual configuration section.

Some changes I needed to make:

I moved remote-component.config.js into src/remote-component.config.js

Then I create src/components/RemoteComponent.js. I pointed to the new location for src/remote-component.config.js. I also had to change the imports.

/*
 * src/components/RemoteComponent.js
 */
//import {
//  createRemoteComponent,
//  createRequires
//} from "@paciolan/remote-component";
import { createRemoteComponent } from "@paciolan/remote-component/dist/lib/createRemoteComponent";
import { createRequires } from "@paciolan/remote-component/dist/lib/createRequires";
import { resolve } from "../../remote-component.config";

const requires = createRequires(resolve);
export const RemoteComponent = createRemoteComponent({ requires });

The error message seems to be from eager loading of RemoteComponent, even though it’s not used. I’m gonna work on changing this to be lazy in the next version.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Paciolan/remote-component: Dynamically load a React ...
A Remote Components is loaded at runtime from a URL. It is used in the same way any other React Component is used....
Read more >
Microfrontend Module Federation: Exposing Remote from ...
Exposing as a Remote​​ When you browse to http://localhost:8001/remoteEntry.js, you should be able to see the file. This is the file that you...
Read more >
Building React App with Module Federation and NextJS/React
Preferable not created using CRA(create react app); At least one React Component; One will be the host app; The other will a remote...
Read more >
Loading external esmodule on Create React App (w/o ejection)
Is there a way to dynamically load an external component from a remote location on a CRA project w/o the need to eject...
Read more >
Deployment | Create React App
git remote set-url origin https://<user>:<token>@github.com/<user>/<repo> . Try npm run deploy again. "Cannot read property 'email' of null"​.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found