Karthi
Karthi

Reputation: 3489

Slow page build time in development with Next.js and TypeScript

Created a website using next.js with both backend and frontend in one project.In production it takes so much of time to load a webpage.Next version is 9.3.0. this is my script.using of scss effects loading time

package.json

"scripts": {
    "dev": "ts-node --compiler-options=\"{\\\"module\\\": \\\"commonjs\\\"}\" server/server.ts",
    "build": "next build",
    "start": "NODE_ENV=production 'ts-node' --compiler-options=\"{\\\"module\\\": \\\"commonjs\\\"}\" server/server.ts"
}

Upvotes: 0

Views: 7975

Answers (2)

Chukwuemeka Maduekwe
Chukwuemeka Maduekwe

Reputation: 8546

  1. https://github.com/vercel/next.js/issues/12797#issuecomment-629321790
  2. https://github.com/vercel/next.js/issues/12797#issuecomment-660225689

For those curious, this was caused by Windows Defender. Windows Defender was delaying the HMR (to do a scan) because our emitted JavaScript files contained the word eval! That's why macOS was unaffected.

Upvotes: 1

felixmosh
felixmosh

Reputation: 35553

I guess that you are starting your production app using npm run start. From it, it looks like you are running ts-node on production (which compiles TS on the fly).

It is better to compile server.ts on build step using typescript into dist or something like this, then run node on a js result inside dist folder.

Upvotes: 2

Related Questions