{"id":19138064,"url":"https://github.com/lemonpi/issues_webpack_classname","last_synced_at":"2026-06-14T01:31:52.463Z","repository":{"id":73435523,"uuid":"151347170","full_name":"LemonPi/issues_webpack_classname","owner":"LemonPi","description":"Minimum demo of webpack classname mangling issue","archived":false,"fork":false,"pushed_at":"2019-03-11T15:43:03.000Z","size":44,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-13T01:20:45.222Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/LemonPi.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,"publiccode":null,"codemeta":null}},"created_at":"2018-10-03T01:41:15.000Z","updated_at":"2019-03-11T15:43:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"46e42a2a-d535-45e6-8628-8c4bf4918f1a","html_url":"https://github.com/LemonPi/issues_webpack_classname","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/LemonPi/issues_webpack_classname","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LemonPi%2Fissues_webpack_classname","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LemonPi%2Fissues_webpack_classname/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LemonPi%2Fissues_webpack_classname/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LemonPi%2Fissues_webpack_classname/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LemonPi","download_url":"https://codeload.github.com/LemonPi/issues_webpack_classname/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LemonPi%2Fissues_webpack_classname/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34306772,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-13T02:00:06.617Z","response_time":62,"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":[],"created_at":"2024-11-09T06:41:37.378Z","updated_at":"2026-06-14T01:31:52.194Z","avatar_url":"https://github.com/LemonPi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Problem\n\nwebpack is mangling class names.\n\n```javascript\nexport class Test {\n    constructor() {\n        this.test = 1;\n    }\n}\n\nTest.name; // should be \"Test\", but is instead some mangled character like \"n\"\nTest.prototype.constructor.name; // similar to above\n```\n\nTest this out with\n```\nnpm run start\n```\n\nAnd use console to evaluate the expressions on the `lib` library.\n\n## Solution\n\nThe current webpack configuration solves this issue by explicitly keeping function and class names:\n\n```\n    optimization: {\n        minimizer: [\n            new UglifyJSPlugin({\n                cache        : true,\n                parallel     : true,\n                uglifyOptions: {\n                    compress: true,\n                    ecma    : 6,\n                    keep_fnames: true,\n                    keep_classnames: true,\n                },\n                sourceMap    : true\n            })\n\n        ]\n    },\n```\n\nAlthough UglifyJS only works on ES5, so we have to pull in Babel as well:\n\n```\n    module      : {\n        rules: [\n            {\n                test   : /\\.js$/,\n                include: [/src/],\n                use    : {\n                    loader : 'babel-loader',\n                    options: {\n                        presets: ['@babel/preset-env']\n                    }\n                }\n            },\n        ]\n    },\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemonpi%2Fissues_webpack_classname","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flemonpi%2Fissues_webpack_classname","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemonpi%2Fissues_webpack_classname/lists"}