isaacs/minimatch

Webpack build is failing since 7.1.1

UnchartedBull opened this issue · 4 comments

Hi,

I'm having some problems with using minimatch within an Angular app (thus I do not have access to the node variables and such). This was not a problem for minimatch before probably this commit 58917fe.

With the line change here:

platform?: typeof process.platform
this now results in an error when building:

Error: node_modules/minimatch/dist/cjs/index.d.ts:63:22 - error TS2591: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig.

63     platform: typeof process.platform;
                        ~~~~~~~

Would be great if this could be optional similar to how the other node dependent code is handled.

isaacs commented

Have you tried doing what the error message says, adding @types/node as a dev dep and putting 'node' in the types field in your tsconfig?

I can unroll the type, but it does work fine in a non-node environment, it just needs the type at compile time to resolve the reference.

Hi, thanks for the quick response! :) yes I tried that: installed the types and added node as a type in the tsconfig. Weirdly enough it doesn't work and still throws the same error. I suppose this could be fixed with some work to the tsconfig though.

I'd prefer if I don't need to add the node type to the tsconfig though, since then all node dependent code will compile fine. The errors will then only come up in a browser when the node functionality is not available.

So if possible it would be super nice to be able to continue using minimatch without relying on node.

Thanks for fixing this so quickly. It seems like this was the only occurrence of process.platform:

type Platform = typeof process.platform

platform: typeof process.platform

The build is still failing with the same error:

Error: node_modules/minimatch/dist/cjs/index.d.ts:20:23 - error TS2591: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig.

20     platform?: typeof process.platform;
                         ~~~~~~~


Error: node_modules/minimatch/dist/cjs/index.d.ts:67:22 - error TS2591: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig.

67     platform: typeof process.platform;
                        ~~~~~~~

Sorry for bugging you again.

isaacs commented

Ok, should work now. Got rid of all references to NodeJS.Platform type on v7 and v8 latest publishes.