sdk-typescript icon indicating copy to clipboard operation
sdk-typescript copied to clipboard

Bundle using Vite

Open gajus opened this issue 2 years ago • 5 comments

I am sure you are already familiar with Vite https://vitejs.dev/

Webpack is great, but it is pretty slow and waiting 10 seconds for bundle to complete can become a nuisance.

It would be really nice to be able to bundle using Vite.

gajus avatar Nov 03 '23 17:11 gajus

I'm using esbuild and building for production only takes 0.6s (workflows.js and worker.js), no need to use the built-in webpack bundling. For dev/watch mode, I'm using https://github.com/esbuild-kit/tsx.

Bildschirmfoto 2023-11-05 um 00 58 44

I agree it would be cool if temporal moved to a faster build-in bundler (vite or esbuild). Think cloudflare wrangler and aws sdk have gone for esbuild by default.

bkniffler avatar Nov 05 '23 00:11 bkniffler

I'm using esbuild and building for production only takes 0.6s (workflows.js and worker.js), no need to use the built-in webpack bundling.

Can you elaborate how?

gajus avatar Nov 05 '23 03:11 gajus

Build script js file building index.js and workflows.js via esbuild https://gist.github.com/bkniffler/9fe91f6a1a8ba05f1eeb993441c7cdb5

Dev NPM script using tsx to run worker NODE_NO_WARNINGS=1 tsx watch src/index.ts

If I've some time, I'd be happy to provide a simple sample project.

bkniffler avatar Nov 05 '23 09:11 bkniffler

@bkniffler If you have time to create a sample project, I would definitely appreciate it.

baileywickham avatar Nov 08 '23 19:11 baileywickham

@bkniffler AFAICT you still need the sdk’s webpack bundler after you generate your js bundle with esbuild. How are you instantiating your worker?

bergundy avatar Nov 09 '23 04:11 bergundy