wombleton / semistandard-loader

Lint webpack builds with Flet/semistandard.
3 stars 2 forks source link

Failing with last version of webpack #3

Open chris-zen opened 6 years ago

chris-zen commented 6 years ago

I get the following error when executing webpack (version 4.17.1):

ERROR in ./src/index.js
Module build failed (from ./node_modules/semistandard-loader/index.js):
TypeError: Cannot read property 'semistandard' of undefined
    at Object.semistandardLoader (/.../node_modules/semistandard-loader/index.js:14:18)

My webpack.config.js looks like:

const webpack = require('webpack');
const path = require('path');
var fs = require('fs');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');

var nodeModules = {};
fs.readdirSync('node_modules')
  .filter(function(x) {
    return ['.bin'].indexOf(x) === -1;
  })
  .forEach(function(mod) {
    nodeModules[mod] = 'commonjs ' + mod;
  });

module.exports = {
  target: 'node',

  module: {

    rules: [
      {
        // set up semistandard-loader as a preloader
        enforce: 'pre',
        test: /\.jsx?$/,
        loader: 'semistandard-loader',
        exclude: /(node_modules|bower_components)/,

        options: {
          parser: 'babel-eslint',
          snazzy: true,
          error: false
        }
      },
      {
        include: [path.resolve(__dirname, 'src')],
        loader: 'babel-loader',

        options: {
          plugins: ['syntax-dynamic-import'],
        },

        test: /\.js$/
      }
    ]
  },

  entry: {
    app: './src/index.js'
  },

  output: {
    filename: 'backend.bundle.js',
    path: path.resolve(__dirname, 'dist')
  },

  mode: 'development',

  externals: nodeModules,

  plugins: [
    new webpack.IgnorePlugin(/\.(css|less)$/),
  ],
  devtool: 'sourcemap',

  optimization: {
    splitChunks: {
      cacheGroups: {
        vendors: {
          priority: -10,
          test: /[\\/]node_modules[\\/]/
        }
      },

      chunks: 'async',
      minChunks: 1,
      minSize: 30000,
      name: true
    }
  }
};

standard-loader works fine.

I can fix the problem by replacing the following code in node_modules/semistandard-loader/index.js:

var config = assign(
    this.options.semistandard || {},
    loaderUtils.parseQuery(this.query)
  );

with:

var config = assign(
    (this.options || {}).semistandard || {},
    loaderUtils.parseQuery(this.query)
  );
angelo-msg commented 4 years ago

Has anything been done to address this?