Skip to content

Commit

Permalink
fix: HMR reload (resolver side-effects) (#213)
Browse files Browse the repository at this point in the history
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
  • Loading branch information
azaleta and antfu committed Jun 29, 2022
1 parent 4cd3ccd commit d153511
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/core/resolvers.ts
Expand Up @@ -48,8 +48,13 @@ export function resolversAddon(resolvers: Resolver[]): Addon {
const dynamic: ImportExtended[] = []
const sideEffects: ImportExtended[] = []
await Promise.all([...names].map(async (name) => {
if (matched.find(i => i.as === name))
const matchedImport = matched.find(i => i.as === name)
if (matchedImport) {
if ('sideEffects' in matchedImport)
sideEffects.push(...toArray((matchedImport as ImportExtended).sideEffects).map(i => normalizeImport(i, '')))

return
}
const resolved = await firstMatchedResolver(resolvers, name)
if (resolved)
dynamic.push(resolved)
Expand Down

0 comments on commit d153511

Please sign in to comment.