-
-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include a worktop build
command
#82
Comments
I think there are 2 valid use-cases for a CLI. Making it even more trivial to generate a worker for simple use-cases and to use it to compile out Worktop altogether. If I have a medium complexity worker that happens to use Worktop I already have a bundler solution setup and I don't need anything special from Worktop right? If you have a small CLI included in worktop with a But the compiling out of the |
@evanderkoogh yea exactly. The counterpoint here that I forgot to mention is that I already have So, today, you can already create a Worker with worktop & build it with cfw without any configuration needed. But this solution misses out on the optimizations part of the equation. |
Initially it sounds like this would be nice for the dev experience but the point about the project scope seems like it could be a lot of work for relatively little gain. I don't know much about these different build systems (webpack vs rollup vs esbuild) but I do know that I have never liked webpack. After a quick look, it looks like esbuild and swc are really interesting alternatives. I would try to get one of these to work with my current project and see if there is a noticeable difference compared to webpack when it comes to re-building the project during development. I think for me, and maybe other developers, it would be ideal to have a starter template with worktop and esbuild/swc. Looking back now, I guess I didn't think of exploring other options since webpack is default for wrangler. Even with webpack though, there hasn't been any real problems since the initial hiccup with #62 and I could entirely focus on developing without thinking about the framework. I can't really comment on the other technical points since I don't understand them enough. Just wanted to provide some thoughts on the onboarding experience. If that (onboarding) is a main motivation for considering this issue I personally feel like some effort in documentation/examples would be enough. |
Providing plugins for those who want/need the extra optimization seems like the best solution. |
Closing in favor of #95, which tracks the optimization work specifically. Already merged #94 which added the This will serve as an easy-yet-configurable solution for building a worktop Worker (or any Worker) instead of the default |
I've been going back on forth on this for a while... Basically, it's a debate between:
worktop
CLI that builds a Worker for youI suppose it's possible to do both, but the array of plugins would be second-class in that scenario, especially since it's (probably) unlikely that each integration could offer the same level of output refinement.
PROs
It'd be nice to have a ready-to-go build system for you, allowing (most) users to avoid the webpack that wrangler includes. This would solve low-hanging issues (eg #62, #73, #81). There's already very little reason to use webpack anyway, but really, this is the only unmatched benefit to offering a build-in CLI solution. In other words, even with a
worktop/webpack
plugin, there's still the"exports"
and ESM resolving issue that I (as the plugin) can't fix without risking other resolutions breaking.Either as a
worktop
CLI or as a series of plugins, I'm going to want to do AST transformations. For long before worktop's first public release, I've had a PoC that compiles away the worktopRouter
in production. Even though the Router is already fast and lightweight, this removes all doubt and produces the most optimized form of the equivalent routing logic.If I ship a CLI, it's easier to defend including an entire
@swc/core
installation. It also means that worktop could lean into other compile-time optimizations/rewrites. Going the plugins route, I'd have to sheepishly include all of@swc/core
anyway, which is kinda like embedding a bundler within your existing bundler, or rewrite all the same AST operations using the target system's offerings –– i've explored this for another project... it's not fun.CONs
worktop build
sorta implies the existence/inevitably of aworktop dev
commandCan always attach
miniflare
/equivalent, but the expectation will be there and creates far more scope.Current Stance
Right now, I'm thinking that if I do this, it'd all take place under another package. That would mean that your
package.json
looks something like this:This way, you only buy into all of the build-time optimizations if you decide to actually use/install
worktop-builder
(name tbd). If you don't install and use the toolkit, then you useworktop
as you/we already do today.Two quick polls to (anonymously) weigh in on the points raised here. Thank you~! 🙇
Plugins vs CLI
Single vs Separate Packages
The text was updated successfully, but these errors were encountered: