Skip to content

Customising the Module Resolver

Bubblyworld edited this page Dec 1, 2014 · 2 revisions

Customising the Module Resolver

By default, a heuristic resolver is used to find module paths. This can be changed by setting the moduleResolver configuration option to a resolver of your choice. The custom resolver must export a resolveModulePath(file, module) method that takes two parameters:

  • file : The path to the file importing the module.
  • module : The module string, e.g. ./foo.

resolveModulePath must return a string containing the full path of the resolved module, or throw an appropriate error if the module cannot be resolved. For example:

resolveModulePath(file, module) {
 ...
 return resolvedModulePath;
 or
 throw new Error("Couldn't find module ...");
 });
}

Clone this wiki locally