> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# resolve

Options for module resolution.

## resolve.aliasStrategy [![resolve.aliasStrategy](https://assets.rspack.rs/rsbuild/rsbuild-logo.svg)resolve.aliasStrategy](https://rsbuild.rs/config/resolve/alias-strategy)
Set the strategy for path alias resolution, to control the priority relationship between the paths option in `tsconfig.json` and the [resolve.alias](/config/rsbuild/resolve.md#resolvealias) option.

## resolve.alias [![resolve.alias](https://assets.rspack.rs/rsbuild/rsbuild-logo.svg)resolve.alias](https://rsbuild.rs/config/resolve/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](https://rspack.rs/config/resolve#resolvealias) config of Rspack.

For TypeScript projects, you only need to configure [compilerOptions.paths](https://www.typescriptlang.org/tsconfig/#paths) in the `tsconfig.json` file. Rslib will automatically recognize it, so there is no need to configure the `resolve.alias` option separately.

It is worth noting that in bundle mode, both `resolve.alias` and [output.externals](/config/rsbuild/output.md#outputexternals) can be used to set aliases, but they differ in the following ways:

- `resolve.alias` is used to replace the target module with another module, which will be bundled into the output.

  For example, if you want to replace `lodash` with `lodash-es` when bundling a package, you can configure it as follows:

  ```ts title="rslib.config.ts"
  export default {
    // ...
    resolve: {
      alias: {
        lodash: 'lodash-es',
      },
    },
  };
  ```

  Now, all `lodash` imports in the source code will be mapped to `lodash-es` and bundled into the output.

- `output.externals` is used to handle alias mapping for externalized modules. Externalized modules are not included in the bundle; instead, they are imported from external sources at runtime.

  For example, if you want to replace externalized modules `react` and `react-dom` with `preact/compat` in the bundle, you can configure it as follows:

  ```ts title="rslib.config.ts"
  export default {
    // ...
    output: {
      externals: {
        react: 'preact/compat',
        'react-dom': 'preact/compat',
      },
    },
  };
  ```

  Now, the code `import { useState } from 'react'` will be replaced with `import { useState } from 'preact/compat'`.

::: note
In bundleless mode, since there is no bundling concept, all modules will be externalized. Rslib will automatically transform the modules resolved to the [outBase](/config/lib/out-base.md) directory based on the mappings configured in `resolve.alias` or [compilerOptions.paths](https://www.typescriptlang.org/tsconfig/#paths) in `tsconfig.json`.
:::

## resolve.conditionNames [![resolve.conditionNames](https://assets.rspack.rs/rsbuild/rsbuild-logo.svg)resolve.conditionNames](https://rsbuild.rs/config/resolve/condition-names)
Specifies the condition names used to match entry points in the [exports field](https://nodejs.org/api/packages.html#exports) of a package.

## resolve.dedupe [![resolve.dedupe](https://assets.rspack.rs/rsbuild/rsbuild-logo.svg)resolve.dedupe](https://rsbuild.rs/config/resolve/dedupe)
Force Rsbuild to resolve the specified packages from project root, which is useful for deduplicating packages and reducing the bundle size.

## resolve.extensions [![resolve.extensions](https://assets.rspack.rs/rsbuild/rsbuild-logo.svg)resolve.extensions](https://rsbuild.rs/config/resolve/extensions)
Automatically resolve file extensions when importing modules. This means you can import files without explicitly writing their extensions.

## resolve.mainFields [![resolve.mainFields](https://assets.rspack.rs/rsbuild/rsbuild-logo.svg)resolve.mainFields](https://rsbuild.rs/config/resolve/main-fields)
Controls the priority of fields in a package.json used to locate a package's entry file. It is the ordered list of package.json fields Rspack will try when resolving an npm package's entry point.
