chapter-three / next-drupal

Next.js for Drupal has everything you need to build a next-generation front-end for your Drupal site: SSG, SSR, and ISR, Multi-site, Authentication, Webforms, Search API, I18n and Preview mode (works with JSON:API and GraphQL).
https://next-drupal.org
MIT License
606 stars 172 forks source link

syncDrupalPreviewRoutes bundle size #397

Open dottodot opened 1 year ago

dottodot commented 1 year ago

I've noticed that if I add syncDrupalPreviewRoutes in my app.tsx my bundle size is increased by about 100kb however if I just include the function in my app.tsx sync still functions

function syncDrupalPreviewRoutes(path) {
  if (window && window.top !== window.self) {
    window.parent.postMessage(
      { type: 'NEXT_DRUPAL_ROUTE_SYNC', path },
      process.env.NEXT_PUBLIC_DRUPAL_BASE_URL
    );
  }
}

Router.events.on('routeChangeStart', function (path) {
  syncDrupalPreviewRoutes(path);
});
shadcn commented 1 year ago

The syncDrupalPreviewRoutes is still part of the "legacy" code that was created before DrupalClient. I believe this is being bundled as part of.

Copying it to your _app.tsx is perfectly fine. (This is what I do as well.

We'll deprecate all the non-client code in 2.0 and move this code as part of docs.