
Security News
Node.js Moves Toward Stable TypeScript Support with Amaro 1.0
Amaro 1.0 lays the groundwork for stable TypeScript support in Node.js, bringing official .ts loading closer to reality.
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
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
Amaro 1.0 lays the groundwork for stable TypeScript support in Node.js, bringing official .ts loading closer to reality.
Research
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.
Product
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.