bootstrap-vue: Babel Errors in nuxt generate 2.14
Describe the bug
I updated my nuxt project to the latest release which is 2.14. I then use nuxt generate to build the project. While nuxt is building the project, it gives this error
[BABEL] Note: The code generator has deoptimised the styling of \node_modules\bootstrap-vue\src\icons\icons.js as it exceeds the max of 500KB.
Steps to reproduce the bug
- Update the project to 2.14
- Use nuxt generate to build project
- It will display the error when compiling on the Client
Expected behavior
Should not have any errors
Versions
Libraries:
- BootstrapVue: 2.16.0
- Bootstrap: 4.5.0
- Nuxt: 2.14.0
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 18
- Comments: 42 (6 by maintainers)
Hi, in the docs it is said the icons shouldn’t be loaded by default, but I get that error the same, both if I set
and if I set no bootstrapVue property and just load the module. Do you know why?
@amdp BootstrapVue
I use them like so: // nuxt.config.js
// icons.js in plugin folder
And to avoid the above mentioned warning: // config.nuxt.js
Hope it helps
Same problem as @amdp. I haven’t enabled the icons at all, and I’m seeing the build error. All I did was add
bootstrap-vue/nuxttomodulesReopen, still an issue !
If you want to remove icons plugin from your nuxt app remove icons component and directive from global components in
nuxt.config.jsfile and just add components you need, for example:same here
Bump, still a big issue
any solution for this ?
Same issue - nuxt.config.js
I believe the icons tree-shaking works most of the time, except under certain circumstances. For example, I found that if I include
SkeletonPlugin, the icons tree-shaking would fail, so I importBSkeletoncomponent only and it works.The following is my configuration using Nuxt.
Source: https://code.luasoftware.com/tutorials/vuejs/bootstrapvue-icons-import-specific-icon-only/
I resolved this issue by patch icons.
The steps are download this repository, remove unused icons, generate icons.js, and copy icons.js to node_modules.
Icons listed in above are used by internal components of bootstrap-vue, if you need more icons include them to the command.
After optimize the bundle size is reduced about 500kb.
And I think this issue deserve to reopen, include 500kb unused resources in production app is really bad, even most frontend developers wont give a sh’t of performance.
The problem is in Bootstrap-Vue. I forced webpack 5 to explicitly not load the stuff I wasn’t using (I’m transpiling it explicitly):
That leaves with no icons at all, however, even if you import those you want. However you can efficiently include just those same icons which you actually use without Boostrap Vue.
it IS problem.
@hassan-jahan I checked out your example project and it works as it should. As our documentation states here are icons only opt-in and not included by default.
Bundle size with no
bootstrapVueNuxt.js config:Bundle size with
icons: trueinbootstrapVueNuxt.js config:See the tree shaking section to learn how to reduce the general bundle size.
This is not an error, it is just a note (
[BABEL] Note: ...) from Babel’scompactoption option.Since the
icons.jsfile is quite big (> 500KB), all optional newlines and whitespace will be omitted. When you wan’t to get rid of the note, set the compact option to eithertrueorfalse.@PixsaOJ the problem is the final bundle size is huge even if no icons are used.
babel: compactjust hides the warning. I removed bootstrap-vue and just linked in the bootstrap CSS and JS, and it shaves of ~500KB from the production build.build: { babel: { compact: true } }andSeems to work. Just make sure you have the latest packages.
Where I put this please ? I’m not so familiar with webpack.
This is still an issue. Just after including the Nuxt module without any usage.
This is still an issue, please reopen it
The warning will show up independently wether you import/register all or just some of the icons. Relevant for the note is the source file (
icons.js) and that stays the same.Please take a look at the Nuxt.js documentation for the
babelbuild property on how to configure it properly.