-
-
Notifications
You must be signed in to change notification settings - Fork 5k
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
feat(vue-app): support configurable features #6287
Conversation
Amazing idea 👍 |
fix builder.generate test implement review suggestions support features.layouts support features.store (so store can exists but still be disabled)
Added the suggestions and implemented store/layout features. Also had some wrong/old features in the nuxt.config of the minimal example, so size is even smaller now (image of app bundle size is updated). |
Really nice enhancement. I wish we could also support disabling router. But seems not an easy task for initial PR. |
Codecov Report
@@ Coverage Diff @@
## dev #6287 +/- ##
==========================================
+ Coverage 95.71% 95.74% +0.02%
==========================================
Files 79 79
Lines 2663 2678 +15
Branches 682 691 +9
==========================================
+ Hits 2549 2564 +15
Misses 98 98
Partials 16 16
Continue to review full report at Codecov.
|
I looked into making the router configurable as well but almost every function in |
Great work @pimlie, I had this in mind for Nuxt 3. Ideally, the features enable themselves when used (when detecting the directory associated or defined in the config). Also, I am afraid that some module may not work if the user disable some features 🤔 |
Well, yes/no. I can imagine there are also times you just want to disable a feature regardless whether you have certain files in your project. Eg with the current store implementation I did you can have a store module in your project, but if you toggle the feature to false it will still be disabled.
True, for the moment thats really up to the user to think about. Thats why I mentioned experimental and for advanced users only. I dont think we should launch this pr as a great new feature anyway, not as long as we cant provide a router feature. So I would propose to do a silent launch, learn from it and then improve by maybe taking the approach you had in mind for v3 |
Definitely, the user prefence should take precedence! But disabling/enabling features if certain conditions are present and the user didn't set the config otherwise would be nice. |
useUrl: true | ||
}, | ||
components: { | ||
aliases: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you think about flattened options like compoentAliases
? This way we don't need to always worry about falsy value in the path (Like components: false
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A REALLY REALLY nice improvement to support minimal builds for nuxt. Can't wait to also have router disabling support. With nuxt 3 we can have nuxt to be used like:
- Create
app.vue
npx nuxt dev
- TADA! A fully minimal/universal/efficient vue app is ready!
I think we should be better to merge this ASAP to avoid merge conflicts.
test: add minimal app resource size test
@clarkdo Thanks, could you please verify if I implemented it correctly? And I would appreciate your/anyone's help with resolving the error with unicode-base, dont really understand why that now gives an error? The file exists on the fs and is listed in the manifest, does one of you maybe have any idea why jsdom cant find it? Only change for that test is that I added --edit-- |
@pimlie Looks perfect, you can double verify it by having a look at analyze report. |
This PR is only a draft because we didn't discuss this yet before. Feature-wise I think its complete, maybe just need to add some tests.Types of changes
Description
The Nuxt Vue-app has quite a bit of features which until this PR were always included, whether you used them or not. This PR defines a list of features which are used to either include or omit the corresponding code in the Vue-app templates. This makes it possible for a user to further optimize their bundle sizes.
Here is the list of features which are toggleable:
I've included a copy of the hello world example app with all (supported) features disabled.
App bundle size of Hello world app
App bundle size of Minimal-features Hello world app:
This PR was also partially given in by the benchmark discussions on discord. You could argue that disabling all these settings is not very usefull and I will probably agree with that. But giving users the possiblity to further optimize their bundle sizes is a nice feature I think and worth the extra work with regards to maintaining the vue-app templates.
Disabling features is considered highly experimental and for advanced users only.
Note: The above bundle size of the Hello world app has already improved slightly compared to the current dev branch. This is mainly due to some optimisations in
./utils.js
. EgurlJoin
is/was always included in the app bundle but thats only used inserver.js
Checklist: