Security News
The Dark Side of Open Source
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
add-module-exports-webpack-plugin
Advanced tools
Readme
Add
module.exports
for Babel and TypeScript compiled code
When 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.
$ npm install add-module-exports-webpack-plugin
const AddModuleExportsPlugin = require('add-module-exports-webpack-plugin');
module.exports = {
// …
output: {
filename: 'dist/index.js',
libraryTarget: 'commonjs2'
},
plugins: [
new AddModuleExportsPlugin()
]
};
output.libraryTarget
must be commonjs2
When 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.
module.exports.default = (arg1, arg2) => arg1 + arg2;
module.exports.subtract = (arg1, arg2) => arg1 - arg2;
This module re-exports them as follows.
module.exports = (arg1, arg2) => arg1 + arg2;
module.exports.default = (arg1, arg2) => arg1 + arg2;
module.exports.subtract = (arg1, arg2) => arg1 - arg2;
Because 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
.
NODE_ENV
handlingFAQs
Add `module.exports` for Babel and TypeScript compiled code
The npm package add-module-exports-webpack-plugin receives a total of 74 weekly downloads. As such, add-module-exports-webpack-plugin popularity was classified as not popular.
We found that add-module-exports-webpack-plugin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.