Post

Is there a way to ensure certain files that aren't in the app tree make it into the @svelte.dev Kit build output? I have a background process that pulls a file from a relative import. Works fine in dev. Can't find the file in prod :/

Sure. Im deploying to a node server because I need background tasks to run. Using node-cron to run these, and there's a feature where tasks can run as background processes if you provide a file path. As such, node-cron tries to import that file, but it doesn't exist in the build output

If, however, i import the js export and register it with node-cron, it will exist in the AST at build time, and be brought over. The issue is that the file structure changes between Dev and build times such that node-cron cannot locate the file to import.

0 reposts0 likes

Currently, I'm getting around this issue by registering the js module, rather than the file location. This doesn't support background processes, but it's a decent stop gap. I don't think node is the right place for background tasks anyway. But off the main process would be ideal.

That's a good idea. I had landed on something somewhat similar by moving all the cron tasks to a completely separate app, rather than shoehorning them into svelte. In any case, that read function was a great tip. Thanks for all these ideas