{"id":19306599,"url":"https://github.com/sonicoder86/typescript-webpack-tree-shaking","last_synced_at":"2025-04-22T12:36:05.979Z","repository":{"id":113390506,"uuid":"66199769","full_name":"sonicoder86/typescript-webpack-tree-shaking","owner":"sonicoder86","description":"Tree-shaking example with Typescript and Webpack","archived":false,"fork":false,"pushed_at":"2017-06-17T06:11:07.000Z","size":33,"stargazers_count":145,"open_issues_count":5,"forks_count":20,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-02-23T12:28:43.536Z","etag":null,"topics":["babili","tree-shaking","typescript","webpack"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sonicoder86.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2016-08-21T13:18:28.000Z","updated_at":"2024-02-23T12:28:44.950Z","dependencies_parsed_at":null,"dependency_job_id":"ebebd87c-da4c-4ade-a2a7-16556f20b370","html_url":"https://github.com/sonicoder86/typescript-webpack-tree-shaking","commit_stats":null,"previous_names":["sonicoder86/typescript-webpack-tree-shaking"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonicoder86%2Ftypescript-webpack-tree-shaking","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonicoder86%2Ftypescript-webpack-tree-shaking/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonicoder86%2Ftypescript-webpack-tree-shaking/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonicoder86%2Ftypescript-webpack-tree-shaking/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sonicoder86","download_url":"https://codeload.github.com/sonicoder86/typescript-webpack-tree-shaking/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223896995,"owners_count":17221475,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["babili","tree-shaking","typescript","webpack"],"created_at":"2024-11-10T00:07:03.816Z","updated_at":"2024-11-10T00:07:04.932Z","avatar_url":"https://github.com/sonicoder86.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tree-shaking example with Typescript and Webpack\n[![devDependency Status](https://david-dm.org/blacksonic/typescript-webpack-tree-shaking/dev-status.svg)](https://david-dm.org/blacksonic/typescript-webpack-tree-shaking?type=dev)\n\nThis repository shows how to configure Typescript and Webpack to enable tree-shaking.\nIt will eliminate dead code if they have ES2015 module format.\n\nThe source code can be found in the ```app/``` folder,\nwhere the main file ```car.js``` doesn't use all the dependencies from ```engine.js```.\nThe built and transpiled files can be found in the ```/dist``` folder.\n\nWebpack only marks unused code at bundling and leaves the removing part to minifiers.\nThis is why all the code is included in development builds in contrary to Rollup.\n\nIf you want a more detailed explanation,\n[read this article](https://blog.craftlab.hu/how-to-do-proper-tree-shaking-in-webpack-2-e27852af8b21).\n\n### Webpack + Typescript + UglifyJS\n\nCan only remove unused functions and variables.\n\nFor development build run ```npm run webpack``` (Typescript -\u003e ES5 bundle).\n\nFor production build run ```npm run webpack-prod``` (Typescript -\u003e ES5 bundle -\u003e UglifyJS).\n\nWhen transpiling classes with Typescript, it generates an IIFE with an assignment to the prototype.\nIt is considered as a side effect by UglifyJS and it skips removing of it.\n\nSee the issues below:\n\n- [Webpack issue](https://github.com/webpack/webpack/issues/2899) and a [more detailed one](https://github.com/webpack/webpack/issues/2867)\n- [UglifyJS issue](https://github.com/mishoo/UglifyJS2/issues/1261)\n\n### Webpack + Typescript + Babili\n\nCan remove unused classes, functions and variables.\n\nFor development build run ```npm run webpack-es2015``` (Typescript -\u003e ES2015 bundle).\n\nFor production build run ```npm run webpack-es2015-prod``` (Typescript -\u003e ES2015 bundle -\u003e Babili).\n\nIt uses the [Babili](https://github.com/babel/babili) ES6+ aware minifier and solves the issues what UglifyJS has.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsonicoder86%2Ftypescript-webpack-tree-shaking","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsonicoder86%2Ftypescript-webpack-tree-shaking","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsonicoder86%2Ftypescript-webpack-tree-shaking/lists"}