Skip to content

Commit

Permalink
fix: fix module entry redirect on Windows (fix #55)
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed May 5, 2020
1 parent 59b8638 commit 01135fa
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/node/serverPluginModuleResolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import resolve from 'resolve-from'
import { Plugin } from './server'
import { resolveVue } from './vueResolver'
import { cachedRead } from './utils'
import slash from 'slash'

const debug = require('debug')('vite:resolve')

Expand Down Expand Up @@ -53,7 +54,7 @@ export const moduleResolvePlugin: Plugin = ({ root, app }) => {
const cachedEntry = idToEntryMap.get(id)
if (cachedEntry) {
debug(`(cached redirect) ${id} -> ${cachedEntry}`)
return ctx.redirect(path.join(ctx.path, cachedEntry))
return ctx.redirect(slash(path.join(ctx.path, cachedEntry)))
}

// resolve from web_modules
Expand All @@ -72,7 +73,7 @@ export const moduleResolvePlugin: Plugin = ({ root, app }) => {

const entryPoint = await resolveNodeModuleEntry(root, id)
if (entryPoint) {
return ctx.redirect(path.join(ctx.path, entryPoint))
return ctx.redirect(slash(path.join(ctx.path, entryPoint)))
}

// resolve from node_modules
Expand Down

0 comments on commit 01135fa

Please sign in to comment.