enable or disable relative path resolution.
a function that resolves a path segment to an absolute path (i.e. a path that the plugin itself can recognize as an absolute path).
this function is utilized by the relativePathResolver
function inside the plugin's body,
and it will operate independent of what your isAbsolutePath function is.
this means that you will have to check for absolute paths yourself,
because every resource that will make its way to the relativePathResolver
will be processed by this resolvePath
function.
in general, there are four checks that your path resolver function should perform in the provided order:
path
is undefined
or an empty string, then the current working directory should be returned.importer
's domain
(for instance, the domain of https://esm.sh/hello/world
would be https://esm.sh/
).
but if no importer
argument is present, then go to the next case (where you'll effectively resolve it as an absolute local unix file path).path
is an absolute path of some kind, you should simply return it as is, after ensuring posix separators ("/"
) are being used.importer
if it is present, otherwise join them with your current working directory (or absWorkingDir
).Optional
path: stringthe path of the resource that is being resolved.
it could be a relative path (i.e. starts with "./"
or "../"
),
or a root-path (i.e. starts with "/"
), or a pre-existing absolute path (such as jsr:@std/jsonc/parses
).
and it may use windows backslashes instead of posix forward slashes, so make sure to handle all of these cases.
Optional
importer: stringwhen an importer file is present, this parameter will be provided,
and you will be expected to join the importer
with the path
if the path
is either relative or a root-path.
do note that the importer is never an empty string.
the absolute path to the provided resource.
a function that declares whether or not a given path segment is an absolute path (i.e. the plugin itself recognizes it as an absolute path).
configuration for the relative-path resolver in resolverPluginSetup.