Quramy / loadable-ts-transformer

TypeScript custom transformer for loadable-components SSR

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

loadable component options not available on server

jkkjonah opened this issue · comments

First of all, thanks for your effort to put together this package. I'm currently using it in a project and it mostly works, however I noticed that for whatever reason the loadable option argument does not work. When I step through the code in the debugger, the loadable function all always executes with options undefined. For example

// mycomponent.tsx
export const MyComponent = (props) => <div>Foo</div>;
// mycontainer.tsx
import loadable from '@loadable/component';
const MyComponent = loadable(
    () => import('./mycomponent'), 
    {resolveComponent: m => m.MyComponent}
);

When I trigger that codepath on the server, I get the following error: TypeError: Cannot convert undefined or null to object
the trace points at the module resolution code which should use the custom logic if provided, but always uses the default. Debugging shows that at the time of resolution, the option object is undefined, despite the fact that is is defined in the component code