Skip to content

Commit

Permalink
fix(vite plugin): some vite plugins do not provide alias configuratio…
Browse files Browse the repository at this point in the history
…n errors (#1278)

* fix(plugin): some vite's plugins do not provide `alias` configuration, resulting in errors

* intercept at the location where getAliasEntries are obtained

* changeset `@farmfe/core` patch
  • Loading branch information
RSS1102 committed May 3, 2024
1 parent 807911e commit 28e1a37
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/nine-schools-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@farmfe/core': patch
---

fix(vite plugin): some vite plugins do not provide `alias` configuration errors
2 changes: 1 addition & 1 deletion packages/core/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export async function resolveConfig(
resolvedUserConfig.rustPlugins = rustPlugins;

// Temporarily dealing with alias objects and arrays in js will be unified in rust in the future.]
if (resolvedUserConfig.compilation.resolve?.alias && vitePlugins.length) {
if (vitePlugins.length) {
resolvedUserConfig.compilation.resolve.alias = getAliasEntries(
resolvedUserConfig.compilation.resolve.alias
);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/utils/plugin-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function throwError(pluginName: string, type: string, error: Error) {
export function getAliasEntries(
entries: Record<string, string> | Array<Alias>
): any {
if (!entries) {
if (!entries || !Object.keys(entries).length) {
return [];
}

Expand Down

0 comments on commit 28e1a37

Please sign in to comment.