Skip to content

A few issues with Modern.js ssr #4298

Open
@yay

Description

  1. Running the Modern.js SSR example in dev mode works great. But building the host app fails with Cannot find module 'remote/Image' or its corresponding type declarations., which can be fixed by casting the module name to any:

    const RemoteSSRComponent = createRemoteSSRComponent({
        // `npm run build` error: Cannot find module 'remote/Image' or its corresponding type declarations.
        loader: () => import("remote/Image" as any),

    Is there a better way to fix it?

  2. How does one get type hinting to work? If I add a prop to the Image component in the provider and try using it in the host app on the imported <RemoteSSRComponent />, I get a type error.

  3. Even though TypeScript doesn't recognize the prop, it does work and is passed to the remote Image component. However, every time I change the prop from the host -- e.g. a counter increment -- I see the page flash for a split second with "Loading..." shown in place of both components before they show up again. How do I prevent this from happening?

    const Index = () => {
        const [counter, setCounter] = React.useState(0);
        return (
    	    <div className="container-box">
    		    <button onClick={() => setCounter(counter + 1)}>+1</button>
    		    <RemoteSSRComponent counter={counter} />
    		    <DynamicRemoteSSRComponents />
    	    </div>
        );
    };
    Screen.Recording.2024-10-27.at.10.58.45.PM.mov
  4. Running all three apps in dev mode works just fine, but when previewing the production build locally with npm run serve the host fails with a CORS error:
    Screenshot 2024-10-27 at 10 02 37 PM
    Do you know how to fix this one? I struggled to find anything online and in Modern.js docs.

  5. When serving, navigating to http://localhost:3007/mf-manifest.json and http://localhost:3008/mf-manifest.json shows a blank page with only 404 text in it. Is this normal? It doesn't happen when running in dev mode.

  6. When running in dev mode, I sometimes see the following host app console errors: Screenshot 2024-10-27 at 10 30 15 PM
    Screenshot 2024-10-27 at 10 35 46 PM
    I haven't been able to consistently reproduce it. Do you know what might be causing them?

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions