eidellev / inertiajs-adonisjs

280 stars 17 forks source link

Adonis watch re-starting http server #97

Closed andreasbergqvist closed 1 year ago

andreasbergqvist commented 1 year ago

I've tried to find information about the problem I have but have not been able to find an answer.

Not really the fault of this library... But maybe someone here has solved it (better than me).

I have an Adonis site with Inertia and it works as expected. But when I save a file in my resources/js folder, the Adonis web server also restarts. Since it's a TypeScript file that has changed. And since also the browser reloads, it returns a blank page.

I notice that the file watcher triggers whenever a file is changed: https://github.com/adonisjs/assembler/blob/develop/src/DevServer/index.ts#L299

I'm not sure exactly how this works but managed to patch the DevServer to check if the files exist in "metaFiles" .adonisrc.json and don't restart the server if it has that setting. But this seems like a "hacky" solution...

eidellev commented 1 year ago

Hi @andreasbergqvist !

I've also run into this issue in the past. The way I solved this is by adding the resources directory to the exclude clause in my tsconfig.json. You probably need a dedicated tsconfig.json for your client code anyways.

 "exclude": ["node_modules", "build", "resources"]

Let me know if it didn't work for you

andreasbergqvist commented 1 year ago

I tested it out but got stuck when I had two separate tsconfig.json for the backend and client and wanted to share code (like DTOs or interfaces). I got it working at last but then eslint failed and after some time when I couldn't get eslint working as I wanted, I turned back to my "patch the node_modules solution".

I read and did as mentioned in the last comment at: https://github.com/adonisjs/core/issues/3799

If there is a preferred way of setting up Adonis with Inertia regarding tsconfig.json and eslint I think it would be great if it could be documented somehow.