A plugin type: Turn dependency requests into absolute paths (or exclude them)

Resolvers get called with an asset request (consisting of a source file path and the specifier of what is being requested) which it then attempts to resolve. If the resolver isn't sure how to handle a request, it can also return null and pass it to the next resolver in the chain.

import { Resolver } from "@parcel/plugin";

export default new Resolver({
async resolve({ filePath, dependency }) {
if (!shouldHandle(filePath)) {
return null;
// ...
return {
filePath: doResolve({ from: filePath, to: dependency.moduleSpecifier }),

The result object can also contain sideEffects (which corresponds to package.json#sideEffects) code (used instead of fs.readFile(filePath)) and isExcluded (e.g. to exclude node_modules).

ΒΆ Relevant API

ResolveResult parcel/packages/core/types/index.js:1008

type ResolveResultΒ = {|
  +filePath?: FilePath,
  +isExcluded?: boolean,
  +sideEffects?: boolean,
Corresponds to BaseAsset's sideEffects.
  +code?: string,
A resolver might want to resolve to a dummy, in this case filePath is rather "resolve from".
Referenced by:
BaseAsset, Resolver

Resolver parcel/packages/core/types/index.js:1118

type ResolverΒ = {|
    dependency: Dependency,
    options: PluginOptions,
    logger: PluginLogger,
    filePath: FilePath,
  |}): Async<?ResolveResult>,