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

Fix logger creation when showLogs is false #10

Merged
merged 1 commit into from
Jul 4, 2017

Conversation

sudo-suhas
Copy link
Collaborator

Summary

This PR does 2 things:

  • Fix warning Warning: .then() only accepts functions but was passed: [object Undefined] when showLogs is false(details below)
  • Correctly flow through the given value in log.tap

Details

I was trying out the plugin in vue.js webpack template but got the following warning:

(node:452) Warning: .then() only accepts functions but was passed: [object Undefined]
webpack.dev.conf.js
var path = require('path');
var utils = require('./utils')
var webpack = require('webpack')
var config = require('../config')
var merge = require('webpack-merge')
var baseWebpackConfig = require('./webpack.base.conf')
var AutoDllPlugin = require('autodll-webpack-plugin')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')

// add hot-reload related code to entry chunks
Object.keys(baseWebpackConfig.entry).forEach(function (name) {
  baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name])
})

module.exports = merge(baseWebpackConfig, {
  module: {
    rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap })
  },
  // cheap-module-eval-source-map is faster for development
  devtool: '#cheap-module-eval-source-map',
  plugins: [
    new webpack.DefinePlugin({
      'process.env': config.dev.env
    }),
    // https://github.com/glenjamin/webpack-hot-middleware#installation--usage
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoEmitOnErrorsPlugin(),
    // https://github.com/ampedandwired/html-webpack-plugin
    new HtmlWebpackPlugin({
      filename: 'index.html',
      template: 'index.html',
      inject: true
    }),
    new AutoDllPlugin({
      inject: true,
      context: path.join(__dirname, '..'),
      filename: '[name]_[hash].js',
      path: './dll',
      entry: {
        vendor: [
          'vue',
          'vue-router'
        ]
      }
    }),
    new FriendlyErrorsPlugin()
  ]
})

Stack Trace
(node:2948) Warning: .then() only accepts functions but was passed: [object Undefined]
Warning: .then() only accepts functions but was passed: [object Undefined]
    at compileIfNeeded (E:\Projects\experiments\vue-test\node_modules\autodll-webpack-plugin\lib\compileIfNeeded.js:75:6)
    at Compiler.onRun (E:\Projects\experiments\vue-test\node_modules\autodll-webpack-plugin\lib\plugin.js:84:73)
    at Compiler.applyPluginsAsyncSeries (E:\Projects\experiments\vue-test\node_modules\tapable\lib\Tapable.js:142:13)
    at Watching._go (E:\Projects\experiments\vue-test\node_modules\webpack\lib\Compiler.js:42:16)
    at Watching.<anonymous> (E:\Projects\experiments\vue-test\node_modules\webpack\lib\Compiler.js:33:8)
    at Compiler.readRecords (E:\Projects\experiments\vue-test\node_modules\webpack\lib\Compiler.js:388:10)
    at new Watching (E:\Projects\experiments\vue-test\node_modules\webpack\lib\Compiler.js:30:16)
    at Compiler.watch (E:\Projects\experiments\vue-test\node_modules\webpack\lib\Compiler.js:219:17)
    at Object.startWatch (E:\Projects\experiments\vue-test\node_modules\webpack-dev-middleware\lib\Shared.js:169:29)
    at Shared (E:\Projects\experiments\vue-test\node_modules\webpack-dev-middleware\lib\Shared.js:231:8)
    at module.exports (E:\Projects\experiments\vue-test\node_modules\webpack-dev-middleware\middleware.js:22:15)
    at Object.<anonymous> (E:\Projects\experiments\vue-test\build\dev-server.js:28:54)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (module.js:605:10)
    at startup (bootstrap_node.js:158:16)

Additionally, log.tap logs the given message and passes the result resolved from the promise through to the chain. This was not being done when showLogs was false.

@sudo-suhas sudo-suhas force-pushed the fix_logger_warning branch from bda2d82 to d6fbc6c Compare July 4, 2017 07:24
@asfktz
Copy link
Owner

asfktz commented Jul 4, 2017

Good catch!

Thanks again, @sudo-suhas
It is much appreciated (:

@asfktz asfktz merged commit 6dcc109 into asfktz:master Jul 4, 2017
@sudo-suhas sudo-suhas deleted the fix_logger_warning branch July 4, 2017 17:35
@sudo-suhas
Copy link
Collaborator Author

You are welcome @asfktz 😁

@asfktz asfktz added this to the 0.0.7 milestone Jul 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants