webpack-contrib / Thread Loader
Licence: mit
Runs the following loaders in a worker pool
Stars: ✭ 945
Programming Languages
javascript
184084 projects - #8 most used programming language
Projects that are alternatives of or similar to Thread Loader
Markdown Loader
markdown loader for webpack
Stars: ✭ 335 (-64.55%)
Mutual labels: webpack, webpack-loader, loader
Wasm Loader
✨ WASM webpack loader
Stars: ✭ 604 (-36.08%)
Mutual labels: webpack, webpack-loader, loader
Stylefmt Loader
Webpack-loader. Fixes stylelint issues automatically while bundling with Webpack.
Stars: ✭ 24 (-97.46%)
Mutual labels: webpack, webpack-loader, loader
Sass Vars Loader
Use Sass variables defined in Webpack config or in external Javascript or JSON files
Stars: ✭ 112 (-88.15%)
Mutual labels: webpack, webpack-loader, loader
Svgr
Transform SVGs into React components 🦁
Stars: ✭ 8,263 (+774.39%)
Mutual labels: webpack, webpack-loader, loader
Sass Loader
Compiles Sass to CSS
Stars: ✭ 3,718 (+293.44%)
Mutual labels: webpack, webpack-loader, 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 (-88.89%)
Mutual labels: webpack, webpack-loader, loader
Phaser Ce Npm Webpack Typescript Starter Project
Project to get you started with your Phaser-CE (using the npm module) game using Typescript and Webpack for building! No hassle asset management, Google Web Font loader, live server, development vs distribution build pipeline, Electron packaging for desktop builds, and more...
Stars: ✭ 414 (-56.19%)
Mutual labels: webpack, loader
Inject Loader
💉📦 A Webpack loader for injecting code into modules via their dependencies.
Stars: ✭ 474 (-49.84%)
Mutual labels: webpack-loader, loader
Angular Hmr
🔥 Angular Hot Module Replacement for Hot Module Reloading
Stars: ✭ 490 (-48.15%)
Mutual labels: webpack, loader
Hamsters.js
100% Vanilla Javascript Multithreading & Parallel Execution Library
Stars: ✭ 517 (-45.29%)
Mutual labels: multithreading, thread
React Imported Component
✂️📦Bundler-independent solution for SSR-friendly code-splitting
Stars: ✭ 525 (-44.44%)
Mutual labels: webpack, loader
Comlink Loader
Webpack loader to offload modules to Worker threads seamlessly using Comlink.
Stars: ✭ 535 (-43.39%)
Mutual labels: webpack, webpack-loader
Extract Loader
webpack loader to extract HTML and CSS from the bundle
Stars: ✭ 297 (-68.57%)
Mutual labels: webpack, webpack-loader
Inline Style Loader
inline style loader for webpack
Stars: ✭ 16 (-98.31%)
Mutual labels: webpack, webpack-loader
Interlace
Easily turn single threaded command line applications into a fast, multi-threaded application with CIDR and glob support.
Stars: ✭ 760 (-19.58%)
Mutual labels: multithreading, thread
thread-loader
Runs the following loaders in a worker pool.
Getting Started
npm install --save-dev thread-loader
Put this loader in front of other loaders. The following loaders run in a worker pool.
Loaders running in a worker pool are limited. Examples:
- Loaders cannot emit files.
- Loaders cannot use custom loader API (i. e. by plugins).
- Loaders cannot access the webpack options.
Each worker is a separate node.js process, which has an overhead of ~600ms. There is also an overhead of inter-process communication.
Use this loader only for expensive operations!
Examples
webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.js$/,
include: path.resolve('src'),
use: [
'thread-loader',
// your expensive loader (e.g babel-loader)
],
},
],
},
};
with options
use: [
{
loader: 'thread-loader',
// loaders with equal options will share worker pools
options: {
// the number of spawned workers, defaults to (number of cpus - 1) or
// fallback to 1 when require('os').cpus() is undefined
workers: 2,
// number of jobs a worker processes in parallel
// defaults to 20
workerParallelJobs: 50,
// additional node.js arguments
workerNodeArgs: ['--max-old-space-size=1024'],
// Allow to respawn a dead worker pool
// respawning slows down the entire compilation
// and should be set to false for development
poolRespawn: false,
// timeout for killing the worker processes when idle
// defaults to 500 (ms)
// can be set to Infinity for watching builds to keep workers alive
poolTimeout: 2000,
// number of jobs the poll distributes to the workers
// defaults to 200
// decrease of less efficient but more fair distribution
poolParallelJobs: 50,
// name of the pool
// can be used to create different pools with elsewise identical options
name: 'my-pool',
},
},
// your expensive loader (e.g babel-loader)
];
prewarming
To prevent the high delay when booting workers it possible to warmup the worker pool.
This boots the max number of workers in the pool and loads specified modules into the node.js module cache.
const threadLoader = require('thread-loader');
threadLoader.warmup(
{
// pool options, like passed to loader options
// must match loader options to boot the correct pool
},
[
// modules to load
// can be any module, i. e.
'babel-loader',
'babel-preset-es2015',
'sass-loader',
]
);
Contributing
Please take a moment to read our contributing guidelines if you haven't yet done so.
License
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].