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

throw signature changed error when running with happypack #439

Open
budlion opened this issue Sep 20, 2018 · 2 comments
Open

throw signature changed error when running with happypack #439

budlion opened this issue Sep 20, 2018 · 2 comments

Comments

@budlion
Copy link

budlion commented Sep 20, 2018

Error: Signature changed: context parameter added
    at Resolver.resolve (<<project location>>\node_modules\webpack\node_modules\enhanced-resolve\lib\Resolver.js:32:9)
    at Resolver.resolver.resolve (<<project location>>\node_modules\hard-source-webpack-plugin\lib\enhanced-resolve-cache.js:329:22)
    at resolveLoader (<<project location>>\node_modules\happypack\lib\WebpackUtils.js:150:17)
    at <<project location>>\node_modules\happypack\lib\WebpackUtils.js:131:7
    at <<project location>>\node_modules\happypack\node_modules\async\lib\async.js:713:13
    at async.forEachOf.async.eachOf (<<project location>>\node_modules\happypack\node_modules\async\lib\async.js:233:13)
    at _parallel (<<project location>>\node_modules\happypack\node_modules\async\lib\async.js:712:9)
    at Object.async.parallel (<<project location>>\node_modules\happypack\node_modules\async\lib\async.js:726:9)
    at Object.exports.resolveLoaders (<<project location>>\node_modules\happypack\lib\WebpackUtils.js:127:9)
    at resolveLoaders (<<project location>>\node_modules\happypack\lib\HappyPlugin.js:139:20)
    at <<project location>>\node_modules\happypack\node_modules\async\lib\async.js:713:13
    at iterate (<<project location>>\node_modules\happypack\node_modules\async\lib\async.js:262:13)
    at async.forEachOfSeries.async.eachOfSeries (<<project location>>\node_modules\happypack\node_modules\async\lib\async.js:281:9)
    at _parallel (<<project location>>\node_modules\happypack\node_modules\async\lib\async.js:712:9)
    at Object.async.series (<<project location>>\node_modules\happypack\node_modules\async\lib\async.js:734:9)
    at HappyPlugin.start (<<project location>>\node_modules\happypack\lib\HappyPlugin.js:128:9)

webpack: 3.12.0
enhanced-resolve: 3.4.1
happypack: 4.0.1 || 5.0.1

enhanced-resolve 3.x does not support 3 arguments, while hard-source-webpack-plugin will trap the code that try to give resolve 3 arguments.

// enhanced-resolve
Resolver.prototype.resolve = function resolve(context, path, request, callback) {
	if(arguments.length === 3) {
		throw new Error("Signature changed: context parameter added" + arguments[0] + ' ' + arguments[1] + ' ' + arguments[2]);
	}
}
// hard-source-webpack-plugin CacheEnhancedResolve.sj

          if (numArgs === 3) { 
            _resolve.call(this, context, request, callback); // will trap here
          } else if (numArgs === 5) {
            _resolve.call(
              this,
              info,
              context,
              request,
              resolveContext,
              callback,
            );
          } else {
            _resolve.call(this, info, context, request, callback);
          }

Ops! our resolver has 5 arguments ...

// happypack
  function resolveLoader(context, loader, callback) {
    if (compiler.resolverFactory) {
      compiler.resolverFactory.get("loader").resolve({}, context, loader, {}, callback);
    } else {
      var resolve = compiler.resolvers.loader.resolve;
      var resolveContext = compiler.resolvers.loader;

      // webpack2 has changed the signature for the resolve method where it accepts
      // a fourth argument (context), so we need to sniff and support both versions
      //
      // fixes #23
      if (resolve.length === 4) {
        resolve.apply(resolveContext, [ context, context, loader, callback ])
      }
      else {
        resolve.apply(resolveContext, [ context, loader, callback ]);
      }
    }
  }
@dorado-lmz
Copy link

I also met。
Can only change happypack

 if (resolve.length > 3) {
      resolve.apply(resolveContext, [ context, context, loader, callback ])
    }
    else {
      resolve.apply(resolveContext, [ context, loader, callback ]);
    }

@zhangrunhao
Copy link

I also met。
Can only change happypack

 if (resolve.length > 3) {
      resolve.apply(resolveContext, [ context, context, loader, callback ])
    }
    else {
      resolve.apply(resolveContext, [ context, loader, callback ]);
    }

hi . now i can use happypack and hard-source-webpack-plugin .

but i want to ask , why change after can use?
happy is work now ?

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

3 participants