Nx with Angular and Webpack: tree shaking and barrel file from libraries

Discussão em 'Angular' iniciado por Max Liapkalo, Outubro 30, 2024.

  1. Max Liapkalo

    Max Liapkalo Guest

    To start with, here's a minimal repo where you can see the behaviour I'm going to describe: repo

    And here's the nx graph of workspace from repo:

    [​IMG]

    My question is how can I perform tree shaking on barrel files from data-access libraries? Running webpack-bundle-analyzer(run nx analyze host inside the workspace from provided repo) shows that everything from data-access ends up in initial bundle(or am I misinterpreting the results?). I understand that barrel files from data-access libraries re-export every module the lib has, but I was expecting tree shaking come into action.

    Output of nx analyze host:

    [​IMG]

    Both books-data-access and users-data-access libraries have sideEffects: false in their package.json files and I use only a single module from each data-access lib inside host app.

    Continue reading...

Compartilhe esta Página