google / playground-elements

Serverless coding environments for the web.
BSD 3-Clause "New" or "Revised" License
549 stars 55 forks source link

Speed up builds by not bundling typescript #398

Closed justinfagnani closed 7 months ago

justinfagnani commented 7 months ago

This marks internal/typescript.js as internal in the worker Rollup config, and switches the worker to use modules so it can load the typescript module build.

playground-typescript-worker.js's size goes from 3034427 bytes to 39289 bytes, and the build time on my M1 Pro goes from 26.2s to 4.4s when the typescript bundle is already built.

Module worker support is very good now, at > 96% of tracked users: https://caniuse.com/mdn-api_worker_worker_ecmascript_modules

tbroyer commented 3 weeks ago

This introduced an (unexpected?) breaking change: the internal/typescript.js now needs to be copied alongside the playground-typescript-worker.js, and when using Rollup with @web/rollup-plugin-import-meta-assets, it has to be manually copied to the assets folder (alongside the worker script that Rollup would have copied itself).

The README needs to be updated to reflect this. See #418