-
-
Notifications
You must be signed in to change notification settings - Fork 243
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
types.ts files do not trigger rebuild in webpack-dev-server #36
Comments
I've been working with @abirmingham and have seen this myself. Do you have any ideas @piotr-oles? Thanks! |
This plugin has no influence to the build watcher. You can comment out plugin and build should not trigger after |
Hi @piotr-oles, thanks for responding! The issue is not phrased very clearly. Let me share my experience: If tweaking a file which is interfaces only, fork-ts-checker-webpack-plugin does not seem to notice the change and perform checking again. It's like it only watches files that would produce JavaScript if TSC was pointed at them. Have you any ideas why this might be? |
To be clear: it's that fork-ts-checker-webpack-plugin does not seem to detect changes to interface only files. You'd imagine that it would, as a change to an interface could change a successful type check into a failed one. (Hope that makes sense) |
fork-ts-checker-webpack-plugin is hooked to the compilation run and if compilation doesn't run after file change, it will not run checker. I think it doesn't run because of some optimization in loader in transpileOnly mode - there is no need to recompile project if only typings have been changed. Maybe it's bad design to rely on compilation run in async mode - maybe I should make it totally async... It can check files that are not a part of webpack's compilation so maybe it will be better behavior :) |
Thanks for the clarification @piotr-oles. It would be good if we could resolve this - I'm open to making changes in ts-loader if that would help. Though what you've suggested might be the better design choice... In the meantime is it worth noting this down on the readme as a known issue for now? Happy to submit a docs PR.... I guess an ugly workaround which might / might not work would be to have some actual JavaScript in interface only files to ensure that file changes always trigger compilation. Sounds like a terrible hack. Not recommended... |
Always happy to see PR :) |
Thanks for the replies, @johnnyreilly and @piotr-oles! I don't have much experience with webpack plugin development, but if I'm reading awesome-ts-loader correct, it appears that they hook into 'after-compile' here, and add dependencies in that function here. Should fork-ts-checker-webpack-plugin do the same? Apologies if I'm misinterpreting the issue! |
Completely by the by but for interest you can see the corresponding code in ts-loader here and here. That said, I think @piotr-oles is proposing not depending on ts-loader's compilation (I think) |
That makes sense. @piotr-oles if you have a suggested implementation I can take a shot at it and create a PR :) |
I've made the suggested docs PR now.
Like @abirmingham I'd be happy to help out on a suggested implementation to fix this problem. Do you have an idea that you'd like to try? I haven't looked in depth at the reasons why this is happening but I'd speculate that this is to do with webpack seeing that the output from ts-loader hasn't changed ( @sokra - if you have a moment, is that a reasonable assumption of webpack behaviour on my part? |
There is an interesting proposal in TypeScript project (thanks @johnnyreilly for cc ;) ): microsoft/TypeScript#17493 so I think the best idea is to wait for it and implement when it will be ready :) |
I'm glad you noticed @piotr-oles - I'm never too sure if everyone sees their cc's. 🌻
I think you may be right; do feel free to pitch in on the comment thread. Your input will be very valuable to them and the TypeScript team are friendly and receptive people! On another matter, from what @TheLarkInn has said about "deprecated accessing of
And doing "2" involves hooking into webpack internals. I don't have the details but it sounds like the only way to do "2" in a webpack friendly way will be through moving type checking into a plugin (just as fork-ts-checker-webpack-plugin does) and only to run ts-loader in My understanding may not be 100% on this and so I'd appreciate anyone who can set me straight doing so. cc @jbrantly |
How does this makes all of them consistent? Btw this issue is already solvable when you pass all type checked files back to webpack, so webpack can detect changes on this file and trigger another build. But this will work only for non-async mode. |
With microsoft/TypeScript#17493 now being resolved, is there a chance of seeing a fix for this now? |
Would really love seeing a fix for this :) pushes politely |
|
@piecyk that's exciting, what version is it working on? Where/when was it fixed? |
@abirmingham hard to say, just testing
Basic changing ts file with only type triggers rebuild, and correct type diagnostic to be presented. |
If it's fixed that's awesome! I believe there's been a couple of PRs along the way that I have not been involved with. Maybe it was one of them that resolved it? |
@piecyk hm..., the same versions of packages., however, changing ts(x) files which have only types definitions does not trigger a rebuild. |
@johnnyreilly @a-tarasyuk @abirmingham false alarm Guys, it's not working, tested on repo from scratch... It looks like on my more complex repo that mislead me something is triggering the watch to run... |
Bump :) |
Thank you @oviava for the comment about |
This flag doesn't seem to help me :( .babelrc.jsmodule.exports = api => {
const isTest = api.env('test')
return {
"presets": [
"@babel/preset-typescript",
"@babel/preset-react",
[
"@babel/preset-env",
isTest ? { // babel needs to target node for jest tests instead of what's in the browserslist in package.json
"useBuiltIns": "entry",
"corejs": "3",
"targets": {
"node": "current"
}
} : {
"useBuiltIns": "entry",
"corejs": "3"
}
]
],
"plugins": [
"@babel/plugin-proposal-class-properties",
"babel-plugin-styled-components"
]
}
} tsconfig.json{
"compilerOptions": {
"baseUrl": "src",
"outDir": "./dist/",
"noImplicitAny": false,
"module": "es6",
"moduleResolution": "Node",
"target": "es5",
"jsx": "react",
"allowJs": true,
"sourceMap": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"noEmit": true,
"importsNotUsedAsValues": "preserve"
}
} webpack.config.js...
new ForkTsCheckerWebpackPlugin({
typescript: {
diagnosticOptions: {
semantic: true,
syntactic: true,
},
},
}),
... |
I reopened this as @sangeeth96 opened an issue which seems to be this. It could be worth trying the |
It seems like an issue with the |
Thanks @piotr-oles - in one of those "no buses come and then 3 arrive at once" things we've had a second person raise this issue. I've closed it as a duplicate and linked to this |
Same issue here. I use graphql-code-generator to create an |
A little more info: I'm using In both v4 and v5, updating a In v5, re-saving the |
Current relevant dependencies:
Checking up on whether there is any progress on this issue? Webpack is not recompiling when a type (e.g, interface) is modified and then saved. This occurred after upgrading |
The same problem:
Rolling fork-ts-checker-webpack-plugin back to 4.1.6 resolves the problem. |
I'm working on a fix, there is progress :) Unfortunately, I'm not able to give you time frame when it will be fixed |
I've released a new version on the alpha channel - ’6.0.0-alpha.1’. It should detect changes in type-only files without additional TypeScript/Babel configuration :) |
Nice work! |
I'm not sure if this case is unique, but we use |
@bhollis Would you be able to create a small reproduction repository? |
Here you go! I hope it's minimal enough: https://github.com/bhollis/fork-ts-checker-repro |
@bhollis Your reproduction repo uses |
Fantastic! For future reference, what was breaking it for us was this line, which was once recommended as part of the new webpack.WatchIgnorePlugin([/scss\.d\.ts$/]), That was disabling Webpack's watcher which meant your fix wasn't able to run. |
I'm closing this as it seems to be resolved with the 6.0.0 release :) |
First - thanks for the plugin and associated speed improvements!
One issue I've seen is that webpack-dev-server will not rebuild when a change is made in a source file that will not emit js. For example, if I have a types.js file that exports nothing but types/interfaces, and I make a change to that file that introduces a type error, I will not see a warning for that error until I change a file that does emit js. Here is an example:
Changes to mainEntry.ts will trigger a rebuild, but updating types.ts with
name:number
does not trigger a rebuild, and the error is unnoticed.Relevant webpack config is as follows:
The text was updated successfully, but these errors were encountered: