question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NextJS static pages with dynamic routes results in oversized server.js

See original GitHub issue

NextJS compilation target has been set to serverless. Fab builds without issues aside from extremely large server.js in resulting bundle. This prevents a deploy to Cloudflare as there is a 1MB worker size limit.

[…/input-nextjs] Finding all static HTML pages…
[…/input-nextjs] ✔ Found 88 static html pages.
[…/input-nextjs] Reusing NextJS renderer cache frontend/.fab/.cache/generated-nextjs-renderers.049a5d6.js
[…/input-nextjs] Finding all static assets
[…/input-nextjs] ✔ Found 238 assets.
[…/input-nextjs] Finding all public files
[…/input-nextjs]   ✔ android-chrome-192x192.png
[…/input-nextjs]   ✔ android-chrome-512x512.png
[…/input-nextjs]   ✔ apple-touch-icon.png
[…/input-nextjs]   ✔ browserconfig.xml
[…/input-nextjs]   ✔ favicon-16x16.png
[…/input-nextjs]   ✔ favicon-32x32.png
[…/input-nextjs]   ✔ favicon.ico
[…/input-nextjs]   ✔ mstile-144x144.png
[…/input-nextjs]   ✔ mstile-150x150.png
[…/input-nextjs]   ✔ mstile-310x150.png
[…/input-nextjs]   ✔ mstile-310x310.png
[…/input-nextjs]   ✔ mstile-70x70.png
[…/input-nextjs]   ✔ safari-pinned-tab.svg
[…/input-nextjs]   ✔ site.webmanifest
       [Builder] Building @fab/plugin-render-html:
[@fab/plugin-r…] Compiled 88 html files.
[…n-render-html] No fallback injected.
       [Builder] Building @fab/plugin-rewire-assets:
[@fab/plugin-r…] Inlining 117 assets.
[…rewire-assets] ✔ Done.
[…rewire-assets] Generating server code to rewire 135 assets.
[…rewire-assets] ✔ Done.
       [Builder] Build plugins completed in 3.21 seconds.
     [Typecheck] No Typescript plugins detected. Skipping.
      [Compiler] Compiling your server.js:
      [Compiler] Done in 8.61 seconds.
... snip ...
/server.js (12.9 MB)
     [Generator] Done in 0.17 seconds.
     [Generator] Zipping it up into a FAB:
     [Generator] Created fab.zip (9.38 MB) in 1.07 seconds

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
abdelhamid-attabycommented, Mar 14, 2021

Same issue here with nextjs 10.0.8 for a fresh project.

0reactions
jteschercommented, Mar 20, 2021

@geelen can reproduce with:

$ npx create-next-app
$ cd example-app
$ npx fab init
$ npm run build:fab
 ...
 [Generator] Created fab.zip (1.6 MB) in 0.21 seconds
Read more comments on GitHub >

github_iconTop Results From Across the Web

Dynamic Routes | Learn Next.js
In this lesson, you'll learn: How to statically generate pages with dynamic routes using getStaticPaths . How to write getStaticProps to fetch the...
Read more >
Static Site Generation with Next.js and TypeScript (Part IV)
Dynamic Routes Any page component that's defined within a file whose. ... Next.js will pre-render 100 static pages and routes.
Read more >
How to handle dynamic routes at the same level for Static and ...
The reason is that the site has static and SSR pages, the static ones ... Next.js uses a file-system based routing, if both...
Read more >
Dynamic Routing in Next.js - Andrew Aquino
js site to deliver smaller, more performant websites while still being able to statically generate or server-side render pages. The momentum ...
Read more >
Dynamic Next.js Routing Explained | Next.js Zero to Hero #2
On the topic of Next.js Routing, today we will be learning about how we can have an infinite number of pages rendered through...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found