addyosmani/webpack-lighthouse-plugin

Lighthouse plugin causes vue-template-loader to fail to load

steveworkman opened this issue · 9 comments

Originally raised in vuejs/vue-cli#3394

Trying to use this plugin with the VueJS CLI causes the vue-template-loader to fail to load. The Vue team identified this as a problem with Lighthouse mocking the window object.

You can see this reproduced in https://github.com/steveworkman/vue-cli-bug-repo

Is this something that can change?

I'll have a look but most likely this is a bug with lighthouse itself

@evenstensberg I thought so, but I wanted to raise this here first just to be sure. Lighthouse has a lot of open issues, and this is probably a problem with all VueJS CLI applications.

Temporarily, to get lighthouse working,I may be able to set this up as a separate job, but it'll lose this nice webpack integration

I'll see what we can do. @patrickhulce might have some insight here

Hm, I'm not sure what you're referring to with "Lighthouse mocking the window object". I'm not able to load localhost:8080 for that repo in a regular browser outside of a Lighthouse run.

I see


Module build failed (from ./node_modules/vue-loader/lib/index.js):
TypeError: Cannot read property 'parseComponent' of undefined
    at parse (/Users/patrick/Code/Playgrounds/vue-cli-bug-repo/node_modules/@vue/component-compiler-utils/dist/parse.js:14:23)
    at Object.module.exports (/Users/patrick/Code/Playgrounds/vue-cli-bug-repo/node_modules/vue-loader/lib/index.js:67:22)

in the console though, this seems like a different bug

The repo has the bug in it. If you remove the WebpackLighthousePlugin from https://github.com/steveworkman/vue-cli-bug-repo/blob/master/vue.config.js the application runs.

The note of Lighthouse mocking the window object comes from the Vue team in here: vuejs/vue-cli#3394 - honestly I don't know any more about this than what they've said

I'm not denying the existence of the bug :) I'm just saying it happens before Lighthouse is invoked.

Thanks very much for the comment link! I see now what they're saying, window object on the node side!

@evenstensberg you require lighthouse in on the node side? The version of LH this package is using is pretty old and there used to be polyfills to get devtools to work correctly which is probably what's going on. If you update to 4.0 it should go away.

I'll have a look at it next week!

Fixed now, please close issue once you have verified.

Yep, that works. Thanks a lot!