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

Commit b3fc54e

Browse files
committed
refactor: impove hash check
1 parent 63051db commit b3fc54e

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

server/app.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -652,9 +652,10 @@ export class Application implements ServerApplication {
652652
if (
653653
!this.#reloading &&
654654
(isRemote && !url.startsWith('http://localhost:')) &&
655+
reFullVersion.test(url) &&
655656
mod.sourceHash !== ''
656657
) {
657-
const jsFile = util.cleanPath(saveDir + '/' + name + '.js')
658+
const jsFile = path.join(saveDir, name + '.js')
658659
if (existsFileSync(jsFile)) {
659660
shouldFetch = false
660661
}
@@ -671,9 +672,16 @@ export class Application implements ServerApplication {
671672
}
672673
}
673674

674-
// compute hash
675-
mod.hash = isRemote ? mod.sourceHash : computeHash(mod.sourceHash + JSON.stringify(this.defaultCompileOptions))
676-
mod.jsFile = util.cleanPath(saveDir + '/' + name + (isRemote ? '' : `.${mod.hash.slice(0, hashShortLength)}`) + '.js')
675+
mod.hash = computeHash(
676+
mod.sourceHash +
677+
JSON.stringify(this.defaultCompileOptions) +
678+
this.config.plugins.filter(isLoaderPlugin).map(({ name }) => name).join(',')
679+
)
680+
if (isRemote) {
681+
mod.jsFile = util.cleanPath(`${saveDir}/${name}.js`)
682+
} else {
683+
mod.jsFile = `${saveDir}/${name}.${mod.hash.slice(0, hashShortLength)}.js`
684+
}
677685

678686
// check previous compilation output if the source content doesn't changed.
679687
if (!shouldCompile && !existsFileSync(mod.jsFile)) {

0 commit comments

Comments
 (0)