I’m trying to implement dynamic loading to split the code per page to minimise the main bundle size cause the app is slow…
I tried to check on the forum by finding relevant posts and imitate the logic. But the solution is no different than what’s done before. Is there any other thing that needs to be done other than dynamically loading all my components that are assigned to routes?
This is an expensive route. This creates a new component everytime the route is rendered. Each re-render results to mount and unmount instead of just updating.
I don’t really see a difference with mine. They are identical almost.
Wonder if there’s any other trick that needs to be done for Meteor to handle this? I mean at the end client is served by the Meteor server and I would think that some configuration is necessary??
Without any error messages and knowing the structure of your app it is kinda hard to tell what ist going wrong.
One instance where those dynamic imports actually might fail is when trying to access the server on the local network without setting ROOT_URL. But then it logs all sorts of error messages:
What do you mean “no error whatsoever”, there should be plenty, e.g. that in Routes.jsx “CalendarContainer” is not even defined.
Also, I’m not sure how this should work, I’m not familiar with loadable, but I think the router doesn’t work because those container-files like ActivitiesContainer etc. are not returning React components. Sorry, I’m not using withTracker much.
Can you please confirm that lazy loading is not working?
In Chrome dev tools, press command-shift-p (Mac) or control-shift-p (Windows) to open the command menu. Select Show Coverage and click the Reload button and reload your home page, and Chrome will show you what has loaded.
Yeah, really there was no error - no difference to the state that it was before…
You’re right about the CalendarContainer - I missed it but it was still working. And I reckoned and defined it yesterday. Somehow the build system finds the component in the repo with the name of the file I think (if there is a file with the name of the component/var assigned to the route). I tested it by changing the name of the file and then it was a build error…
Actually you have a point! I have checked this before but it felt the same. Then I checked again and although it doesn’t seem like there’s a bundle per each page loading; the bundle I see is with the name of the initial page… Interesting!
Dear @flean I wonder how the Meteor’s built-in imports folder logic coexists with React’s lazy loading?
Because according to the docs at the page you sent, it feels like React’s lazy is redundant if we do this way of Meteor…?
Perhaps React brings the code splitting feature, whereas with Meteor imports folder we optimise the bundle?
Interesting that it starts to work, except that in only few pages I get a strange error:
Uncaught ReferenceError: Buffer is not defined
The common thing in those pages are that they are with route parameters like /page/:pageId but not all pages with params have error. Some of them do work.