webpack-contrib / thread-loader

Runs the following loaders in a worker pool
MIT License
1.11k stars 68 forks source link

Cannot read property 'outputOptions' of undefined #66

Open FuncWei opened 5 years ago

FuncWei commented 5 years ago

Compile prompt me: Module build failed: Thread Loader (Worker 0) Cannot read property 'outputOptions' of undefined at PoolWorker.fromErrorObj(...)

alexander-akait commented 5 years ago

Please use issue template

likeavenus commented 4 years ago

Hi, I have the same problem after I abandoned the isomorphic style loader and added a mini css extract pluginin css config:

`import autoprefixer from 'autoprefixer'; import mqpacker from 'css-mqpacker'; import calc from 'postcss-calc'; import partialImport from 'postcss-partial-import'; import postcssUrl from 'postcss-url'; import cssvariables from 'postcss-css-variables'; import mediaVariables from 'postcss-media-variables'; import path from 'path'; import { warmup } from 'thread-loader'; import resolveConfig from '../resolve'; const MiniCssExtractPlugin = require('mini-css-extract-plugin');

warmup({}, [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader']); const css = isDev => ({ test: /.css$/, exclude: /nodemodules/, use: [ 'thread-loader', { loader: MiniCssExtractPlugin.loader, }, { loader: 'css-loader', options: { modules: true, sourceMap: isDev, importLoaders: 1, localIdentName: '[name][local][hash:base64:5]', minimize: isDev, onlyLocals: true, discardComments: { removeAll: true } } }, { loader: 'postcss-loader', options: { ident: 'postcss', plugins: [

      partialImport({
        resolve(id, basedir) {
          if (!/\.css$/.test(id)) id = `${id}.css`;

          // Webpack aliases
          const alias = resolveConfig.alias;
          const aliasesKeys = Object.keys(alias);
          let resolveId;
          for (let alias of aliasesKeys) {
            if (new RegExp(`^${alias}`).test(id)) {
              resolveId = `./${id}`;
              break;
            }
          }

          if (resolveId) {
            return path.resolve(resolveId);
          }

          // From folder
          if (/^\./.test(id)) return path.resolve(basedir, id);

          // Node modules
          return path.resolve('./node_modules', id);
        }
      }),
      mediaVariables(),
      cssvariables(),
      calc(),
      autoprefixer({
        browsers: ['>1%', 'last 4 versions', 'Firefox ESR', 'not ie < 9']
      }),
      postcssUrl,
      mediaVariables(),
      mqpacker
    ]
  }
},

], });

export default css; `

AprilArcus commented 2 years ago

Similar error originates here, in the case of css modules.

https://github.com/webpack-contrib/css-loader/blob/v6.2.0/src/utils.js#L530

The loaderContext passed to getModulesOptions does not have a _compilation key. It originates as the loaders this https://github.com/webpack-contrib/css-loader/blob/v6.2.0/src/index.js.

vagusX commented 2 years ago

How's going?

thl3538 commented 1 year ago

How's going?

xsfxtsxxr commented 2 months ago

Try to use "css-loader": "1.0.1" and "thread-loader": "^3.0.4"