Comments (20)
Hey @piotr-oles, @eddyw, @johnnyreilly, @knaos, @vepanimas,
We've hit the same issue and spent some time to investigate it.
@vepanimas,
You're absolutely correct that we'll got it working if we move the logic from emit hook to an earlier stage of webpack compilation. According to the source code in webpack repo, we need to push errors in compilation object before or at the latest on shouldEmit
. This way noEmitOnErrors
property in webpack.config will work out of the box.
It turns out that shouldEmit
is not suitable for our case as it is SyncBailHook but we need AsyncSeriesHook
. However, afterCompile
seems the perfect solution as it is async
hook and is executed before shouldEmit
.
from fork-ts-checker-webpack-plugin.
Do you want to raise a speculative PR and let's see where it goes?
from fork-ts-checker-webpack-plugin.
Here is the PR - #337.
from fork-ts-checker-webpack-plugin.
Sorry I'm currently snowed @Fatme
I will try and take a look but it won't be immediately I'm afraid
from fork-ts-checker-webpack-plugin.
Hi! :)
This plugin only checks typing errors and reports errors. There is no emit at all. I think this issue should be opened in ts-loader repository :)
from fork-ts-checker-webpack-plugin.
Although I haven't checked recently, I believe ts-loader already supports this (I think some of our execution tests depend on it).
from fork-ts-checker-webpack-plugin.
I'd close the issue if there's no more to do
from fork-ts-checker-webpack-plugin.
Yes, thank you. @johnnyreilly ts-loader has it working. But I want to use it with happypack, and then the emit prevention won't work.
from fork-ts-checker-webpack-plugin.
@knaos I just realized what you want to achieve and why it won't work. If you are using transpileOnly mode, ts-loader doesn't know about semantic errors so it's not possible to block emit. The information about errors is in the fork-ts-checker-webpack-plugin.
Support for this setting would be possible only in the "async: false" mode, where type-checking and emitting is synchronized. There is fork-ts-checker-emit
webpack's hook - ts-loader could listen on that hook and block emit if there would be errors.
@johnnyreilly what do you think about that?
from fork-ts-checker-webpack-plugin.
Yup - I'd be open to a PR on that 👍
from fork-ts-checker-webpack-plugin.
@johnnyreilly I'm curious about the status of this issue. Is it now possible to do so?
from fork-ts-checker-webpack-plugin.
Uh I don't think anything has been implemented related to this so I guess not.. don't actually know
from fork-ts-checker-webpack-plugin.
@johnnyreilly I'll try to implement it on ts-loader
and open a PR. It will take me some time, because I'm actually hating the hacky way I'm dealing with this right now.
Actually, I was thinking about building a new loader to have accept a function in options to listen to some hooks and decide if it should allow emitting files or not. Kind of:
{ loader: 'some-loader', options: { listen: (done, fail) => { /* decide here if it should allow emitting or not */ } } }
So it could work as a general solution rather than a solution only for ts-loader
. Do you know if something like this exists? If so, I won't need to code it haha
from fork-ts-checker-webpack-plugin.
I don't know - now's your chance!
from fork-ts-checker-webpack-plugin.
@johnnyreilly got it working!. Listening to fork-ts-checker-receive
hook instead before fork-ts-checker-emit
is reached, so it's possible to tell webpack not to emit on error. I will share it tomorrow, now the code is a mess.
from fork-ts-checker-webpack-plugin.
Great!
from fork-ts-checker-webpack-plugin.
@johnnyreilly I wrote what I was using as a webpack
loader. It's a bit hacky but works:
https://github.com/eddyw/forktschecker-hook-loader
Maybe something like it could be implemented inside fork-ts-checker-webpack-plugin
. I mean, if this package could ship also a loader.
Anyway, it works with my current configuration in build and watch mode. The first build is usually slower in --watch
, then it's cached and every other rebuild after it is faster. Also, I actually get better results with async: false
(threads: 2, happypack threads: 6)
from fork-ts-checker-webpack-plugin.
It's been some time. I figured how to make the compiler work with HappyPack
or thread-loader
without killing Type Checking and also allowing to noEmitOnError
..
https://github.com/eddyw/owlpkg-typescript-loader
I wrote the loader from scratch. First as part of an experiment, then it turned out to work fairly well. tslint
is also able to run within the loader with HappyPack, ... and cache
from fork-ts-checker-webpack-plugin.
If that line will be invoked before shouldEmit
webpack hook, we'll got it working. That's how the default NoEmitOnErrorsPlugin
works, it checks compilation.errors
on shouldEmit
and returns false if they exist.
So if we could move this code to an earlier stage (ex. afterCompile or even shouldEmit), it would possibly fix that issue. @johnnyreilly
from fork-ts-checker-webpack-plugin.
Did you have the chance to take a look at the PR?
from fork-ts-checker-webpack-plugin.
Related Issues (20)
- Configuration has an unknown property 'resolveTypeReferenceDirectiveModule'. HOT 1
- Incremental mode is not working in webpack devServer
- Solution Builder should set reportDiagnostic on build mode
- error: debug failure. false expression HOT 3
- Update `minimatch` to Latest and Update Import
- Uncaught Exception in yaml - A dependency update is required for `cosmiconfig`
- Use specific lerna module tsconfig on type checking HOT 2
- Emitted files should be added as assets to the compilation HOT 5
- Getting ERROR in compiler.getInfrastructureLogger is not a function HOT 2
- Issues when importing plugin in TypeScript (`index.d.ts` vs `plugin.d.ts`)
- TypeError: config.logger.log is not a function HOT 3
- extends should be an array in typescript 5.0 HOT 2
- Github Actions module 'Ajv' not found HOT 1
- overlay: false not working HOT 1
- Does it respect @ts-nocheck ? HOT 1
- Performance loss between latest and v6.5.3
- class IssueWebpackError extends webpack_1.default.WebpackError when run webpack build
- Type check is slow in incremental mode on watch mode's subsequent runs (not on the first run).
- Fork-ts-checker >= 6 hangs on windows
- `TypeError: Cannot set property mark of #<Object> which has only a getter` HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fork-ts-checker-webpack-plugin.