{"id":19306613,"url":"https://github.com/sonicoder86/babel-webpack-tree-shaking","last_synced_at":"2025-08-08T02:39:36.564Z","repository":{"id":113389750,"uuid":"66268966","full_name":"sonicoder86/babel-webpack-tree-shaking","owner":"sonicoder86","description":"Tree-shaking example with Babel and Webpack","archived":false,"fork":false,"pushed_at":"2017-09-17T10:46:33.000Z","size":36,"stargazers_count":250,"open_issues_count":2,"forks_count":16,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-22T12:36:40.882Z","etag":null,"topics":["babel","babili","tree-shaking","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-22T12:00:52.000Z","updated_at":"2024-08-12T10:51:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"348caa1a-b510-476b-9d23-cee5547e8f5c","html_url":"https://github.com/sonicoder86/babel-webpack-tree-shaking","commit_stats":null,"previous_names":["sonicoder86/babel-webpack-tree-shaking"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sonicoder86/babel-webpack-tree-shaking","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonicoder86%2Fbabel-webpack-tree-shaking","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonicoder86%2Fbabel-webpack-tree-shaking/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonicoder86%2Fbabel-webpack-tree-shaking/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonicoder86%2Fbabel-webpack-tree-shaking/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sonicoder86","download_url":"https://codeload.github.com/sonicoder86/babel-webpack-tree-shaking/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonicoder86%2Fbabel-webpack-tree-shaking/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269355207,"owners_count":24403403,"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","status":"online","status_checked_at":"2025-08-08T02:00:09.200Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["babel","babili","tree-shaking","webpack"],"created_at":"2024-11-10T00:07:07.168Z","updated_at":"2025-08-08T02:39:36.499Z","avatar_url":"https://github.com/sonicoder86.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tree-shaking example with Babel and Webpack\n[![devDependency Status](https://david-dm.org/blacksonic/babel-webpack-tree-shaking/dev-status.svg)](https://david-dm.org/blacksonic/babel-webpack-tree-shaking?type=dev)\n\nThis repository shows how to configure Babel 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 + Babel + UglifyJS\n\nCan only remove unused functions and variables.\n\nFor development build run ```npm run webpack``` (ES2015 -\u003e ES5 bundle).\n\nFor production build run ```npm run webpack-prod``` (ES2015 -\u003e ES5 bundle -\u003e UglifyJS).\n\nWhen transpiling classes with Babel, 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 + Babili\n\nCan remove unused classes, functions and variables.\n\nFor development build run ```npm run webpack-es2015``` (ES2015 -\u003e ES2015 bundle).\n\nFor production build run ```npm run webpack-es2015-prod``` (ES2015 -\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%2Fbabel-webpack-tree-shaking","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsonicoder86%2Fbabel-webpack-tree-shaking","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsonicoder86%2Fbabel-webpack-tree-shaking/lists"}