• Stars
    star
    145
  • Rank 254,144 (Top 6 %)
  • Language
    JavaScript
  • Created about 8 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Tree-shaking example with Typescript and Webpack

Tree-shaking example with Typescript and Webpack

devDependency Status

This repository shows how to configure Typescript and Webpack to enable tree-shaking. It will eliminate dead code if they have ES2015 module format.

The source code can be found in the app/ folder, where the main file car.js doesn't use all the dependencies from engine.js. The built and transpiled files can be found in the /dist folder.

Webpack only marks unused code at bundling and leaves the removing part to minifiers. This is why all the code is included in development builds in contrary to Rollup.

If you want a more detailed explanation, read this article.

Webpack + Typescript + UglifyJS

Can only remove unused functions and variables.

For development build run npm run webpack (Typescript -> ES5 bundle).

For production build run npm run webpack-prod (Typescript -> ES5 bundle -> UglifyJS).

When transpiling classes with Typescript, it generates an IIFE with an assignment to the prototype. It is considered as a side effect by UglifyJS and it skips removing of it.

See the issues below:

Webpack + Typescript + Babili

Can remove unused classes, functions and variables.

For development build run npm run webpack-es2015 (Typescript -> ES2015 bundle).

For production build run npm run webpack-es2015-prod (Typescript -> ES2015 bundle -> Babili).

It uses the Babili ES6+ aware minifier and solves the issues what UglifyJS has.

More Repositories

1

awesome-vue-3

A curated list of awesome things related to Vue 3
1,324
star
2

vue-3-playground

Vue 3 Playground packed with all the new features
Vue
509
star
3

angular2-babel-esnext-starter

Angular development and testing examples with Babel in Javascript (ES6/ES7).
JavaScript
488
star
4

angular2-aot-webpack

Angular AOT (Ahead Of Time) offline compilation example with Webpack
JavaScript
313
star
5

babel-webpack-tree-shaking

Tree-shaking example with Babel and Webpack
JavaScript
252
star
6

angular2-esnext-todomvc

Angular TodoMVC application in Javascript (ES6/ES7).
JavaScript
130
star
7

todomvc-vue-composition-api

TodoMVC built with Vue 3 Composition Api and Vuex
JavaScript
126
star
8

movie-search-vue

Movie search app with the Vue 3 Composition API
Vue
44
star
9

angular2-aot-cli-webpack-plugin

Angular AOT (Ahead Of Time) compilation with Webpack plugin
JavaScript
40
star
10

todomvc-svelte

TodoMVC built with Svelte and Store
JavaScript
38
star
11

todomvc-vue

TodoMVC built with Vue and Vuex
JavaScript
28
star
12

todomvc-react-hooks

TodoMVC built with React Hooks and Redux
JavaScript
24
star
13

ngx-http-test

Angular 2 Http test helper
TypeScript
17
star
14

minesweeper

Minesweeper game built with isomorphic Javascript
JavaScript
14
star
15

todomvc-react

TodoMVC built with React and Redux
JavaScript
6
star
16

node-docker-workflow

Docker workflow for local development and deployment
Makefile
5
star
17

game-of-life

Vue 3 implementation of Conway's Game of Life, with a twist
Vue
4
star
18

todomvc-angular

TodoMVC built with Angular and NgRx
TypeScript
3
star
19

webpack-showcase

Basic setup for Webpack 4 and Babel 7 covering development, testing and deployment.
JavaScript
3
star
20

url-shortener

TypeScript
1
star
21

framework-diff

Comparing the same application written in (Vue, Angular, React, Svelte)
Vue
1
star