addyosmani / webpack-lighthouse-plugin

A Webpack plugin for Lighthouse
Apache License 2.0
290 stars 12 forks source link

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

Closed steveworkman closed 5 years ago

steveworkman commented 5 years ago

Originally raised in https://github.com/vuejs/vue-cli/issues/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?

evenstensberg commented 5 years ago

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

steveworkman commented 5 years ago

@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

evenstensberg commented 5 years ago

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

patrickhulce commented 5 years ago

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

steveworkman commented 5 years ago

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: https://github.com/vuejs/vue-cli/issues/3394 - honestly I don't know any more about this than what they've said

patrickhulce commented 5 years ago

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.

evenstensberg commented 5 years ago

I'll have a look at it next week!

evenstensberg commented 5 years ago

Fixed now, please close issue once you have verified.

steveworkman commented 5 years ago

Yep, that works. Thanks a lot!