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

Webpack errors are not logged #227

Closed
patope opened this issue Feb 26, 2017 · 7 comments
Closed

Webpack errors are not logged #227

patope opened this issue Feb 26, 2017 · 7 comments

Comments

@patope
Copy link

patope commented Feb 26, 2017

I'm submitting a feature request

Webpack version:
2.x

Webpack Karma version:
2.0.x

Karma version:
1.x

Please tell us about your environment:
OSX 10.x

Current behavior:
karma-webpack do not log webpack configuration issues. Simply reports

26 02 2017 22:08:57.640:ERROR [preprocess]: Can not load "webpack"!
  Error
    at webpack (..../node_modules/webpack/lib/webpack.js:19:9)

code here https://github.com/webpack-contrib/karma-webpack/blob/v2/src/karma-webpack.js#L65

Expected/desired behavior:
Instead karma-webpack should catch expcetion thrown by webpack and log message on exception.

Replacing above line with

  var compiler;
  try {
    compiler = webpack(webpackOptions);
  } catch(e) {
    console.error(e.message);
    throw e;
  }

Report is

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.module has an unknown property 'preLoaders'. These properties are valid:
   object { exprContextCritical?, exprContextRecursive?, exprContextRegExp?, exprContextRequest?, loaders?, noParse?, rules?, unknownContextCritical?, unknownContextRecursive?, unknownContextRegExp?, unknownContextRequest?, unsafeCache?, wrappedContextCritical?, wrappedContextRecursive?, wrappedContextRegExp? }
   Options affecting the normal modules (`NormalModuleFactory`).
 - configuration.resolve.extensions[0] should not be empty.
26 02 2017 22:08:57.640:ERROR [preprocess]: Can not load "webpack"!
  Error
    at webpack (..../webpack/lib/webpack.js:19:9)
  • What is the motivation / use case for changing the behavior?
    Make easier to resolve webpack configuration issues.
@joshwiens
Copy link
Contributor

That's not an error, that is a malformed configuration.

Everything you need to resolve the issues with your configuration are in the stack you pasted in.

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.module has an unknown property 'preLoaders'. These properties are valid:
   object { exprContextCritical?, exprContextRecursive?, exprContextRegExp?, exprContextRequest?, loaders?, noParse?, rules?, unknownContextCritical?, unknownContextRecursive?, unknownContextRegExp?, unknownContextRequest?, unsafeCache?, wrappedContextCritical?, wrappedContextRecursive?, wrappedContextRegExp? }
   Options affecting the normal modules (`NormalModuleFactory`).
 - configuration.resolve.extensions[0] should not be empty.

@patope
Copy link
Author

patope commented Feb 27, 2017

@d3viant0ne yes, i know. But, that is not point of this report. Could you reread this?

karma-webpack currently keeps this information hidden from user and reports only Can not load "webpack"!. Which is not very informative and generates unneccessary support requests for you.

@joshwiens joshwiens reopened this Feb 27, 2017
@joshwiens
Copy link
Contributor

joshwiens commented Feb 27, 2017

@patope - Sorry, I misread the first part. I'll have this fixed and out to npm shortly.

@marcusellis05
Copy link

Do you have an ETA on the fix?

@joshwiens
Copy link
Contributor

@marcusellis05 - It's next on my list after css-loader to go out. Couple of hours to npm

@ghost
Copy link

ghost commented Jan 23, 2018

I am getting this error only when running npm test which runs karma start --single-run. Normal webpack works fine:

Version: webpack 3.10.0
Time: 8108ms

My entry is not empty as this error states
Error trace when running npm test:

WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.entry should be one of these:
   object { <key>: non-empty string | [non-empty string] } | non-empty string | [non-empty string] | function
   -> The entry point(s) of the compilation.
   Details:
    * configuration.entry should not be empty.
      -> Multiple entry bundles are created. The key is the chunk name. The value can be a string or an array.
    * configuration.entry should be a string.
      -> An entry point without name. The string is resolved to a module which is loaded upon startup.
    * configuration.entry should be an array:
      [non-empty string]
    * configuration.entry should be an instance of function
      -> A Function returning an entry object, an entry string, an entry array or a promise to these things.
    at webpack (C:\l\node_modules\webpack\lib\webpack.js:19:9)
    at new Plugin (C:\node_modules\karma-webpack\lib\karma-webpack.js:69:16)

webpack entry:

module.exports = {
    resolve: {
        extensions: ['.js', '.ts']
    },
    devtool:'source-map',
    entry: {
        background: './src/background',
        content: './src/content',
        'url-listener': './src/url-listener',
        frame: './src/frame',
        options: './src/options',
        popup: './src/popup'
    },
"devDependencies": {
    "@types/chai": "^4.0.10",
    "@types/mocha": "^2.2.32",
    "chai": "^4.1.2",
    "chai-as-promised": "^7.1.1",
    "copy-webpack-plugin": "^4.3.1",
    "css-loader": "^0.28.7",
    "cucumber": "^3.2.1",
    "cucumber-html-report": "^0.6.3",
    "file-loader": "^1.1.6",
    "finalhandler": "^1.0.0",
    "html-loader": "^0.5.1",
    "html-webpack-plugin": "^2.9.0",
    "htmlhint": "^0.9.12",
    "htmlhint-loader": "^1.3.0",
    "json-loader": "^0.5.4",
    "karma": "^2.0.0",
    "karma-chai": "^0.1.0",
    "karma-chrome-launcher": "^2.2.0",
    "karma-mocha": "^1.0.1",
    "karma-webpack": "^2.0.9",
    "mocha": "^5.0.0",
    "protractor": "^5.2.2",
    "protractor-cucumber-framework": "^4.1.1",
    "raw-loader": "^0.5.1",
    "restify": "^6.3.4",
    "serve-static": "^1.11.1",
    "style-loader": "^0.19.1",
    "ts-loader": "^3.3.1",
    "ts-node": "^4.1.0",
    "tslint": "^5.8.0",
    "tslint-loader": "^3.5.3",
    "typescript": "^2.0.3",
    "url-loader": "^0.6.2",
    "webpack": "^3.10.0",
    "ws": "^4.0.0"
  }
/*eslint-disable no-var*/

var webpackConfig = require('./webpack.config.js');
webpackConfig.entry = {};


module.exports = function(config) {
    config.set({
        basePath: '',
        frameworks: ['mocha', 'chai'],
        files: [
            'test/unit/**/*.spec.ts'
        ],
        exclude: [
        ],
        preprocessors: {
            'test/unit/**/*.ts': ['webpack']
        },
        reporters: ['progress'],
        port: 9876,
        colors: true,

        // level of logging
        // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
        logLevel: config.LOG_INFO,


        // enable / disable watching file and executing tests whenever any file changes
        autoWatch: true,
        browsers: ['Chrome'],

        // Continuous Integration mode
        // if true, Karma captures browsers, runs the tests and exits
        singleRun: false,

        // Concurrency level
        // how many browser should be started simultaneous
        concurrency: Infinity,

        webpack: webpackConfig,

        webpackMiddleware: {
            noInfo: true
        }
    });
};

@ghost
Copy link

ghost commented Jan 23, 2018

let me know if I should open a new thread

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

3 participants