All Projects β†’ plasticine β†’ Inject Loader

plasticine / Inject Loader

Licence: mit
πŸ’‰πŸ“¦ A Webpack loader for injecting code into modules via their dependencies.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Inject Loader

Vue Pretty Logger
The console is more cool to use, easier to debug, and more fun log output. Enjoy the vue-pretty-logger in the vue project.
Stars: ✭ 150 (-68.35%)
Mutual labels:  webpack-loader, loader
jsx-compress-loader
βš›οΈJSX optimisation loader to reduce size of React application
Stars: ✭ 40 (-91.56%)
Mutual labels:  loader, webpack-loader
Rust Native Wasm Loader
Stars: ✭ 156 (-67.09%)
Mutual labels:  webpack-loader, loader
Markdown Loader
markdown loader for webpack
Stars: ✭ 335 (-29.32%)
Mutual labels:  webpack-loader, loader
Sass Loader
Compiles Sass to CSS
Stars: ✭ 3,718 (+684.39%)
Mutual labels:  webpack-loader, loader
Sass Vars Loader
Use Sass variables defined in Webpack config or in external Javascript or JSON files
Stars: ✭ 112 (-76.37%)
Mutual labels:  webpack-loader, loader
sizeof-loader
Webpack loader that works like url-loader (or file-loader) but with extracted information such as image dimensions and file-size.
Stars: ✭ 20 (-95.78%)
Mutual labels:  loader, webpack-loader
Thread Loader
Runs the following loaders in a worker pool
Stars: ✭ 945 (+99.37%)
Mutual labels:  webpack-loader, loader
markup-inline-loader
a webpack loader to embed svg/MathML to html
Stars: ✭ 24 (-94.94%)
Mutual labels:  loader, webpack-loader
angular-translate-loader
"angular-translate" loader for webpack
Stars: ✭ 15 (-96.84%)
Mutual labels:  loader, webpack-loader
Css Loader
CSS Loader
Stars: ✭ 4,067 (+758.02%)
Mutual labels:  webpack-loader, loader
nunjucks-loader
Webpack loader for Nunjucks templates
Stars: ✭ 20 (-95.78%)
Mutual labels:  loader, webpack-loader
Vue Svg Inline Loader
Webpack loader used for inline replacement of SVG images with actual content of SVG files in Vue projects.
Stars: ✭ 105 (-77.85%)
Mutual labels:  webpack-loader, loader
Style Loader
Style Loader
Stars: ✭ 1,572 (+231.65%)
Mutual labels:  webpack-loader, loader
Svgr
Transform SVGs into React components 🦁
Stars: ✭ 8,263 (+1643.25%)
Mutual labels:  webpack-loader, loader
Pug As Jsx Loader
Stars: ✭ 168 (-64.56%)
Mutual labels:  webpack-loader, loader
Wasm Loader
✨ WASM webpack loader
Stars: ✭ 604 (+27.43%)
Mutual labels:  webpack-loader, loader
Stylefmt Loader
Webpack-loader. Fixes stylelint issues automatically while bundling with Webpack.
Stars: ✭ 24 (-94.94%)
Mutual labels:  webpack-loader, loader
image-minimizer-webpack-plugin
Webpack loader and plugin to compress images using imagemin
Stars: ✭ 180 (-62.03%)
Mutual labels:  loader, webpack-loader
webpack-modernizr-loader
Get your modernizr build bundled with webpack, use modernizr with webpack easily
Stars: ✭ 35 (-92.62%)
Mutual labels:  loader, webpack-loader
 

πŸ’‰πŸ“¦

inject-loader

A Webpack loader for injecting code into modules via their dependencies

build status npm version npm downloads

Why

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.

Usage

Documentation: Using loaders

Use the inject loader by adding the 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.

Examples

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('inject-loader!MyStore')
MyModule = MyModuleInjector({
  'lib/dispatcher': DispatcherMock,
  'events': EventsMock,
  'lib/handle_action': HandleActionMock
})

There are a few examples of complete test setups for both Webpack 1, 2, 3 & 4 in the example folder.

License

MIT (http://www.opensource.org/licenses/mit-license.php)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].