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

watchRun issue with latest version #63

Closed
tborychowski opened this issue May 9, 2018 · 3 comments
Closed

watchRun issue with latest version #63

tborychowski opened this issue May 9, 2018 · 3 comments

Comments

@tborychowski
Copy link

tborychowski commented May 9, 2018

I updated svelte-loader to the latest version

{
    "svelte": "^2.5.0",
    "svelte-loader": "^2.9.0"
}

and now I'm getting this issue:

[Error running Gulp] Error: ./client/app/index.html
Module build failed: TypeError: Cannot read property 'watchRun' of undefined
    at new VirtualModulesPlugin (/Users/me/project1/node_modules/svelte-loader/lib/virtual.js:35:17)
    at Object.module.exports (/Users/me/project1/node_modules/svelte-loader/index.js:83:46)
 @ ./client/index.js 1:0-24

Edit: this seems to be an issue with the svelte-loader only. When I downgrade to v2.8.1 - everything works.

@tborychowski tborychowski changed the title watchRun issue with latest webpack watchRun issue with latest version May 9, 2018
@perifer
Copy link

perifer commented Jun 14, 2018

Looking at the referenced https://github.com/sysgears/webpack-virtual-modules they do this:

    var watchRunHook = function(watcher, callback) {
        self._watcher = watcher.compiler || watcher;
        callback();
    }

    if (compiler.hooks) {
        compiler.hooks.watchRun.tapAsync('VirtualModulesPlugin', watchRunHook);
    } else {
        compiler.plugin("watch-run", watchRunHook);
    }

My very limited understanding of this from reading through the commits of the above repo is that compiler.hooks is for older versions of Webpack.

@SimulatedGREG
Copy link
Contributor

SimulatedGREG commented Jul 26, 2018

After testing @perifer's comment, I did some more research and found that compiler.hooks were introduced in [email protected], so all previous versions will get the watchRun error. Applying this change with [email protected] fixes the issue.

Given that not everybody may be able to update to v4 just yet, I've made a PR to support older versions. #68

Rich-Harris added a commit that referenced this issue Aug 2, 2018
@Rich-Harris
Copy link
Member

Fixed in 2.10.1, thanks @SimulatedGREG!

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

No branches or pull requests

4 participants