Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
amd-inject-loader
Advanced tools
This is a simple webpack loader that allows you to override any dependency requested at the top of your code file in a normal define
function block. It is currently very limited in scope. It doesn't handle nested require
statements, and it doesn't overwrite or shim the require
method itself.
If you are looking for something that works with CommonJS code, try the inject-loader
.We tried that loader first, but it didn't work with AMD code and didn't work with our code formatting style, so we whipped this up to meet our immediate testing needs. The API is similar, but you don't need to specify ahead of time which dependencies you want to inject or leave alone. Simply pass in whatever injections you want each time you call the factory method. It can even change between tests in the same file.
If working with a code file that looks like this:
myfile.js
define( [ "lodash", "customApi" ], function () {
return {
init: function () {
customApi.run()
}
}
});
You could inject a different customApi
like this:
myfile.spec.js
var myfileInjector = require( "amd-inject!./myfile" );
var myfile = myfileInjector({
customApi: {
run: function () {
console.log( "A new run definition" );
}
}
});
myfile.init(); // Outputs A new run definition
To customize options, add a amdInjectLoader
key to your webpack config file:
{
loaders: [ ... ],
...
amdInjectLoader: {
istanbul: true,
stripComments: true
}
}
istanbul
- true
or false
(Defaults to false
) – Include istanbul ignore blocks on the lines that handle the injectionstripComments
- true
or false
(Defaults to false
) – Strip comments from multiline dependency declarations0.5.0
FAQs
A simple webpack inject loader for AMD-style code
The npm package amd-inject-loader receives a total of 37 weekly downloads. As such, amd-inject-loader popularity was classified as not popular.
We found that amd-inject-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.