Skip to content

Commit

Permalink
fix: fix alias resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
kricsleo committed Jan 12, 2025
1 parent 997497b commit 04dc449
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
8 changes: 2 additions & 6 deletions src/builders/rollup/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,15 @@ 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";
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);
Expand Down
13 changes: 0 additions & 13 deletions src/builders/rollup/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,6 @@ export function resolveAliases(ctx: BuildContext): Record<string, string> {
return aliases;
}

// TODO: use pathe utils to handle nested aliases
export function resolveAlias(
id: string,
aliases: Record<string, string>,
): 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,
Expand Down

0 comments on commit 04dc449

Please sign in to comment.