wmill sync not bundling relative imports
I have a "utils" class that has its own dependencies. I import this class in a "script".
I would expect this to be bundled when using "wmill sync push" as per the docs, but the script gets "--- BUN INSTALL ---
error: Failed to find relative import at ...."
In the VSCode plugin, I can observe the same error, but if I tick the "bundle relative paths for preview" box, the script works as expected, and the dependencies get bundled. If i run "bun build" on the script, I can also observe a correct and expected bundle being generated.
No matter what I do I cant get the dependencies to resolve outside of my own local "bun build" or the VSCode plugin with "bundle relative imports" enabled.
Am I wrong that using "wmill sync push" should build a bundle with dependencies included?
Ive experimented with different values in "includes" and "excludes". The dependency is a Prisma Client generated with ESM and if I dont have it in "excludes", "wmill sync push" generates 100's of scripts + yamls + lock files, one for each single individual file in the generated client and any dependency it has, that just doesnt seem right...? Is it the case that you need to create "scripts" for every single file that is a part of a relatively imported dependency tree? Some of my upcoming dependencies have 1000+ files, what is the intended workflow for relative imports?
I just want the script I push with "windmill sync push" to be the same as when I bundle locally with esbuild or the VSCode extension feature, is that not possible?
This line in the docs is very confusing at https://www.windmill.dev/docs/advanced/dependencies_in_typescript#bundle-per-script-built-by-cli:
"Windmill CLI, it is done automatically on wmill sync push for any script that falls in the patterns of includes and excludes as defined by the wmill.yaml (in the codebase field)."
I dont have any codebases, just my windmill code and scripts in same path, with stuff i want to import relateively across several scripts...
Dependencies in TypeScript | Windmill
In Windmill standard mode, dependencies in TypeScript are handled directly within their scripts without the need to manage separate dependency files.
4 Replies
I dont have any codebases, just my windmill code and scripts in same path, with stuff i want to import relateively across several scripts...yes that paragraph should be improved and have an example of what we mean by the codebase field. But yes you're correct, you need to push individual "scripts" for all the relative imports otherwise windmill can't be aware of them. The only alternative is to use codebase & bundles. We may allow later to push bundle in "esbuild mode" like vscode but it destroys the ability to edit those in the UI which is very confusing as well.
for those that come after, I've solved it by doing a custom esbuild step to package the deps as a single ts file to keep the windmill ui in a sane state without thousands of scripts that are unusable... 🙂
@Nacki I see you've played a bit of expedition 33 🇫🇷 It's pretty much how it could work in the mode i've mentionned above. We could indeed just treat it as a bit text file to execute and save as a script.
but I think you will have some issues with pull no ?
yeah expedition 33 is definitely up there for one of the greatest of all time in my opinion! 🙂 I'm not sure about the pull issues, I've not come across a scenario where I've needed to use it yet, as per the other help thread I started I can't get generate + sync to work properly without diffing every time but everything seems to be working fine anyway so right now I'm focused on the features to do.. 🙂