Skip to content

Commit

Permalink
fix: fix HMR in windows port
Browse files Browse the repository at this point in the history
  • Loading branch information
Je committed Oct 25, 2020
1 parent f2a98b0 commit 86bb340
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ export class Project {
log.info('Start watching code changes...')
for await (const event of w) {
for (const p of event.paths) {
const path = '/' + util.trimPrefix(util.trimPrefix(p, this.appRoot), '/')
const path = util.cleanPath(util.trimPrefix(p, this.appRoot))
// handle `api` dir remove directly
const validated = (() => {
if (!reModuleExt.test(path) && !reStyleModuleExt.test(path) && !reMDExt.test(path)) {
Expand Down Expand Up @@ -1429,7 +1429,7 @@ Object.assign(globalThis, {

/** inject HMR and React Fast Referesh helper code */
export function injectHmr({ id, sourceFilePath, jsContent }: Module): string {
let hmrImportPath = path.relative(
let hmrImportPath = getRelativePath(
path.dirname(sourceFilePath),
'/-/deno.land/x/aleph/hmr.js'
)
Expand Down
2 changes: 1 addition & 1 deletion server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export async function start(appDir: string, port: number, isDev = false, reload
type: 'update',
moduleId: mod.id,
hash,
updateUrl: path.join('/', project.config.baseUrl, '/_aleph/', mod.id.replace(/\.js$/, '') + `.${hash!.slice(0, hashShort)}.js`)
updateUrl: util.cleanPath(`${project.config.baseUrl}/_aleph/${mod.id.replace(/\.js$/, '')}.${hash!.slice(0, hashShort)}.js`)
})))
}
}
Expand Down
2 changes: 1 addition & 1 deletion util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export default {
},
splitPath(path: string): string[] {
return path
.split('/')
.split(/[\/\\]/g)
.map(p => p.trim())
.filter(p => p !== '' && p !== '.')
.reduce((path, p) => {
Expand Down

0 comments on commit 86bb340

Please sign in to comment.