Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 2.1.0-beta.25 causes parseQuery should get a string as first argument #3060

Closed
wlingke opened this issue Sep 24, 2016 · 7 comments
Closed

Comments

@wlingke
Copy link

wlingke commented Sep 24, 2016

I'm submitting a bug report

Webpack version:
2.x

Please tell us about your environment:
Windows 10

Current behavior:
I recently upgraded to webpack 2 beta 25 from beta 20. In beta 20, my entire configuration worked and the compilation worked. Upgrading to webpack 25 causes this error:

image

I'm running the compiler script using babel-node.

import webpack from 'webpack';
import _debug from 'debug';

const debug = _debug('build:webpack-compiler');
const DEFAULT_STATS_FORMAT = {
  chunks: false,
  chunkModules: false,
  colors: true,
};

export default function webpackCompiler(webpackConfig, statsFormat = DEFAULT_STATS_FORMAT) {
  return new Promise((resolve, reject) => {
    const compiler = webpack(webpackConfig);

    /* eslint-disable consistent-return */
    compiler.run((err, stats) => {
      if (err) {
        debug('Webpack compiler encountered a fatal error.', err);
        return reject(err);
      }

      const jsonStats = stats.toJson();
      debug('Webpack compile completed.');
      debug(stats.toString(statsFormat));

      if (jsonStats.errors.length > 0) {
        debug('Webpack compiler encountered errors.');
        debug(jsonStats.errors.join('\n'));
        return reject(new Error('Webpack compiler encountered errors'));
      } else if (jsonStats.warnings.length > 0) {
        debug('Webpack compiler encountered warnings.');
        debug(jsonStats.warnings.join('\n'));
      } else {
        debug('No errors or warnings encountered.');
      }
      resolve(jsonStats);
    });
  });
}
  • Language: [all | TypeScript X.X | ES6/7 | ES5 | Dart | ...]
    ES6/7
@stevewillard
Copy link

Instead of loaders and query in your webpack config, you need to update them to the new rules and options:

https://github.com/webpack/webpack.js.org/blob/develop/content/how-to/upgrade-from-webpack-1.md#moduleloaders-is-now-modulerules

@gkostyanikov
Copy link

Having hard times debugging this and still no luck.

webpack 2.1.0-beta.25
osx el captain

my config:

var webpack = require('webpack');
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ManifestRevisionPlugin = require('manifest-revision-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');

var rootAssetPath = './public/assets';

module.exports = {

  entry: { 
    bundle: [ 'babel-polyfill', 'tether', __dirname + "/app/scripts/app.js" ],
    //trick: [ __dirname + "/app/scripts/Trick.js" ],
    //hit: [ __dirname + "/app/scripts/Hit.js" ]
    //test: [ __dirname + "/app/scripts/test.js" ]
  },

  output: {
    path: path.join(__dirname, 'public', 'assets'),
    filename: '[name].js'
  },

  module: {

    noParse: [
      path.resolve(__dirname, "public"),
      path.resolve(__dirname, "data"),
      path.resolve(__dirname, "data-raw"),
      path.resolve(__dirname, "vendor"),
    ],

    rules: [

      {
        test: /\.$|\.js$|\.jsx$|\.es6$/,
        include: [
          path.resolve(__dirname, "app/scripts"),
          path.resolve(__dirname, "app/vendor")
        ],
        exclude: /node_modules/,
        loader: 'babel',
        options: {
          presets: [
            ['es2015', { modules: false }],
            'react',
            'stage-0',
          ]
        }
      },

      {
        test: /\.css$/,
        use: [
          { loader: 'style' },
          { loader: 'css' },
          { loader: 'postcss' },
        ]
      },

      {
        test: /\.scss$/,
        use: [
          { loader: 'style' },
          { loader: 'css' },
          { loader: 'postcss' },
          { loader: 'sass' },
        ],
        include: [
          path.resolve(__dirname, "app/styles"),
          path.resolve(__dirname, "app/vendor")
        ]
      },

      {
        test: /\.(eot|woff|woff2|ttf|svg|png|jpe?g|gif)(\?\S*)?$/,
        loader: 'url',
        options: {
          limit: '100000',
          name: '[name].[ext]'
        }
      }

    ]
  },
  plugins: [
    new webpack.ProvidePlugin({
      "window.Tether": "tether",
      $: "jquery",
      jQuery: "jquery",
      "window.jQuery": "jquery"
    }),
    new webpack.NoErrorsPlugin(),
    new ManifestRevisionPlugin('./manifest.json', {
      rootAssetPath: rootAssetPath,
      ignorePaths: ['/styles', '/scripts', '/images', '.DS_Store']
    }),
    new CopyWebpackPlugin([
      { from: './app/images' }
    ]),
    new webpack.LoaderOptionsPlugin({
      options: {
        postcss: [ require('autoprefixer')]
      }
    })
  ]
}

I guess something with loader options section because when i've removed

        options: {
          presets: [
            ['es2015', { modules: false }],
            'react',
            'stage-0',
          ]
        }

and moved babel configuration to .babelrc webpack stopped to show errors with this loader and started to show up errors with next loader which has options section (url loader).

@stevewillard
Copy link

In your rule config try using use instead of loader or loaders

It looks like you missed that change for your url-loader and your babel-loader

@gkostyanikov
Copy link

Unfortunately i've tried more verbose syntax with use's everywhere without success just before the more compact version posted above. I've only omitted use section where only one loader in chain(babel, url) following this example http://webpack.js.org/configuration/. Here is the rewritten version with use's that throws the same error:

var webpack = require('webpack');
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ManifestRevisionPlugin = require('manifest-revision-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');

var rootAssetPath = './public/assets';

module.exports = {

  entry: { 
    bundle: [ 'babel-polyfill', 'tether', __dirname + "/app/scripts/app.js" ],
    //trick: [ __dirname + "/app/scripts/Trick.js" ],
    //hit: [ __dirname + "/app/scripts/Hit.js" ]
    //test: [ __dirname + "/app/scripts/test.js" ]
  },

  output: {
    path: path.join(__dirname, 'public', 'assets'),
    filename: '[name].js'
  },

  module: {

    noParse: [
      path.resolve(__dirname, "public"),
      path.resolve(__dirname, "data"),
      path.resolve(__dirname, "data-raw"),
      path.resolve(__dirname, "vendor"),
    ],

    rules: [

      {
        test: /\.$|\.js$|\.jsx$|\.es6$/,
        include: [
          path.resolve(__dirname, "app/scripts"),
          path.resolve(__dirname, "app/vendor")
        ],
        exclude: /node_modules/,
        use: [
          {
            loader: 'babel',
            options: {
              presets: [
                ['es2015', { modules: false }],
                'react',
                'stage-0',
              ]
            }
          }
        ]
      },

      {
        test: /\.css$/,
        use: [
          { loader: 'style' },
          { loader: 'css' },
          { loader: 'postcss' },
        ]
      },

      {
        test: /\.scss$/,
        use: [
          { loader: 'style' },
          { loader: 'css' },
          { loader: 'postcss' },
          { loader: 'sass' },
        ],
        include: [
          path.resolve(__dirname, "app/styles"),
          path.resolve(__dirname, "app/vendor")
        ]
      },

      {
        test: /\.(eot|woff|woff2|ttf|svg|png|jpe?g|gif)(\?\S*)?$/,
        use: [
          {
            loader: 'url',
            options: {
              limit: '100000',
              name: '[name].[ext]'
            }
          }
        ]
      }

    ]
  },
  plugins: [
    new webpack.ProvidePlugin({
      "window.Tether": "tether",
      $: "jquery",
      jQuery: "jquery",
      "window.jQuery": "jquery"
    }),
    new webpack.NoErrorsPlugin(),
    new ManifestRevisionPlugin('./manifest.json', {
      rootAssetPath: rootAssetPath,
      ignorePaths: ['/styles', '/scripts', '/images', '.DS_Store']
    }),
    new CopyWebpackPlugin([
      { from: './app/images' }
    ]),
    new webpack.LoaderOptionsPlugin({
      options: {
        postcss: [ require('autoprefixer')]
      }
    })
  ]
}

@alexichepura
Copy link

There is old loader-utils in webpack's package.json "loader-utils": "^0.2.11"
But only latest 0.2.16 is now compatible with webpack 2. For some reason it didn't updated.
Short fix:
npm i loader-utils

@lukeapage
Copy link
Contributor

Thanks @achicu I got the same problem and was trying to work it out as your message came through. That fixes it for me.

@gkostyanikov
Copy link

@AlexChepura thanks, finally it works!)

@sokra sokra closed this as completed Sep 24, 2016
lukeapage added a commit to lukeapage/webpack that referenced this issue Sep 26, 2016
sokra added a commit that referenced this issue Sep 27, 2016
Update loader utils dependency to fix #3060
SteveVanOpstal added a commit to SteveVanOpstal/LegendBuilder that referenced this issue Oct 6, 2016
amsdamsgram added a commit to amsdamsgram/webpack that referenced this issue Oct 6, 2016
* master: (77 commits)
  remove-automatic-loader-extension: update examples
  fix-2986: Remove automatic -loader module name extension
  replaced calls to Object.assign with objectAssign to support node 0.12.x (webpack#3080)
  docs(example): update examples template (webpack#3074)
  Fix plugin typos in options validation
  feat(readme): add jsbeautify-loader to readme (webpack#3062)
  Update loader utils dependency to fix webpack#3060
  add number for schema info
  2.1.0-beta.25
  fix test
  fixed Validation message
  fixed dll test cases
  fixed browsertest
  added a note about applying the LoaderOptionsPlugin only for some modules
  added another custom error message for the debug property
  Adds empty into schema for node (webpack#3034)
  Moving parsing of the `progress` flag to webpack specific bin
  2.1.0-beta.24
  beautify
  fixed max line length
  ...
leonaves added a commit to leonaves/babel-loader that referenced this issue Feb 7, 2017
Anything below 0.2.16 for loader-utils causes issues with webpack 2 (webpack/webpack#3060 (comment) and I have replicated the issue)
danez pushed a commit to babel/babel-loader that referenced this issue Feb 7, 2017
Anything below 0.2.16 for loader-utils causes issues with webpack 2 (webpack/webpack#3060 (comment) and I have replicated the issue)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants