For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /config/build/resolve.md.
close
  • English
  • resolve

    Options for module resolution.

    resolve.aliasStrategy resolve.aliasStrategyresolve.aliasStrategy

    Control the priority between the resolve.alias option and the paths option in tsconfig.json.

    resolve.alias resolve.aliasresolve.alias

    Set the alias for the module path, which is used to simplify the import path or redirect the module reference, similar to the resolve.alias config of Rspack.

    For TypeScript projects, you only need to configure compilerOptions.paths in the tsconfig.json file. Rstest will automatically recognize it, so there is no need to configure the resolve.alias option separately.

    resolve.dedupe resolve.deduperesolve.dedupe

    Force Rstest to resolve the specified packages from project root, which is useful for deduplicating packages and reducing the bundle size.

    resolve.extensions resolve.extensionsresolve.extensions

    Automatically resolve file extensions when importing modules. This means you can import files without explicitly writing their extensions.

    resolve.conditionNames resolve.conditionNamesresolve.conditionNames

    Control the condition names used when resolving the exports field of a package.

    Default: Depends on the test environment and dependency type.

    For node, jsdom, and happy-dom tests, Rstest inherits Rspack's default conditions. With the default NODE_ENV=test, bundled JavaScript dependencies use:

    Test environmentESM importCommonJS require
    nodeimport, module, webpack, development, noderequire, module, webpack, development, node
    jsdom / happy-dombrowser, import, module, webpack, development, nodebrowser, require, module, webpack, development, node

    Rstest treats NODE_ENV=test as development mode for bundling, so development is active even though NODE_ENV is 'test'. The package's exports key order determines which matching entry wins, rather than the order of conditionNames.

    When customizing this option, use '...' to preserve Rspack's default conditions. For example, use conditionNames: ['custom', '...'] in node tests, or conditionNames: ['browser', 'custom', '...'] in jsdom / happy-dom tests. When this option is set explicitly, Rstest no longer adds browser automatically.

    Providing a list without '...' replaces the defaults across dependency types, including the distinction between import and require.

    To remove a default condition while keeping separate ESM and CommonJS resolution, configure tools.rspack.resolve.byDependency. See the Jest migration example, which excludes development and explains when to include browser.

    resolve.mainFields resolve.mainFieldsresolve.mainFields

    Control the priority order of package entry fields such as main, module, and browser.