Skip to content

Commit

Permalink
🐛 Fix legacy alias warning
Browse files Browse the repository at this point in the history
  • Loading branch information
amoutonbrady committed Mar 25, 2021
1 parent 7e9bec8 commit 847cdfe
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
: [];

// TODO: remove when fully removed from vite
userConfig.alias = normalizeAliases(userConfig.alias)
const legacyAlias = normalizeAliases(userConfig.alias);

if (!userConfig.resolve) userConfig.resolve = {}
userConfig.resolve.alias = normalizeAliases(userConfig.resolve?.alias)
if (!userConfig.resolve) userConfig.resolve = {};
userConfig.resolve.alias = [...legacyAlias, ...normalizeAliases(userConfig.resolve?.alias)];

return mergeAndConcat(userConfig, {
/**
Expand All @@ -43,10 +43,7 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
resolve: {
conditions: ['solid'],
dedupe: ['solid-js', 'solid-js/web'],
alias: [
{ find: /^solid-refresh$/, replacement: runtimePublicPath },
...alias,
],
alias: [{ find: /^solid-refresh$/, replacement: runtimePublicPath }, ...alias],
},
optimizeDeps: {
include: ['solid-js/dev', 'solid-js/web'],
Expand Down Expand Up @@ -107,6 +104,5 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
function normalizeAliases(alias: AliasOptions = []): Alias[] {
return Array.isArray(alias)
? alias
: Object.entries(alias).map(([find, replacement]) => ({ find, replacement }))
: Object.entries(alias).map(([find, replacement]) => ({ find, replacement }));
}

0 comments on commit 847cdfe

Please sign in to comment.