TypeStrong / fork-ts-checker-webpack-plugin

Webpack plugin that runs typescript type checker on a separate process.
MIT License
1.93k stars 238 forks source link

fix: #775 node_modules not ignored. #802

Closed annitya closed 1 year ago

annitya commented 1 year ago

The logic has been taken form this post.

On windows the "node_modules"-entry in the excluded array is absolute and looks something like this: "c:\\users\\..". The path that is tested is in unix-format. The string-test startsWith fails to account for this.

I grabbed the code from StackOverflow, tested it directly by editing the compiled version of this plugin, modified it and added it here. It's late and I'm tired, so take a few extra looks at the logic. Our app would hang for about 30s, seemingly doing nothing after webpack was done compiling. It now starts instantly.

annitya commented 1 year ago

'aight! I fixed it up a little.

piotr-oles commented 1 year ago

Looks like it doesn't work on linux and macos :)

annitya commented 1 year ago

Looks like it doesn't work on linux and macos :)

Can't even trust StackOverFlow? What's the world coming to... I'll take a look!

piotr-oles commented 1 year ago

Yeah, AFAIK, path behavior is platform specific unless you use path.win32 or path.posix

annitya commented 1 year ago

I modified the tests to use the platform-specific implementation. I reasoned that if you are matching against win32-paths when on Unix, something else entirely has gone majorly wrong.

github-actions[bot] commented 1 year ago

:tada: This PR is included in version 8.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

annitya commented 1 year ago

Thanks for merging!

Tested the changes today. At first it didn't work, but then I found out why. TypeScript-exclude supports glob-patterns, but the custom-matcher in fork-ts-checker-webpack-plugin does not. The logic is complex and while it's tempting to reuse, rather than recreate, the API is marked as internal.

On a positive note, globs never worked, so it's not worse than before. Thoughts?