How to use thread-loader - 8 common examples

To help you get started, we’ve selected a few thread-loader examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github elastic / kibana / src / optimize / base_optimizer.js View on Github external
warmupThreadLoaderPool() {
    const baseModules = [
      'babel-loader',
      BABEL_PRESET_PATH
    ];

    threadLoader.warmup(
      // pool options, like passed to loader options
      // must match loader options to boot the correct pool
      this.getThreadLoaderPoolConfig(),
      [
        // modules to load on the pool
        ...baseModules,
      ]
    );
  }
github codesandbox / codesandbox-client / packages / app / config / webpack.common.js View on Github external
})
    .join('\n')}
  },
  processors: {
      ".vue": require("eslint-plugin-vue/lib/processor")
  }
}`;

const sepRe = `\\${path.sep}`; // path separator regex

const threadPoolConfig = {
  workers: 2,
};

if (!isLint) {
  threadLoader.warmup(threadPoolConfig, ['babel-loader']);
}

module.exports = {
  entry: SANDBOX_ONLY
    ? {
        sandbox: [
          require.resolve('./polyfills'),
          path.join(paths.sandboxSrc, 'index.js'),
        ],
        'sandbox-startup': path.join(paths.sandboxSrc, 'startup.js'),
      }
    : {
        app: [
          require.resolve('./polyfills'),
          path.join(paths.appSrc, 'index.js'),
        ],
github BryanAdamss / vue-awesome-template / build / webpack.base.conf.js View on Github external
const createLintingRule = () => ({
  test: /\.(js|vue)$/,
  loader: 'eslint-loader',
  enforce: 'pre',
  include: [resolve('src'), resolve('test')],
  options: {
    formatter: require('eslint-friendly-formatter'),
    emitWarning: !config.dev.showEslintErrorsInOverlay
  }
})

// * 2020-0103- 添加thread-loader
// https://medium.com/@shinychang/webpack-%E6%9C%80%E4%BD%B3%E5%8C%96-thread-loader-bd18471ffb4c
const threadLoader = require('thread-loader')
const jsWorkerPool = { poolTimeout: 2000 }
threadLoader.warmup(jsWorkerPool, ['babel-loader']) // 预热

module.exports = {
  context: path.resolve(__dirname, '../'),
  entry: {
    app: './src/main.js'
  },
  output: {
    path: config.build.assetsRoot,
    filename: '[name].js',
    // * 2019-0111-调整开发、生产环境输出的包名
    chunkFilename: utils.assetsPath('js/[name].[chunkhash].js'),
    publicPath:
      process.env.NODE_ENV === 'production'
        ? config.build.assetsPublicPath
        : config.dev.assetsPublicPath
  },
github MyCryptoHQ / MyCrypto / webpack_config / makeConfig.js View on Github external
};

  if (options.isProduction) {
    entry.vendor = config.vendorModules;
  }

  // ====================
  // ====== Rules =======
  // ====================
  const rules = [];

  // Typescript
  if (options.isProduction || !process.env.SLOW_BUILD_SPEED) {
    rules.push(config.typescriptRule);
  } else {
    threadLoader.warmup(config.typescriptRule.use[0].options, [
      config.typescriptRule.use[0].loader
    ]);
    rules.push({
      ...config.typescriptRule,
      use: [
        {
          loader: 'thread-loader',
          options: {
            workers: 4
          }
        },
        ...config.typescriptRule.use
      ]
    });
  }
github Naturalclar / expo-typescript-starter / .storybook / webpack.config.js View on Github external
module.exports = ({ config, mode }) => {
  if (mode !== "PRODUCTION") {
    threadLoader.warmup(babelWorkerOptions, ["babel-loader"]);
    threadLoader.warmup(tsWorkerOptions, ["babel-loader"]);
  }
  config.module.rules.push({
    test: /\.tsx?$/,
    exclude: /node_modules/,
    use: [
      { loader: "cache-loader" },
      { loader: "thread-loader", options: tsWorkerOptions },
      {
        loader: "babel-loader",
        options: {
          presets: ["@babel/preset-typescript"]
        }
      }
    ]
  });
github Naturalclar / expo-typescript-starter / .storybook / webpack.config.js View on Github external
module.exports = ({ config, mode }) => {
  if (mode !== "PRODUCTION") {
    threadLoader.warmup(babelWorkerOptions, ["babel-loader"]);
    threadLoader.warmup(tsWorkerOptions, ["babel-loader"]);
  }
  config.module.rules.push({
    test: /\.tsx?$/,
    exclude: /node_modules/,
    use: [
      { loader: "cache-loader" },
      { loader: "thread-loader", options: tsWorkerOptions },
      {
        loader: "babel-loader",
        options: {
          presets: ["@babel/preset-typescript"]
        }
      }
    ]
  });
github fullstack-development / react-redux-starter-kit / webpack / common.ts View on Github external
const threadLoader: webpack.Loader[] = (() => {
  if (process.env.THREADED === 'true') {
    const workerPool = {
      workers: require('os').cpus().length - 1,
      poolTimeout: withHot ? Infinity : 2000,
    };
    isWatchMode && threadLoaderLib.warmup(workerPool, ['babel-loader', 'ts-loader', 'postcss-loader', 'sass-loader']);
    return [{ loader: 'thread-loader', options: workerPool }];
  }
  return [];
})();

thread-loader

Runs the following loaders in a worker pool

MIT
Latest version published 2 months ago

Package Health Score

89 / 100
Full package analysis

Popular thread-loader functions