Questions tagged [tree-shaking]

Tree shaking is a modern dead code elimination algorithm for ECMAScript 2015.

Tree shaking is a modern dead code elimination algorithm for ECMAScript 2015.

239 questions
0
votes
0 answers

Webpack importing all the files from the export file in production bundle

Webpack not removing unused code in production (final) bundle Here is my scenario file-a.js import {otherfunction} from "./anotherFile.js" export const sendAjaxRequest() /** common function to send a ajax Request**\ file-b.js import…
0
votes
0 answers

Is it possible, in JavaScript, to eliminate code branches by tracking their arguments?

I tried to find some tool that would do this, but prepack is not quite doing what I want and other tools are failing at this particular example. I think it's quite common in programming to use functions in which some of the arguments are constants…
Artur
  • 3
  • 2
0
votes
1 answer

Exclude node module from sideEffects - webpack treeshaking

We have a SPFx webpart project which renders Adaptive cards - this project generate bundles using Webpack via gulp-tasks. We also have a (ESM/esnext) typescript library (SPPacking library) which has a lot of utility functions. |-- My-SPFx-Webpart …
Raghav
  • 2,890
  • 7
  • 36
  • 56
0
votes
0 answers

Tree shaking dependencies in Blazor wasm app

I'm trying to understand the various release mode linking / trimming / tree shaking options for a blazor wasm app. It seems tree shaking reduces the size of referenced .NET dlls. Does it also: Trim my app's dll Trim dependencies' dlls I'm…
lonix
  • 14,255
  • 23
  • 85
  • 176
0
votes
0 answers

No provider for DialogRef InjectionToken

I am creating a directive that opens JavaScript's confirm or CDK Dialog based on condition, CDK dialog is optional, and when not used I want it to be tree shaken. So I used InjectionToken to get the reference of CDK dialog and dialogRef. /**…
Sameer
  • 4,758
  • 3
  • 20
  • 41
0
votes
1 answer

bootstrap-vue vuejs dynamic async component import

I would like to import a single bootstrap component dynamically only when I need it. Bellow syntax actually can do it but it does import all components. So final module bundle after tree-shaking is 1.4MB (entire bootstrap library). BNavbar: () =>…
Stan Sokolov
  • 2,140
  • 1
  • 22
  • 23
0
votes
1 answer

Webpack 5.68 not tree shaking ESM imports

I can't get tree shaking to work correctly on my project running Webpack 5.68 and Babel 7.17.0. If I import my component like this everything works fine and dandy. import { InlineNotification } from…
Mcestone
  • 794
  • 3
  • 10
  • 26
0
votes
1 answer

How can I tree-shake a JavaScript AST in memory?

I know that tools like rollup, webpack and even babel are capable of producing tree-shaken bundles. But I would like to do that, but for an abstract syntax tree I parsed from a file, without writing to disk first. Does that make sense? Is it…
Soska
  • 699
  • 7
  • 11
0
votes
0 answers

Why tree-shaking remove the side-effects code?

Here is the code snippet: const bar = () => 11111 function foo(obj) { return bar(obj); } foo() It's obviously that foo is an impure function which has side effects, so webpack's tree-shaking will not remove it. But after I search for the bundle,…
Chor
  • 833
  • 1
  • 5
  • 14
0
votes
1 answer

How to apply webpack tree shaking feature to Vue template‘s v-if directive?

Vue@2.6.14 Webpack@4.29.6