
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
@orrisroot/inject-loader
Advanced tools
A Webpack loader for injecting code into modules via their dependencies
A Webpack loader for injecting code into modules via their dependencies
This is particularly useful for writing tests where mocking things inside your module-under-test is sometimes necessary before execution.
inject-loader
was inspired by, and builds upon ideas introduced in jauco/webpack-injectable.
This library has been forked from inject-loader and renamed to @orrisroot/inject-loader for continued maintenance.
Use the inject loader by adding the @orrisroot/inject-loader!
inline loader when you use require
, this will return a function that can used in test code to modify the injected module.
By default all require
statements in an injected module will be altered to be replaced with an injector, though if a replacement it not specified the default values will be used.
Given some code in a module like this:
// MyStore.js
var Dispatcher = require('lib/dispatcher');
var EventEmitter = require('events').EventEmitter;
var handleAction = require('lib/handle_action');
Dispatcher.register(handleAction, 'MyStore');
You can manipulate it’s dependencies when you come to write tests as follows:
// If no flags are provided when using the loader then
// all require statements will be wrapped in an injector
MyModuleInjector = require('@orrisroot/inject-loader!MyStore')
MyModule = MyModuleInjector({
'lib/dispatcher': DispatcherMock,
'events': EventsMock,
'lib/handle_action': HandleActionMock
})
There are a few examples of complete test setups for Webpack 5 in the example
folder.
The source code is licensed MIT. see LICENSE
.
5.0.0
webpack
version to 5 only.babel-core
library to @babel/core@^7
.
FAQs
A Webpack loader for injecting code into modules via their dependencies
The npm package @orrisroot/inject-loader receives a total of 0 weekly downloads. As such, @orrisroot/inject-loader popularity was classified as not popular.
We found that @orrisroot/inject-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
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.