Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
grunt-amdcheck
Advanced tools
Uses AST to find and remove unused dependencies in AMD modules.
This plugin requires Grunt ~0.4.0
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-amdcheck --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-amdcheck');
When an AMD-based project grows, so does the number of its JS files. Some dependencies of previously used modules may no longer be necessary. The AMD module loader (e.g. requirejs
) loads those useless dependencies from the network, which can increase initial page load time.
This grunt plugin can detect and remove those useless dependencies without modifying source files.
source.js
define('module1', ['p1', 'p2'], function (a, b) {
return a;
});
define('module2', ['p1', 'p2', 'p3'], function (a, b, c) {
return b;
});
optimized-source.js
define('module1', ['p1'], function (a) {
return a;
});
define('module2', ['p2'], function (b) {
return b;
});
Type: Array
Default value: []
An array of strings or RegExps that represent dependency names that should not be taken into account.
Type: Array
Default value: []
An array of strings or RegExps that represent dependency paths that should not be taken into account.
NOTE: exceptsPaths
, followed by a comma-separated list of module paths can be declared before each module definition. This exception is only applied to the underlying module definition.
source.js
/* exceptsPaths: p3 */
define(['p1', 'p2', 'p3'], function (a, b, c) {
return b;
});
optimized-source.js
/* exceptsPaths: p3 */
define(['p2', 'p3'], function (b, c) {
return b;
});
Type: boolean
Default value: false
When strict is true, throws an error if at least one unused dependency path or dependency name was found.
Type: boolean
Default value: false
Logs the id of the module if the module id is specified.
Type: boolean
Default value: false
Logs the list of dependency paths of the module.
Type: boolean
Default value: false
Logs the list of dependency names of the module.
Type: boolean
Default value: true
Logs the list of unused dependency paths of the module.
Type: boolean
Default value: false
Logs the list of unused dependency names of the module.
Type: boolean
Default value: true
Removes detected unused dependencies and saves the new files.
Type: boolean
Default value: false
When removing unused dependencies (i.e. removeUnusedDependencies: true
), only write out files that have unused dependencies.
grunt.initConfig({
amdcheck: {
dev: {
options: {
excepts: ['module'],
exceptsPaths: ['require', /^jquery\./]
},
files: [
{
expand: true,
cwd: 'js/',
src: ['**/*.js'],
dest: 'build/'
}
]
}
}
});
exceptsPaths
can also be defined before each module definition.exceptsPaths
option. Options excepts
and exceptsPaths
can take RegExps.FAQs
Uses AST to find and remove unused dependencies in AMD modules.
The npm package grunt-amdcheck receives a total of 16 weekly downloads. As such, grunt-amdcheck popularity was classified as not popular.
We found that grunt-amdcheck 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’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.