You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As for the presets, this would depend on the choice of the template, obviously.
I honestly spent some time configuring i18n, looking at the example didn't really tell me anything about extra configuration needed for the Vue, as the example is in plain TS.
I've kept the templates as minimal as possible, based off of Vite's templates. If you compare the output of pnpm create vite and pnpx wxt@latest init, you'll notice lots of similarities. I'll also point out that Nuxt's pnpx nuxi@latest init is even more bare-bones that WXT's, with no options at all. I wanted to keep it similar to this, but I needed templates for the different frameworks at least, and that's where it ended.
Right now, templates are literally just cloning the templates/<name> directory. This keeps them super simple and super easy to maintain - to test if a template is valid, just cd into that template directory. I've tried fancy ways to combine and re-use files between templates in the past, and it was a nightmare to maintain/test, easily breaking.
But you're 100% correct, the UX could be improved with a way to add "features". Do you have an example project that has a similar setup to what you're suggesting? The Vue CLI is the only one I can think of. I could look at their implementation to see how reasonable it is. If I kept using the current method, having to maintain a folder for every combination of features isn't reasonable, so I'd need to change it up.
I honestly spent some time configuring i18n, looking at the example didn't really tell me anything about extra configuration needed for the Vue, as the example is in plain TS.
For Vue in particular, I should add that to the Vue template. It's the only framework that needs a custom setting for imports to work as expected.
If the problem is not being able to detect every single change required to enable a feature from the basic templates, an alternative solution might be better documenting it. For example, using a git diff on GitHub to visually show every single change, including the small ones, rather than just linking to some folder in a different repo.
Perhaps there's a way to automate that and turn each example into more of a walkthrough based on the real diff than just text in a README that doesn't mention any specific code. Maybe creating a branch for every example, letting you easily compare them on GitHub's UI. I'll give this a go today.
Another alternative solution is to include a "maximal" template, in contrast to the minimal one, that people can remove things from rather than having to add to it. Could run into similar issues though, accidentally removing code that's required for multiple features. And I'd have to maintain one per framework, so that could grow and become a maintenance burden.
Oh, I see... That makes sense. Did not even look at the current CLI implementation.
Well, I have used Laravel and their Artisan CLI is huge, can generate all sorts of templates, but is probably heavy to maintain.
I remember that Vue also does have a bit more questions, before initial installation. Vue 3
The Vue 3 does not have any question with multiple choice answers, but I guess the preset option I mentioned would be very hard to maintain indeed.
–––
Hmmm I guess that could work, but maybe requires more users. So that you are able to define those minimal and maximal templates based on the use-cases.
An extensible documentation could be an alternative to the extensible CLI too.
I see that you're working alone on this project and I bet it's time consuming to do all of the things. (actual lib, examples, docs)
If I can help with something, let me know! I usually find some time over weekends 😄
Tried out using GitHub as a diff tool, but the way I've set it up, the different branches don't share any history, so github doesn't show a nice diff (see wxt-dev/wxt-examples@vue...vue-i18n). Unsurprising now that I think about it.
An alternative: I could create a patch via git diff and then process that to show all the changes in a nice, walkthrough-esk way, but that seems like a lot of custom code... Might be worth it might not. I think this could be done separate from wxt init improvements though.
Also spent some time doing more research into how other CLI's do this. There doesn't seem to be a consistent library/tool used for this, but there are some patterns:
Merging directories together per feature and overwriting files with the same name
Generating config files that change per feature
The one addition I'd like to see to these is to make it based off the current code on the main branch on GitHub, not tied to a specific release of WXT. This could be done by cloning the project like WXT already does. For the feature lists, I'd like something similar, not tied to the release of WXT.
@dvlden if you want to look into this more and open a PR, I think that sounds good. I like what create-vue does, you could use that as a reference. Lets start with a single feature, vue-i18n, and figure out the system. If not, I probably won't be working on this for a while.
@dvlden I finished creating the doc generator for "example walkthroughs". I know you said you're not using vue-i18n, but would this have been more helpful than whatever docs you referred to originally?
No, I meant... For someone who's not using vue-i18n and only relies on browser.i18n he'd be defining a mess in public/_locales because the syntax is too verbose.
But if someone wanted to use vue-i18n they'd be defining only extension name and description within the context of browser.i18n and the rest can all live inside vue-i18n locale dir.
Am I right? If not, I'd be trying to figure out the way to use only vue-i18n and somehow at the build-time generate locales needed for parts that browser.i18n can access, such as manifest.json file property values.
@dvlden Yes, that is an option, that could be a simple Vite plugin. I need to research other patterns before committing to adding that logic to WXT directly. I don't want to add something that only works for one framework's one library.
Activity
aklinker1 commentedon Oct 29, 2023
I'm glad it's working well for you!
I've kept the templates as minimal as possible, based off of Vite's templates. If you compare the output of
pnpm create viteandpnpx wxt@latest init, you'll notice lots of similarities. I'll also point out that Nuxt'spnpx nuxi@latest initis even more bare-bones that WXT's, with no options at all. I wanted to keep it similar to this, but I needed templates for the different frameworks at least, and that's where it ended.Right now, templates are literally just cloning the
templates/<name>directory. This keeps them super simple and super easy to maintain - to test if a template is valid, justcdinto that template directory. I've tried fancy ways to combine and re-use files between templates in the past, and it was a nightmare to maintain/test, easily breaking.But you're 100% correct, the UX could be improved with a way to add "features". Do you have an example project that has a similar setup to what you're suggesting? The Vue CLI is the only one I can think of. I could look at their implementation to see how reasonable it is. If I kept using the current method, having to maintain a folder for every combination of features isn't reasonable, so I'd need to change it up.
For Vue in particular, I should add that to the Vue template. It's the only framework that needs a custom setting for imports to work as expected.
If the problem is not being able to detect every single change required to enable a feature from the basic templates, an alternative solution might be better documenting it. For example, using a git diff on GitHub to visually show every single change, including the small ones, rather than just linking to some folder in a different repo.
Perhaps there's a way to automate that and turn each example into more of a walkthrough based on the real diff than just text in a README that doesn't mention any specific code. Maybe creating a branch for every example, letting you easily compare them on GitHub's UI. I'll give this a go today.
Another alternative solution is to include a "maximal" template, in contrast to the minimal one, that people can remove things from rather than having to add to it. Could run into similar issues though, accidentally removing code that's required for multiple features. And I'd have to maintain one per framework, so that could grow and become a maintenance burden.
nnx0r commentedon Oct 29, 2023
Oh, I see... That makes sense. Did not even look at the current CLI implementation.
Well, I have used Laravel and their Artisan CLI is huge, can generate all sorts of templates, but is probably heavy to maintain.
I remember that Vue also does have a bit more questions, before initial installation.
Vue 3
The Vue 3 does not have any question with multiple choice answers, but I guess the preset option I mentioned would be very hard to maintain indeed.
–––
Hmmm I guess that could work, but maybe requires more users. So that you are able to define those minimal and maximal templates based on the use-cases.
An extensible documentation could be an alternative to the extensible CLI too.
I see that you're working alone on this project and I bet it's time consuming to do all of the things. (actual lib, examples, docs)
If I can help with something, let me know! I usually find some time over weekends 😄
aklinker1 commentedon Oct 30, 2023
Tried out using GitHub as a diff tool, but the way I've set it up, the different branches don't share any history, so github doesn't show a nice diff (see wxt-dev/wxt-examples@vue...vue-i18n). Unsurprising now that I think about it.
An alternative: I could create a patch via
git diffand then process that to show all the changes in a nice, walkthrough-esk way, but that seems like a lot of custom code... Might be worth it might not. I think this could be done separate fromwxt initimprovements though.Also spent some time doing more research into how other CLI's do this. There doesn't seem to be a consistent library/tool used for this, but there are some patterns:
The one addition I'd like to see to these is to make it based off the current code on the
mainbranch on GitHub, not tied to a specific release of WXT. This could be done by cloning the project like WXT already does. For the feature lists, I'd like something similar, not tied to the release of WXT.@dvlden if you want to look into this more and open a PR, I think that sounds good. I like what
create-vuedoes, you could use that as a reference. Lets start with a single feature,vue-i18n, and figure out the system. If not, I probably won't be working on this for a while.nnx0r commentedon Oct 30, 2023
Interesting thoughts and research.
I'll try to find a clean and maintainable approach over the weekend.
Aside, I was thinking about
browser.i18nCLI option and notvue-i18n, sorry about the confusion.aklinker1 commentedon Nov 2, 2023
@dvlden I finished creating the doc generator for "example walkthroughs". I know you said you're not using
vue-i18n, but would this have been more helpful than whatever docs you referred to originally?https://github.com/wxt-dev/wxt-examples/blob/v2/examples/vue-i18n/README.md
nnx0r commentedon Nov 3, 2023
This is nice. If someone opts-in for
vue-i18nhe'd only be usingpublic/_localesfor extension name and description?aklinker1 commentedon Nov 3, 2023
If they opt-out of
vue-i18n, then yes, they would only use thepublic/_locales/directory. All translations would go in the messages.json files.I'll add a vanilla example as well.
aklinker1 commentedon Nov 5, 2023
Alright, I've integrated the new examples into the docs: https://wxt.dev/examples.html
nnx0r commentedon Nov 7, 2023
No, I meant... For someone who's not using
vue-i18nand only relies onbrowser.i18nhe'd be defining a mess inpublic/_localesbecause the syntax is too verbose.But if someone wanted to use
vue-i18nthey'd be defining only extension name and description within the context ofbrowser.i18nand the rest can all live insidevue-i18nlocale dir.Am I right? If not, I'd be trying to figure out the way to use only vue-i18n and somehow at the build-time generate locales needed for parts that
browser.i18ncan access, such asmanifest.jsonfile property values.aklinker1 commentedon Nov 7, 2023
@dvlden Yes, that is an option, that could be a simple Vite plugin. I need to research other patterns before committing to adding that logic to WXT directly. I don't want to add something that only works for one framework's one library.
aklinker1 commentedon Nov 11, 2023
I'm gonna close this since the examples are much better now.