Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New ssr option #247

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

trhinehart-godaddy
Copy link

Support optional ssr option to allow Loadable.preloadAll(true) to only preload modules that are needed for SSR.

@dobesv
Copy link

dobesv commented Feb 28, 2022

Our use case: we only have a small subset of components that are visible to SSR (e.g. publically available content). In our e2e tests, preloadAll() takes over 3 minutes as we have a lot of components. It would be really great if SSR could just load the components needed for that specific page being rendered.

@dobesv
Copy link

dobesv commented Mar 1, 2022

Although, I guess this solution requires us to just statically annotate the loadable components to indicate which ones to preload, whereas I would prefer a solution where there can be async rendering that loads the modules needed to render the page and nothing extra.

@trhinehart-godaddy
Copy link
Author

I would prefer a solution where there can be async rendering that loads the modules needed to render the page and nothing extra.

I have a solution in mind for that, however at this rate of feedback from @jamiebuilds I'm not sure if this is the right library to contribute to.

@dobesv
Copy link

dobesv commented Mar 1, 2022 via email

@ygs-code
Copy link

After I upgraded webpack 4 to wepack5 。The react-loadable plugin failed chunk.forEachModule is not a function.
code:

function buildManifest(compiler, compilation) {
var context = compiler.options.context;
var manifest = {};

compilation.chunks.forEach(function (chunk) {
chunk.files.forEach(function (file) {
chunk.forEachModule(function (module) {
var id = module.id;
var name = typeof module.libIdent === 'function' ? module.libIdent({ context: context }) : null;
var publicPath = url.resolve(compilation.outputOptions.publicPath || '', file);

    var currentModule = module;
    if (module.constructor.name === 'ConcatenatedModule') {
      currentModule = module.rootModule;
    }
    if (!manifest[currentModule.rawRequest]) {
      manifest[currentModule.rawRequest] = [];
    }

    manifest[currentModule.rawRequest].push({ id: id, name: name, file: file, publicPath: publicPath });
  });
});

});

return manifest;
}

How can I fix this bug and make it work?

Repository owner deleted a comment from ygs-code Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants