Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit 86bb340

Browse files
author
Je
committed
fix: fix HMR in windows port
1 parent f2a98b0 commit 86bb340

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

project.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ export class Project {
663663
log.info('Start watching code changes...')
664664
for await (const event of w) {
665665
for (const p of event.paths) {
666-
const path = '/' + util.trimPrefix(util.trimPrefix(p, this.appRoot), '/')
666+
const path = util.cleanPath(util.trimPrefix(p, this.appRoot))
667667
// handle `api` dir remove directly
668668
const validated = (() => {
669669
if (!reModuleExt.test(path) && !reStyleModuleExt.test(path) && !reMDExt.test(path)) {
@@ -1429,7 +1429,7 @@ Object.assign(globalThis, {
14291429

14301430
/** inject HMR and React Fast Referesh helper code */
14311431
export function injectHmr({ id, sourceFilePath, jsContent }: Module): string {
1432-
let hmrImportPath = path.relative(
1432+
let hmrImportPath = getRelativePath(
14331433
path.dirname(sourceFilePath),
14341434
'/-/deno.land/x/aleph/hmr.js'
14351435
)

server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export async function start(appDir: string, port: number, isDev = false, reload
4848
type: 'update',
4949
moduleId: mod.id,
5050
hash,
51-
updateUrl: path.join('/', project.config.baseUrl, '/_aleph/', mod.id.replace(/\.js$/, '') + `.${hash!.slice(0, hashShort)}.js`)
51+
updateUrl: util.cleanPath(`${project.config.baseUrl}/_aleph/${mod.id.replace(/\.js$/, '')}.${hash!.slice(0, hashShort)}.js`)
5252
})))
5353
}
5454
}

util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export default {
126126
},
127127
splitPath(path: string): string[] {
128128
return path
129-
.split('/')
129+
.split(/[\/\\]/g)
130130
.map(p => p.trim())
131131
.filter(p => p !== '' && p !== '.')
132132
.reduce((path, p) => {

0 commit comments

Comments
 (0)