Add clear and explicit way to exclude files from bundle
I found this post but making a new thread specifically because this is a feature request
I keep getting the need to exclude bundled files from time to time. In particular, I have a file with testing helpers that fails to compile because
convex-test
uses crypto
:
I renamed the file lib/test.nobundle.ts
to work around it.
While the heuristic of "exclude if multiple dots in path" accounts for a lot, it feels a little... flimsy? or something like that
For example, you might want a file that has multiple dots in the path to be included; I tried to name a file something.node.ts
as a companion to something.ts
which includes the node actions, while the main file just has queries and mutations. I was confused for a hot minute why that wasn't included. I worked around it, but at the time, I didn't realize this rule was the cause.
I would prefer one of these alternatives, in order of preference:
- "exclude"
or "ignore"
config in convex.json
- a filename convention, like I did here
- "use nobundle"
or "use exclude"
or some other kind of file directive
Specifically with the file config, it would have the default of excluding .test.
files or whatever else, and maybe you could add a special sigil for that, which I've seen in some config formats:
10 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
Totally, I think we should have one or boht of
- some standard convention like a directory or a file extension or a directive that works with no configuration (what two dots is today, but that one is flimsy)
- a configurable pattern, configured via convex.json
convex.json is where bundling configuration is going to go so that's a natural spot, e.g. custom esbuild plugins
@Tom Can we exclude when there's two dots in the filename?
Just worked for my usecase.
Yeah two dots are already excluded
Sweet
@Tom is there a way to resolve the issue where convex fails to compile because
convex-test
uses crypto
?Tom may follow on with a better solution, but if you're blocked, you can change the name of the file(s) using convex-test to have multiple dots as MapleLeaf did above, eg., myFile.nobundle.ts (or as I do, myFile.test.ts).
Adding .test is what I'd do, you don't want to deploy these files as backend endpoints.
@Tom I already do what you said but I still get the
crypto
error message.
It looks like you're importing convex-test from a file that isn't a .test.ts file