Giter Site home page Giter Site logo

Comments (14)

mcollina avatar mcollina commented on June 15, 2024

cc @fastify/typescript

from fastify-nextjs.

mcollina avatar mcollina commented on June 15, 2024

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.

from fastify-nextjs.

JoffrayBillon avatar JoffrayBillon commented on June 15, 2024

I have no idea how to fix this bug and after more research it looks like that behavior comes from the nextjs implementation... Should I open a ticket on their side, find a way to block the behavior on fastify nextjs or make the tsconfig setting works globally with thoses settings for fastify ?

from fastify-nextjs.

climba03003 avatar climba03003 commented on June 15, 2024

I believe it is a non-issue here. Next.js planned to modify the user setting, but it already provided the information that modified.

It doesn't means that the current template is in-compatible to this plugin but it requires you to justify yourself is the modification fit your needs.

from fastify-nextjs.

JoffrayBillon avatar JoffrayBillon commented on June 15, 2024

I not pretty sure I get what you mean, it's not a modifications that I ask it just don't work the way I showed in the description ^^'

from fastify-nextjs.

climba03003 avatar climba03003 commented on June 15, 2024

it just don't work the way I showed in the description

Then, a proper repro with all the code would be great.

from fastify-nextjs.

fozziethebeat avatar fozziethebeat commented on June 15, 2024

I'm running into the same problem. I created a typescript project with fastify generate . --lang=ts and tried to include @fastify/nextjs. I managed to get things to build but I can't get the nextjs pages to server via fastify.

A more robust demo repo of how to setup this up with the default typescript fastify project would be really helpful.

from fastify-nextjs.

fozziethebeat avatar fozziethebeat commented on June 15, 2024

Also, one maybe helpful clarification.

I modified by build step to be :

  "build": "tsc && next build",

With this change npm run start works correctly. npm run dev does not, it goes into an infinite loop with loading environment variables.

from fastify-nextjs.

fozziethebeat avatar fozziethebeat commented on June 15, 2024

I put together a demo repository that demonstrates this problem: https://github.com/fozziethebeat/fastify-nextjs-ts.

I created this by running

npx fastify generate fastify-nextjs-ts  --lang=ts
cd fastify-next-ts
npm install
npm i @fastify/nextjs next react react-dom

And then adding a basic src/pages/hello.tsx and updating src/app.ts with the lines recommended in the primary README.

I can confirm that npm run start works properly and includes the nextjs page. Running npm run dev goes into an infinite loop where the server never starts.

from fastify-nextjs.

fozziethebeat avatar fozziethebeat commented on June 15, 2024

To try and diagnose this further, I did the same steps but with the standard javascript Fastify template project. I stored that in this repo: https://github.com/fozziethebeat/fastify-nextjs-js

With the javascript template, npm run dev also hangs forever and never starts the server. It doesn't output anything so I can't quite tell what's going on. But I'm guessing fastify -w is what's triggering some underlying issue.

from fastify-nextjs.

climba03003 avatar climba03003 commented on June 15, 2024

fastify-cli is watching the CWD.
If something is triggering the changes, it is expected to restart forever.

I assume nextjs is actually always built the temp assets inside node_modules in dev mode.
And when it restart, the dev mode will clear the temp assets and rebuild again.
That's also why pre-built would works.
Maybe adding node_modules inside the ignore list would helps.

from fastify-nextjs.

fozziethebeat avatar fozziethebeat commented on June 15, 2024

I think that's the part I wasn't too familiar with (Still getting familiar with fastify).

Replacing the typescript dev:start command to be

    "dev:start": "fastify start --ignore-watch='node_modules .next .ts$' -w -l info -P dist/app.js"

did the trick. now npm run dev is working and picking up all the changes. I also had to set noEmit to false in tsconfig.

from fastify-nextjs.

climba03003 avatar climba03003 commented on June 15, 2024

I am going to close and pin this issue.
The solution already exists throughout the conversation.

from fastify-nextjs.

fozziethebeat avatar fozziethebeat commented on June 15, 2024

I updated my test typescript repo with the changes and things are now working smoothly for me. I'll freeze this demo repo so others that run into this problem can replicate the changes.

from fastify-nextjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.