{"id":15113901,"url":"https://github.com/sindresorhus/add-module-exports-webpack-plugin","last_synced_at":"2025-09-27T17:31:46.466Z","repository":{"id":55410025,"uuid":"113447294","full_name":"sindresorhus/add-module-exports-webpack-plugin","owner":"sindresorhus","description":"Add `module.exports` for Babel and TypeScript compiled code","archived":true,"fork":false,"pushed_at":"2024-04-30T12:04:34.000Z","size":11,"stargazers_count":35,"open_issues_count":0,"forks_count":8,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-29T22:38:20.116Z","etag":null,"topics":["javascript","nodejs","npm-package","webpack","webpack-plugin"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sindresorhus.png","metadata":{"funding":{"github":"sindresorhus","open_collective":"sindresorhus","buy_me_a_coffee":"sindresorhus","custom":"https://sindresorhus.com/donate"},"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","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":"2017-12-07T12:18:20.000Z","updated_at":"2024-05-14T10:41:10.000Z","dependencies_parsed_at":"2024-05-01T20:37:27.994Z","dependency_job_id":null,"html_url":"https://github.com/sindresorhus/add-module-exports-webpack-plugin","commit_stats":{"total_commits":13,"total_committers":5,"mean_commits":2.6,"dds":0.3076923076923077,"last_synced_commit":"6fda5cedd39b7d08f65ec8c0688d69ed25527de1"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fadd-module-exports-webpack-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fadd-module-exports-webpack-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fadd-module-exports-webpack-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fadd-module-exports-webpack-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/add-module-exports-webpack-plugin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234450705,"owners_count":18834569,"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":["javascript","nodejs","npm-package","webpack","webpack-plugin"],"created_at":"2024-09-26T01:40:19.947Z","updated_at":"2025-09-27T17:31:41.212Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://buymeacoffee.com/sindresorhus","https://sindresorhus.com/donate"],"categories":[],"sub_categories":[],"readme":"\u003e [!WARNING]\n\u003e Deprecated. Prefer using JavaScript Modules instead of CommonJS.\n\n# add-module-exports-webpack-plugin\n\n\u003e Add `module.exports` for Babel and TypeScript compiled code\n\nWhen you use ES2015 modules with Babel or have a default export in TypeScript, they generate code which requires you to import it with `require('x').default` in CommonJS instead of `require('x')`. This plugin enables the latter.\n\n## Install\n\n```\n$ npm install add-module-exports-webpack-plugin\n```\n\n## Usage\n\n```js\nconst AddModuleExportsPlugin = require('add-module-exports-webpack-plugin');\n\nmodule.exports = {\n\t// …\n\toutput: {\n\t\tfilename: 'dist/index.js',\n\t\tlibraryTarget: 'commonjs2'\n\t},\n\tplugins: [\n\t\tnew AddModuleExportsPlugin()\n\t]\n};\n```\n\n**`output.libraryTarget` must be `commonjs2`**\n\n### Primitive default exports\n\nWhen exporting a primitive value as default export, other exported values will not be exported anymore. The reason is that this module redeclares the exports as follows.\n\n```js\nmodule.exports.default = (arg1, arg2) =\u003e arg1 + arg2;\nmodule.exports.subtract = (arg1, arg2) =\u003e arg1 - arg2;\n```\n\nThis module re-exports them as follows.\n\n```js\nmodule.exports = (arg1, arg2) =\u003e arg1 + arg2;\nmodule.exports.default = (arg1, arg2) =\u003e arg1 + arg2;\nmodule.exports.subtract = (arg1, arg2) =\u003e arg1 - arg2;\n```\n\nBecause you can't attach properties to a primitive value, it's not possible to re-export the other properties and so you would end up with only a `module.exports`.\n\n## Related\n\n- [node-env-webpack-plugin](https://github.com/sindresorhus/node-env-webpack-plugin) - Simplified `NODE_ENV` handling\n- [add-asset-webpack-plugin](https://github.com/sindresorhus/add-asset-webpack-plugin) - Dynamically add an asset to the webpack graph\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fadd-module-exports-webpack-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Fadd-module-exports-webpack-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fadd-module-exports-webpack-plugin/lists"}