You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes, you start a project as an "app", and it perfectly fits. But then, later, your app grows, and what was an "app" before becomes a "module" within a bigger app.
And at this point you may get stuck because you can't import that "module" as a node dependency, and that can be a real blocker for product growth.
This has potential to be more and more a real blocker, especially because of universal apps (like Next.js) that could have the ability to "just import" CRA apps, but can't, because of this CRA's limitation.
Describe the solution you'd like
Assuming I write a CRA app my-cra-app, and I want to use this app in another node.js project - such as Next.s -, I'd like to import it that way:
importMyAppfrom'my-cra-app';// The CRA app loaded as a node.js moduleimportReactfrom'react';constMyCustomCraApp: React.FunctionComponent<Props>=(props: Props): JSX.Element=>{const{ prop2 }=props;return(<MyAppprop1={true}prop2={prop2}/>);};typeProps={prop2: string;}exportdefaultMyCustomCraApp;
Describe alternatives you've considered
At the moment, the only possibility is to load a CRA app on the browser-side. Meaning loading the CSS and JS files in the section, and creating a DOM element that matches the element where gets injected the CRA app.
I haven't found any solution to load a CRA app as a node.js module, and it's therefore not SSR compatible. (loading has to happens on the client side)
Is your proposal related to a problem?
This has potential to be more and more a real blocker, especially because of universal apps (like Next.js) that could have the ability to "just import" CRA apps, but can't, because of this CRA's limitation.
Describe the solution you'd like
Assuming I write a CRA app
my-cra-app
, and I want to use this app in another node.js project - such as Next.s -, I'd like to import it that way:Describe alternatives you've considered
At the moment, the only possibility is to load a CRA app on the browser-side. Meaning loading the CSS and JS files in the section, and creating a DOM element that matches the element where gets injected the CRA app.
I haven't found any solution to load a CRA app as a node.js module, and it's therefore not SSR compatible. (loading has to happens on the client side)
Additional context
Discussed with the community at https://spectrum.chat/create-react-app/general/how-to-convert-a-cra-app-into-a-package~23fd401e-ebb4-409f-9c8f-599fdddb0882
I don't know if it's technically doable, nor how hard it might be.
The text was updated successfully, but these errors were encountered: