Giter VIP home page Giter VIP logo

Comments (20)

Fatme avatar Fatme commented on May 21, 2024 1

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.

johnnyreilly avatar johnnyreilly commented on May 21, 2024 1

Do you want to raise a speculative PR and let's see where it goes?

from fork-ts-checker-webpack-plugin.

Fatme avatar Fatme commented on May 21, 2024 1

@johnnyreilly,

Here is the PR - #337.

from fork-ts-checker-webpack-plugin.

johnnyreilly avatar johnnyreilly commented on May 21, 2024 1

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.

piotr-oles avatar piotr-oles commented on May 21, 2024

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.

johnnyreilly avatar johnnyreilly commented on May 21, 2024

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.

johnnyreilly avatar johnnyreilly commented on May 21, 2024

I'd close the issue if there's no more to do

from fork-ts-checker-webpack-plugin.

knaos avatar knaos commented on May 21, 2024

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.

piotr-oles avatar piotr-oles commented on May 21, 2024

@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.

johnnyreilly avatar johnnyreilly commented on May 21, 2024

Yup - I'd be open to a PR on that 👍

from fork-ts-checker-webpack-plugin.

eddyw avatar eddyw commented on May 21, 2024

@johnnyreilly I'm curious about the status of this issue. Is it now possible to do so?

from fork-ts-checker-webpack-plugin.

johnnyreilly avatar johnnyreilly commented on May 21, 2024

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.

eddyw avatar eddyw commented on May 21, 2024

@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.

johnnyreilly avatar johnnyreilly commented on May 21, 2024

I don't know - now's your chance!

from fork-ts-checker-webpack-plugin.

eddyw avatar eddyw commented on May 21, 2024

@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.

johnnyreilly avatar johnnyreilly commented on May 21, 2024

Great!

from fork-ts-checker-webpack-plugin.

eddyw avatar eddyw commented on May 21, 2024

@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.

eddyw avatar eddyw commented on May 21, 2024

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.

vepanimas avatar vepanimas commented on May 21, 2024

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.

Fatme avatar Fatme commented on May 21, 2024

@johnnyreilly,

Did you have the chance to take a look at the PR?

from fork-ts-checker-webpack-plugin.

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.