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

Es6 babelify import specific functions

I am primarily a backend developer but Im trying to modernise my javascript capabilities. I have written a test file in Es6 as follows: export const TestA = () => { console.log("test A"); } export const TestB = () => { console.log("test…
Kevin Bradshaw
  • 6,327
  • 13
  • 55
  • 78
0
votes
2 answers

Specify which React components to be added to bundle

I have a components_settings file that describes a list of components that shall be included in the production bundle, this file should be read by webpack during the build process, e.g. { RedButton:false, BlueButton:true } I have both of these…
the_dude
  • 39
  • 8
0
votes
1 answer

What do you call function that use stuff outside of the function and function that is self contained?

Dose this two function have a name or a term? I'm sure they do but don't know what to search for. // edit: thanks to Bergi: // this is a function with `no free variables` (outer variables) function add (a, b) { return a + b } and // edit: thanks…
Endless
  • 34,080
  • 13
  • 108
  • 131
0
votes
1 answer

Unexpected code after tree-shake

Given entry is the entry module: It just uses function1 from external1 module. I expected that external1.function2 and the whole external2 module would be eliminated. However, my output includes external2.function1. Just.. why? Here's a repo of…
Daniel Birowsky Popeski
  • 8,752
  • 12
  • 60
  • 125
0
votes
1 answer

Determine whether static file site contains css inheritance rule

I'm working on a site that renders static html files, and I wish to determine which pages in the site contain a specific css inheritance rule, such as .parent .child (a child class that descends from a parent). I can imagine a web crawler that…
duhaime
  • 25,611
  • 17
  • 169
  • 224
0
votes
1 answer

Rollup with CommonJS, import and exports with treeshaking

I'm trying to get rollup, commonjs, es6 and tree shaking working correctly. Currently, I have the following build script: 'use strict'; const rollup = require('rollup'); const resolve = require('rollup-plugin-node-resolve'); const commonjs =…
Prisoner
  • 27,391
  • 11
  • 73
  • 102
0
votes
1 answer

If webpack tree-shaking handle node_modules?

I am working on node@6.11.0, webpack@3.4.1 file.js export function foo () { return 'foo' } export function bar() { return 'bar' } main.js import { foo } from './file' import { log } from 'mathjs' foo() log(10000,10) And bundle.js include all…
2014
  • 103
  • 2
  • 9
0
votes
1 answer

Webpack tree shaking - removes export called Entity

I stumbled across a very strange name issue. I'm trying to use a TypeScript library (TypeORM) in an Ionic App which uses webpack to build and compile the app. TypeORM has decorators for Entities called Entity, AbstractEntity and others. When I…
Daniel Kurz
  • 816
  • 7
  • 21
0
votes
0 answers

Angular 4 CSS not rendering after Tree Shaking

I'm using the Rollup plugin to do a Tree shaking of my Angular application. I get a final build.js and when I inspect it, the CSS is there but for some reason it's not being rendered by the DOM. I'm using SCSS and all my styles have a .scss…
M1X
  • 4,971
  • 10
  • 61
  • 123
0
votes
2 answers

Angular AOT compiled app not tree shaking as expected

I have a module (MyCommonModule) with common components, services, etc that I plan to share between different angular applications. This is an example of a simple app, that only imports MyCommonModule (but doesn't reference any of it in AppComponent…
Joel
  • 8,502
  • 11
  • 66
  • 115
0
votes
1 answer

Angular2 application minification and tree-shaking with Webpack

In my Angular2 application (ES6 spec), I am using WebPack with a common config which is extended in dev and prod config. In my prod config, I would like to also use uglification after doing tree shaking. How do I make it happen? Any sample/link to…
Abhi
  • 1,624
  • 2
  • 16
  • 29
-1
votes
1 answer

vue3 + tailwind - dynamic classes - is this acceptable solution?

Tailwind docs say that we should not pass dynamic pieces of class name as props because it will not work, and well it does not. There are other options. One of them is to predefine object with actual tailwind classes and then passing a prop to pick…
Robert
  • 1,206
  • 1
  • 17
  • 33
-1
votes
1 answer

Tree shaking vs Lazy Loading

In Angular, we can use providedIn: 'root' to make a service tree shakeable. And we can use loadChildren() in our router to specify a lazily loaded module. What's the difference between these two terms 'tree shakeable' and 'lazy loaded'? Do they both…
Kyle Vassella
  • 2,296
  • 10
  • 32
  • 62
-1
votes
1 answer

How to exclude a custom constructor in webpack treeshaking?

I have the following code in a JS file (() => { const Abc = (ab) => { this.ab = ab; this.k = () => { console.log(this.ab); }; }; window.MySpace = window.MySpace || {}; window.MySpace.abc = new…
Green Wizard
  • 3,507
  • 4
  • 18
  • 29
1 2 3
15
16