Skip to content

Tree shaking of vue library #9614

@dandel10n

Description

@dandel10n

Bug report

What is the current behavior?
I have a Vue icons library (npm package), which is using rollup to build the code in various formats (including ES modules) which should be tree-shakable. When I add it to my project, which is built with webpack, and use only one icon from the library, I still see whole library in the production bundle.

If the current behavior is a bug, please provide the steps to reproduce.

I've made super simple vue cli app https://github.com/dandel10n/vue-app-sample - which uses https://github.com/dandel10n/vue-library-sample for easier illustration.

There are 3 components in the library. In the app I use only one (LibComponentOne). But in the vendors.bundle.js I still see all three components being imported.

If I build the app in dev mode with passing optimization: { usedExports: true } then in the bundled js file I see the unused components marked as /* unused harmony export LibComponentThree */\n/* unused harmony export LibComponentTwo */ as expected. But in production build I still see the unused components being included.

What is the expected behavior?

As I understand in app's vendors bundle I should see only one component, not all 3.

Other relevant information:
webpack version: v4.28.4
Node.js version: v10.15.0
Operating System: macOS
Additional tools: Vue CLI, Rollup

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy