-
-
Notifications
You must be signed in to change notification settings - Fork 624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Webpack Encore typescript livereload weird behavior #3799
Comments
The issue report was for Chromium. When using Firefox, the browser does not refresh and is stuck on "Unable to connect". It looks like the browser is refreshed before Encore's typescript compiler has time to rebuild the frontend code. In dev-tools I see failing request to http://localhost:3333/ with no reponse. |
Hey @romanzy-1612! 👋🏻 Could you please paste the content of your Your Adonis server is restarting whenever you change one of your frontend files. This can be configured inside the |
I think the server is restarting because the frontend codebase is in TypeScript and the same I think, the frontend tsconfig has to be separate and then you should ignore the frontend files inside the backend |
When ace generates webpack config, the following options toward the end:
Here is the .adonisjsrc.json
|
Ive created a repo demonstrating this behavior and my attempts at configuring sharing of code/types between server and client. Console output when reloading:
I will keep experimenting on it. Once this issue is resolved, Webpack Encore typescript support should be added to the docs. Also guides on how to structure sub-applications would be appreciated. Also it would be nice for ace to scaffold this automatically. I would like to help to make this happen. Thanks! |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I was having this issue and I think I've solved it just as you described it here. I've created a new TypeScript config at {
"extends": "adonis-preset-ts/tsconfig.json",
"include": ["**/*"],
"compilerOptions": {
"outDir": "build",
"rootDir": "./",
"sourceMap": true
}
} And then modified the root ...
"exclude": ["node_modules", "build", "resources"],
... So far all seems to work as expected. Typescript frontend files are live reloaded without a server restart and the backend restarts when backend files are changed. I'm not sharing types, etc between frontend and backend yet, so not sure if that would be a problem. EDIT: I've also had to create a new eslint config file at export default {
parserOptions: {
project: './tsconfig.json',
},
} |
Video example
Sorry for low quality, its best I could do
Package version
Node.js and npm version
node v16.15.1, npm 8.11.0
Sample Code (to reproduce the issue)
I have followed the tutorial to configure views and Webpack Encore. This only happens when typescript files are modified. Changing templates or css works as expected. The only change in the webpack config is
Encore.addEntry('app', './resources/js/app.js')
to
Encore.addEntry('app', './resources/js/app.ts').enableTypeScriptLoader();
The resource is included in layout with
@entryPointScripts('app')
.I need to enable typescript in my app, and I think this is a common use-case. I am not sure if this is encore or integration issue, but I feel that it is important to report this behavior for the latest build of adonisjs.
Thank you so much for this framework! The docs are amazing, cant wait to rewrite my backend 😁
The text was updated successfully, but these errors were encountered: