stephencookdev / speed-measure-webpack-plugin

⏱ See how fast (or not) your plugins and loaders are, so you can optimise your builds
MIT License
2.39k stars 80 forks source link

Webpack 2 misc/compile/end missing #30

Open stephencookdev opened 6 years ago

stephencookdev commented 6 years ago

@guptakvgaurav managed to get the following error with his webpack set-up:

Could not find a matching event to end misc compile { fillLast: true }
/Users/ttn/labs/ttn_web/node_modules/speed-measure-webpack-plugin/index.js:104
        throw new Error("No matching event!");
        ^

Error: No matching event!
    at SpeedMeasurePlugin.addTimeEvent (/Users/ttn/labs/ttn_web/node_modules/speed-measure-webpack-plugin/index.js:104:15)
    at Compiler.compiler.plugin (/Users/ttn/labs/ttn_web/node_modules/speed-measure-webpack-plugin/index.js:118:12)
    at Compiler.applyPlugins (/Users/ttn/labs/ttn_web/node_modules/tapable/lib/Tapable.js:61:14)
    at /Users/ttn/labs/ttn_web/node_modules/webpack/lib/Compiler.js:271:13
    at Compiler.emitRecords (/Users/ttn/labs/ttn_web/node_modules/webpack/lib/Compiler.js:367:37)
    at /Users/ttn/labs/ttn_web/node_modules/webpack/lib/Compiler.js:265:12
    at /Users/ttn/labs/ttn_web/node_modules/webpack/lib/Compiler.js:360:11
    at next (/Users/ttn/labs/ttn_web/node_modules/tapable/lib/Tapable.js:218:11)
    at Compiler.compiler.plugin (/Users/ttn/labs/ttn_web/node_modules/webpack/lib/performance/SizeLimitsPlugin.js:99:4)
    at Compiler.applyPluginsAsyncSeries1 (/Users/ttn/labs/ttn_web/node_modules/tapable/lib/Tapable.js:222:13)
    at Compiler.afterEmit (/Users/ttn/labs/ttn_web/node_modules/webpack/lib/Compiler.js:357:8)
    at Compiler.<anonymous> (/Users/ttn/labs/ttn_web/node_modules/webpack/lib/Compiler.js:352:14)
    at /Users/ttn/labs/ttn_web/node_modules/async/dist/async.js:473:16
    at iteratorCallback (/Users/ttn/labs/ttn_web/node_modules/async/dist/async.js:1050:13)
    at /Users/ttn/labs/ttn_web/node_modules/async/dist/async.js:958:16
    at /Users/ttn/labs/ttn_web/node_modules/graceful-fs/graceful-fs.js:43:10

with the following webpack config:

const config = {
    entry: {
      app: ['babel-polyfill', './src/index.js'],
        vendor: ['react', 'react-dom']
    },
    output: {
        filename: 'bundle.js',
        path: path.resolve(__dirname, 'dist'),
        publicPath: '/'
    },
    module: {
        rules: [
            // {
            //     test: /\.json$/,
            //     exclude: [
            //         path.resolve(__dirname, 'node_modules'),
            //     ],
            //     loader: 'json-loader'
            // },
            {
                test: /.(jsx|js)?$/,
                exclude: [
                    path.resolve(__dirname, 'node_modules'),
                ],
                loader: 'babel-loader',
            },
            {
                test: /.(scss|css)$/,
                use: ExtractTextPlugin.extract({
                    fallback: 'style-loader',
                    //resolve-url-loader may be chained before sass-loader if necessary
                    use: [{loader: 'css-loader'}, {loader: 'sass-loader', options: {includePaths: [ './node_modules/bourbon' ]}}]
                }),
            },
            {
                test: /\.(otf|png|jpg|jpeg|gif|ttf|eot|svg|woff|woff2)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
                use: 'url-loader?limit=10000',
            },
            {
                test: /\.yaml$/,
                use: [
                    {loader: 'json-loader'},
                    {loader: 'yaml-loader'},
                ]
            },
            {
                test: /\.html$/,
                loader: 'html-loader'
            }
        ]
    },
    resolve: {
        alias: {
            utils: path.resolve(__dirname, './src/utils'),
            constants: path.resolve(__dirname, './src/constants'),
            components: path.resolve(__dirname, './src/app/components'),
            containers: path.resolve(__dirname, './src/app/containers'),
            core: path.resolve(__dirname, './src/app/core'),
            lodashC: path.resolve(__dirname, './src/js/lodash.custom.min.js')
        },
        extensions: ['.js', '.jsx'],
    },
    devtool: 'source-map',
    plugins: [
        // new CleanWebpackPlugin(pathsToClean, cleanOptions),
        // new BundleAnalyzerPlugin(),
        new ExtractTextPlugin({
            filename:'style.css',
            disable: false
        }),
        new webpack.optimize.CommonsChunkPlugin({
            names: 'vendor',
            filename: 'vendor.js'
        }),
        new webpack.DefinePlugin({
            'VENDOR': JSON.stringify(process.env.VENDOR),
            'NODE_ENV': JSON.stringify(process.env.NODE_ENV),
            "process.env": {
                "NODE_ENV": JSON.stringify(process.env.NODE_ENV),
            }
        }),
        new HtmlWebpackPlugin({
            filename: 'index.html',
            template: 'src/index.html'
        }),
        new LiveReloadPlugin(),
        new WebpackBrowserPlugin({
            port: 3000,
            url: 'http://127.0.0.1'
        }),
    ]
};

module.exports = smp.wrap(config);

webpack version - 2.6 smp version - 1.1.3

stephencookdev commented 6 years ago

@guptakvgaurav - this is a bit of an odd error to me. Basically it means that you've hit the "compile/end" flow without ever hitting the "compile/start" flow :thinking:

Would you mind sharing how you're running webpack? I.e. what command are you calling, are you in run-mode or watch-mode, etc. etc.?

appienvanveen commented 6 years ago

I've got the same issue with Wepack 3.10. I'm running the generated setup created by Jhipster. Any idea?

appienvanveen commented 6 years ago

Solved it. It appeared I've had an older version of the merge-jsons-webpack-plugin. I was using 1.0.11. Updating to 1.0.15 solved the issue.

vidal7 commented 5 years ago

I am getting this error with webpack 4 Could not find a matching event to end plugins Object/Compiler/afterEmit Is this related to this issue?

ikobe-zz commented 5 years ago

webpack 4 +1

I write a plugin with following:

class DemoPlugin {
  constructor(options) {
    assert(options, 'options is required');
  }
  public apply(compiler) {
    compiler.hooks.done.tapAsync('monitor', (stats, callback) => {
      console.log('xxx);
      setTimeout(callback(), 1000);
    });
  }
}

The error message is:

Could not find a matching event to end plugins DemoPlugin/Compiler/done { id: 12136 }

If I use compiler.hooks.done.tap, the error message will disappear

It seems like speed-measure-webpack-plugin cannot support tapAsync function

ikobe-zz commented 5 years ago

Solved it. I fix it by using setImmediate:

compiler.hooks.done.tapAsync('monitor', (stats, callback) => {
  console.log('xxx);
  setImmediate(async () => { callback() });
});
sarahquigley commented 5 years ago

@stephencookdev I am encountering a similar error: Could not find a matching event to end plugins CopyPlugin/Compiler/afterEmit { id: 28 }

jrnail23 commented 5 years ago

I'm getting the same as @vidal7 (Could not find a matching event to end plugins Object/Compiler/afterEmit) when using stylelint-webpack-plugin.

fengzilong commented 5 years ago

@stephencookdev I am encountering a similar error: Could not find a matching event to end plugins CopyPlugin/Compiler/afterEmit { id: 28 }

the same error for copy-webpack-plugin with webpack4

dave-educode commented 4 years ago

I am having this same problem as fengzilong with the copy-webpack-plugin. I would really like to fix this. Any ideas?