bootstrap-vue: Nuxt tree shaking not working

Describe the bug

I’m using BootstrapVue with Nuxt and the tree shaking is not working. In spite of set what components will be used, the bundle contains carousel component for example.

nuxt.config.js

  modules: [
    'bootstrap-vue/nuxt'
  ],
  bootstrapVue: {
    bootstrapCSS: false, // Or `css: false`
    bootstrapVueCSS: false, // Or `bvCSS: false`
    directivePlugins: ['VBScrollspyPlugin'],
    components: [
      'BLink',
      'BRow',
      'BCol',
      'BContainer',
      'BJumbotron',
      'BImg',
      'BImgLazy',
      'BNavbar',
      'BNavbarNav',
      'BNavbarBrand',
      'BNavbarToggle'
    ]
  },

bundle analyzer image

Expected behavior

The main bundle should contain only components that I set.

Versions

Libraries:

  • BootstrapVue: 2.0.0-rc.20
  • Bootstrap: 4.3.1
  • Nuxt: 2.7.1

Environment:

  • Device: PC
  • OS: W10
  • Browser: Chrome
  • Version: 74

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 30 (19 by maintainers)

Commits related to this issue

Most upvoted comments

Hmmm it appears webpack isn’t tree shaking based on the named exports (which is should)

IF you import just the plugins, do you see a similar effect:

  modules: [
    'bootstrap-vue/nuxt'
  ],
  bootstrapVue: {
    bootstrapCSS: false, // Or `css: false`
    bootstrapVueCSS: false, // Or `bvCSS: false`
    directivePlugins: ['VBScrollspyPlugin'],
    componentPlugins: [
      'LinkPlugin', 'LayoutPlugin', 'JumbotronPlugin', 'ImagePlugin', 'NavbarPlugin'
    ]
  },