Closed tmeasday closed 3 years ago
I pinged Tobias about this as he'll know the right way to do this.
Can you try https://github.com/tmeasday/storybook-skeleton/issues/19#issuecomment-855867404 with this one? I.e. port to import()
and make sure it's using version of webpack 5 with the fix with Tobias I made to support lazy compilation.
@bebraw in https://github.com/tmeasday/storybook-skeleton/issues/19#issuecomment-856718818 I confirmed it works with import()
thanks to your changes. Did you still want me to try here also?
@tmeasday Nope, that's enough. Now we know import()
works but require.context
doesn't. Let me comment to your comment.
Let's close this then, I think this approach is no longer relevant.
Based on https://github.com/tmeasday/storybook-skeleton/pull/12
The idea here is to work around the (apparent) lack of support for lazy require contexts with lazy compilation.
So instead:
So in a sense we are implementing our own lazy require context via a non-lazy require context and a bunch of lazy "proxy" imports.
I am guessing there is some way to achieve this without manually creating the
.stories.import.jsx
files, but instead getting webpack to do it via some special loader? I was thinking something like.stories.jsx
to a simple import proxy (i.e. like what we have inPages.stories.import.jsx
).import('./Pages.stories.jsx!no-proxy-loader')
)I got this idea from browsing through NextJS's source to see how they do the equivalent thing. I don't pretend to understand the nuance but I did see this:
https://github.com/vercel/next.js/blob/0af3b526408bae26d6b3f8cab75c4229998bf7cb/packages/next/build/webpack/loaders/next-client-pages-loader.ts#L24-L30