Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions docs/config/shared-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Directory to save cache files. Files in this directory are pre-bundled deps or s
## resolve.alias

- **Type:**
`Record<string, string> | Array<{ find: string | RegExp, replacement: string, customResolver?: ResolverFunction | ResolverObject }>`
`Record<string, string> | Array<{ find: string | RegExp, replacement: string }>`

Defines aliases used to replace values in `import` or `require` statements. This works similar to [`@rollup/plugin-alias`](https://github.com/rollup/plugins/tree/master/packages/alias).

Expand All @@ -119,7 +119,7 @@ resolve: {
}
```

### Array Format (`Array<{ find: string | RegExp, replacement: string, customResolver?: ResolverFunction | ResolverObject }>`)
### Array Format (`Array<{ find: string | RegExp, replacement: string }>`)

The Array format allows specifying aliases as objects, which can be useful for complex key/value pairs.

Expand All @@ -138,8 +138,6 @@ When `find` is a regular expression, the `replacement` can use [replacement patt
{ find:/^(.*)\.js$/, replacement: '$1.alias' }
```

`customResolver` option can be used to provide separate module resolution for an individual alias.

## resolve.dedupe

- **Type:** `string[]`
Expand Down
1 change: 1 addition & 0 deletions docs/guide/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ The following options are deprecated and will be removed in the future:
- `worker.rollupOptions`: renamed to `worker.rolldownOptions`
- `build.commonjsOptions`: it is now no-op
- `build.dynamicImportVarsOptions.warnOnError`: it is now no-op
- `resolve.alias[].customResolver`: Use a custom plugin with `resolveId` hook instead

## General Changes [<Badge text="NRV" type="warning" />](#migration-from-v7)

Expand Down
9 changes: 9 additions & 0 deletions packages/vite/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,15 @@ function resolveResolveOptions(
),
)
}
if (alias.some((a) => a.customResolver)) {
logger.warn(
colors.yellow(
`\`resolve.alias\` contains an alias with \`customResolver\` option. ` +
`This is deprecated and will be removed in Vite 9. ` +
`Please use a custom plugin with a resolveId hook instead.`,
),
)
}

return resolveEnvironmentResolveOptions(
resolve,
Expand Down
1 change: 1 addition & 0 deletions packages/vite/src/types/alias.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface Alias {
* Instructs the plugin to use an alternative resolving algorithm,
* rather than the Rollup's resolver.
* @default null
* @deprecated Use a custom plugin with resolveId hook instead
*/
customResolver?: ResolverFunction | ResolverObject | null
}
Expand Down