trunk icon indicating copy to clipboard operation
trunk copied to clipboard

trunk serve --bin/--example

Open simbleau opened this issue 1 year ago • 3 comments

Highly desired feature to include support for --bin (which would set data-bin on the index.html, unless already present) and --example.

simbleau avatar Jan 11 '24 17:01 simbleau

I took a brief look into this. And I am not sure this is achievable.

I personally would also like to to just run:

trunk serve --example foo

However, … --bin is already used for dealing with web-workers. Having the data-bin attribute you mentioned triggers this. And having a web-worker in the mix, the examples I saw make actual use of that. You have two data-bin with <link rel="rust">. Overriding that might make things just complex.

Which brings me to --example, I am not sure how that would properly with the web-worker example mentioned above. --bin in combination with --example might not lead to a sane environment.

So fiddling with this, I fear we would be breaking some things that work quite well at the moment.

On the other hand, back the --example case, I noticed that most projects anyway have a full cargo project for examples. So why not improve the situation of starting trunk with a different base directory?

So that one can do:

trunk serve example/foo

ctron avatar Feb 09 '24 15:02 ctron

@ctron - Maybe we could prioritize workspaces over examples?

I believe it's an extremely common case to have a monorepo with a frontend and backend crate in a workspace, but having an index.html in the example folder might be difficult to make sense of since there's no standard way to handle this.

For example, trunk serve -p frontend could just be a syntax sugar for (essentially) cd frontend && trunk serve

simbleau avatar Feb 18 '24 20:02 simbleau

Maybe … however, so far (due to the way cargo works) we always ended up having the UI excluded from the main workspace. Still keeping things in the same repository.

Still, I do see the benefit of having -p foo for even more reasons. My hope would also be that this should be easier to implement, without breaking existing behavior.

ctron avatar Feb 19 '24 07:02 ctron