2

I'm running a Server rendered react app and having an issue with Loadable.preloadReady() resolving instantly, and not preloading the available modules.

My SSR is perfectly fine with preloadAll(), it understands which components are required, loads their scripts and creates the SSR HTML fine.

When it switches to index.js with the same module array it doesn't work

EDIT: I can see that the READY_INITIALIZERS array is empty when it runs hence why nothing is loading:

Loadable.preloadReady = function () {
  return new Promise(function (resolve, reject) {
    // We always will resolve, errors should be handled within loading UIs.
    flushInitializers(READY_INITIALIZERS).then(resolve, resolve);
  });
};

I'm going to have a go at setting the webpack opt, the docs say this isn't necessary but it looks like the only reason it wouldn't populate the array:

ALL_INITIALIZERS.push(init);    
if (typeof opts.webpack === "function") {
    console.log("is a function");

    READY_INITIALIZERS.push(function () {
      if (isWebpackReady(opts.webpack)) {
            console.log("webpack is ready");

        return init();
      }
    });
}
Cœur
  • 37,241
  • 25
  • 195
  • 267
Tom Rowe
  • 449
  • 2
  • 10

1 Answers1

1

So I figured it out, the Babel Plugin wasn't working as expected:

enter image description here

For some reason this wasn't adding the webpack opt, and according to the FAQ's there are cases where it will break.

Manually adding it in myself fixed the problem

Tom Rowe
  • 449
  • 2
  • 10
  • 1
    Facing the exact same problem. Can you please enlighten us on how you debugged to see Babel Plugin wasn't working as expected? Also, "Manually adding it in myself fixed the problem", what did you manually add and where? – ujjwal Apr 14 '20 at 21:58
  • @Tom Rowe, can u please explain what did u added manually? I stuck with the same issue – Srigar Nov 08 '20 at 08:07