Documentation
    Preparing search index...

    Encapsulates the API to resolve import specifiers with the ability to define custom resolver functions.

    The PathsResolver provides a caching mechanism to avoid resolving the same specifier multiple times and supports custom resolvers for handling special import patterns like path aliases.

    const resolver = new PathsResolver()
    resolver.use((specifier) => '/custom/path/' + specifier)
    const resolved = resolver.resolve('#app/models/user')
    Index

    Constructors

    Methods

    Constructors

    Methods

    • Define a custom resolver that resolves a path

      The custom resolver function will be used instead of the default import.meta.resolve() for resolving import specifiers.

      Parameters

      • resolver: (specifier: string) => string

        Function that takes a specifier and returns resolved path

      Returns void

    • Resolve import specifier to an absolute file path

      This method caches resolved paths to improve performance on repeated resolutions. Relative paths are not supported and will throw an error.

      Parameters

      • specifier: string

        The import specifier to resolve (must not be relative)

      Returns string

      The resolved absolute file path

      Error when attempting to resolve relative paths

      const path = resolver.resolve('#app/models/user')
      const path2 = resolver.resolve('@/utils/helper')