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
1 answer

Why is a unused public methods from services removed by tree-shake

We are developing a webapp, with uses quite a large API, which is included as npm library. The library has a lot of methods, which are not used in the applicaiton and our assumption was, that these methods are not included in the production build.…
Stefan
  • 14,826
  • 17
  • 80
  • 143
0
votes
1 answer

Angular 7 - Enable tree-shaking without code minification

Is it possible to enable tree shaking using ng build--prod without minifying the code? I know it is possible by using a custom webpack.config.js but I am using angular-cli with angular.json for configuration. Some suggest running the ng build --prod…
ASR
  • 421
  • 11
  • 27
0
votes
1 answer

ES6: Keep function from tree shaking

I'm using rollup and babel to transpile ES6 code. Now i need this Recaptcha Callback function to be triggered when the Captcha has been checked. Problem is that tree shaking or another mechanism filters this function out during transpilation…
Mike
  • 5,416
  • 4
  • 40
  • 73
0
votes
1 answer

How to make Angular mock service tree-shakeable

Context In an Angular 9 project, I am working with two environments: production & mock. In the Core Module, I check for mock environment. If build is made with mock configuration I inject mocked services that return mocked data, so no external http…
adrisons
  • 3,443
  • 3
  • 32
  • 48
0
votes
1 answer

How to treat require/import as a value and not dependency

Case I: I have a file called data.json { "a": 1, "b": 2, ... } Which I imported/required in index.js as shown below import data from './data.json'; console.log(data["a"]); Everything works fine but the whole data.json is dumped into…
Toheeb
  • 13
  • 4
0
votes
1 answer

Tree shaking for libraries in Angular 8

I'm planning on making a standalone Angular service for Angular 8+, and I've been reading up on how to make it tree tree-shakable. I believe all we need to do is this: @Injectable({ providedIn: 'root', useFactory: () => new…
Ole
  • 41,793
  • 59
  • 191
  • 359
0
votes
1 answer

Is tree-shaking happening in angular 8 development mode?

I just want to know, if tree-shaking takes place in angular 8 development mode? When using below command: ng build I know if I use the command below tree-shaking takes place. ng build --optimization=true|false
Kumaresan Sd
  • 1,399
  • 4
  • 16
  • 34
0
votes
0 answers

Build with webpack when dead code references a module that's not present fails - is this unavoidable/expected behavior?

I'm sharing some code between environments and in one environment a dependency isn't available - but that code isn't imported into the project and the module uses sideEffects: false - I'd think I should be able to build the project, but if I'm…
Slbox
  • 10,957
  • 15
  • 54
  • 106
0
votes
1 answer

Tree Shaking Lodash with Webpack 3.8.1

Lodash@4.17.4 Webpack@3.8.1 babel@7 babel-plugin-lodash@3.3.2 I use named imports when it comes to Lodash. I've configured @babel/preset-env with 'modules' set to false to prevent transpilation to Common JS and use 'lodash' as a plugin in the…
Mayur Arora
  • 447
  • 5
  • 11
0
votes
1 answer

Quasar v1 tree shaking using webpack 4 and laravel-mix

I am building a fullstack app using laravel and vue. I want to integrate quasar as a front end framework. I am using laravel mix to build the assets. I was wondering how I could tree shake quasar using laravel mix or webpack. The documentation just…
0
votes
1 answer

Typescript removes (tree-shaking) my file/class

Suppose a class adds itself to an other class as follows bar.ts: import { Foo } from './foo'; export class Bar {} Foo.prop = Bar; And file foo.ts export class Foo { public static prop: any; } Now, if would like to use this in index.ts import…
Jeanluca Scaljeri
  • 26,343
  • 56
  • 205
  • 333
0
votes
0 answers

Webpack treeshaking with ~/components/ui/index.js and Vue.js

Hello I have a index in a UI module within my components exporting all components in that folder like so: ~/components/ui/index.js: import Button from './Button'; import Footer from './Footer'; export { Button, Footer } And I use it in some page…
Tim
  • 5,521
  • 8
  • 36
  • 69
0
votes
1 answer

How do I get treeshaking to work for a file that exports multiple react components?

I have a file where I'm exporting multiple consts with arrays of children called icons.js. In another react file, lets call it CloseButton.js. I'm only importing import { cross } from './icons.js'; and when I run webpack with production mode…
0
votes
1 answer

Is there a way in Angular 7 to decide at compile time which service to use?

I've created an Angular 7 project with Ionic 4. In this project I have multiple environments e.g 'local' or 'firebase'. In my environment.ts is a parameter which corresponds to the strings above. export const environment = { production: false, …
MirJo
  • 204
  • 1
  • 2
  • 9
0
votes
1 answer

Conditional environment variables tree-shaking

Currently I am trying to remove unused code based on the environment variable. In the code below when I run ng build --prod and set evironment.showDevTools = false in environment.prod.ts then I expect the console.log not to be included in the final…
Humberd
  • 2,794
  • 3
  • 20
  • 37
1 2 3
15
16