ignore git ignored files by default
I had a config like this on one react-native project:
documents: ['**/*.gql']
this ran like 40 seconds when trying to generate. Why? Because it is traversing whole node_modules. So I would like to have 2 new features:
- ignore git ignored files by default
- When I have too many files, emit a warning to stdout and recommend to limit the glob expression
Sometimes an input can be the generated files from a different tool or it can be under node_modules etc. I think you should always avoid to have a "broad" expression. If you have a proper file structure, I think it can be something like documents: ['src/pages/**/graphql/*.gql'].
Also "too many" depends on many things. "Too many" can be 100 for a setup/project, or 1000 for another. Not sure about the other option.
I was thinking of putting the limit somewhere around 5k mark. Basicaly I would expect code gen to always finish within like 10-15 seconds max and unfortunately node/filesystem/JS is just too slow to churn through that much in a reasonable time.
My project where I bumped into this has 11500 ts files in node_modules.
Counted that with ls node_modules/**/*.ts
Also we would have a flag to silent the warning.
Sometimes an input can be the generated files from a different tool or it can be under node_modules etc
Fair point with generated code, that can be gitignored, but I don't agree with node_modules.
You should never generate stuff in there IMHO. I know there are a few tools that do this-for example @prisma. I still hate it. Depoying prisma to a lambda is a mind numbing, thanks to the fact that your ORM client type defs live outside the git repo by default. You end up writing stuff like this:
await cpy(['../node_modules/@prisma/client/**'], './dist/node_modules', {
parents: true
})
await cpy(['../node_modules/prisma/**'], './dist/node_modules', {
parents: true,
ignore: [
'../node_modules/prisma/libquery_engine-debian-openssl-3.0.x.so.node'
]
})
just to get your lambda build to work.
I didn't mean to generate files into node_modules. I mean to generate files by using some files in node_modules as an input.
You can basically use narrow glob expressions instead of **/*.ts :)
Side note - I lost some time today to the surprise inclusion of node_modules/.
Given both tsc and eslint automatically exclude it, it would be nice for this program to do the same thing.
Edit: I filed #8434, which is a much narrower change that would also address this concern.