configuration options for the jsrPluginSetup and jsrPlugin functions.

interface JsrPluginSetupConfig {
    filters: RegExp[];
    globalImportMap?: ImportMap;
    resolvePath: (...segments: string[]) => string;
}

Hierarchy

Properties

filters: RegExp[]

the regex filters which the plugin's resolvers should use for the initial interception of resource-paths.

TODO: this might be error-prone, since my parsePackageUrl function requires the specifier to be "jsr:". a better approach might be to use a specifiers field, similar to the npm-plugin's config.specifiers option. but it does come with the downside that the specifier will always be entriely replaced with "jsr:".

[/^jsr\:/] (captures "jsr:" uris)

globalImportMap?: ImportMap

specify a global import-map for aliases to resources.

the full import-map within the body of the resolver function should be a merger between this global import-map, and the import-map acquired from the plugin data (i.e. CommonPluginData.importMap). the plugin data's import-map will take a higher priority in case of conflicting key (i.e. same alias key but different absolute path values).

the resolve function will always look for a match for args.path inside of the import-map, before resolving it with respect to the current importer or resolve-directory (i.e. args.importer or args.resolveDir).

{} (empty object/dictionary)

resolvePath: (...segments: string[]) => string

a function that joins/resolves path segments to an absolute path (i.e. a path that the plugin itself can recognize as an absolute path).

typically, only two or one segments are provided at a time, but it's better if your function accepts variable number of segments.