Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
empty-module-loader
Advanced tools
A webpack loader that replaces module with empty function.
npm install --save-dev empty-module-loader
webpack.config.js
module.exports = {
module: {
rules: [
{
test: /path-to-match-module/,
loader: 'empty-module-loader'
}
]
}
}
That is it! All the related codes should be removed in production.
This config is for demonstration only.
webpack.config.js
const path = require('path')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
module.exports = {
entry: './src/index.js',
output: {
filename: 'main.js',
path: path.resolve(__dirname, 'dist'),
},
module: {
rules: [
{
test: /debug/,
loader: require.resolve('empty-module-loader')
},
],
},
optimization: {
minimizer: [
new UglifyJsPlugin({
uglifyOptions: {
warnings: false,
mangle: false,
ie8: false,
output: {
preserve_line: true,
comments: true,
indent_level: 2,
},
},
}),
],
},
}
src/index.js
import debug from './debug'
console.log('normal code')
debug('booting %o', 3)
console.log('normal code')
src/debug.js
export default function debug (...args) {
console.log('debug:', ...args)
}
npm init -y
npm install webpack webpack-cli uglifyjs-webpack-plugin --save-dev
npx webpack --config webpack.config.js
/************************************************************************/
/******/([
/* 0 */
/***/function(module,__webpack_exports__,__webpack_require__){
"use strict"
;__webpack_require__.r(__webpack_exports__);// removed by empty-module-loader
// CONCATENATED MODULE: ./src/index.js
console.log("normal code"),
console.log("normal code")
/***/}
/******/]);
FAQs
A webpack loader that replaces module with empty function.
We found that empty-module-loader 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.