From 04dc4499827a1898d73e0864e019c94ff033af5e Mon Sep 17 00:00:00 2001 From: kricsleo Date: Sun, 12 Jan 2025 16:47:49 +0800 Subject: [PATCH] fix: fix alias resolution --- src/builders/rollup/config.ts | 8 ++------ src/builders/rollup/utils.ts | 13 ------------- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/src/builders/rollup/config.ts b/src/builders/rollup/config.ts index 02547109..375c10c4 100644 --- a/src/builders/rollup/config.ts +++ b/src/builders/rollup/config.ts @@ -4,6 +4,7 @@ import { nodeResolve } from "@rollup/plugin-node-resolve"; import alias from "@rollup/plugin-alias"; import replace from "@rollup/plugin-replace"; import { resolve, isAbsolute } from "pathe"; +import { resolveAlias } from "pathe/utils"; import { arrayIncludes, getpkg, warn } from "../../utils"; import type { BuildContext, RollupOptions } from "../../types"; import { esbuild } from "./plugins/esbuild"; @@ -11,12 +12,7 @@ import { JSONPlugin } from "./plugins/json"; import { rawPlugin } from "./plugins/raw"; import { cjsPlugin } from "./plugins/cjs"; import { shebangPlugin } from "./plugins/shebang"; -import { - DEFAULT_EXTENSIONS, - getChunkFilename, - resolveAlias, - resolveAliases, -} from "./utils"; +import { DEFAULT_EXTENSIONS, getChunkFilename, resolveAliases } from "./utils"; export function getRollupOptions(ctx: BuildContext): RollupOptions { const _aliases = resolveAliases(ctx); diff --git a/src/builders/rollup/utils.ts b/src/builders/rollup/utils.ts index 29083a1e..55205099 100644 --- a/src/builders/rollup/utils.ts +++ b/src/builders/rollup/utils.ts @@ -40,19 +40,6 @@ export function resolveAliases(ctx: BuildContext): Record { return aliases; } -// TODO: use pathe utils to handle nested aliases -export function resolveAlias( - id: string, - aliases: Record, -): string { - for (const [find, replacement] of Object.entries(aliases)) { - if (id.startsWith(find)) { - return id.replace(find, replacement); - } - } - return id; -} - export function getChunkFilename( ctx: BuildContext, chunk: PreRenderedChunk,