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

Commit 36e2e29

Browse files
committed
fix: fix checkCompilationSideEffect method
1 parent f883598 commit 36e2e29

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

server/app.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ export class Application {
11851185

11861186
/** check compilation side-effect caused by dependency graph. */
11871187
private async checkCompilationSideEffect(url: string, callback?: (mod: Module) => void) {
1188-
const { hash, sourceHash } = this.#modules.get(url)!
1188+
const { hash } = this.#modules.get(url)!
11891189

11901190
for (const mod of this.#modules.values()) {
11911191
for (const dep of mod.deps) {
@@ -1204,22 +1204,18 @@ export class Application {
12041204
}
12051205
return s
12061206
})
1207-
let bundlingJS: string | null = null
1208-
if (mod.bundlingFile && existsFileSync(mod.bundlingFile)) {
1209-
bundlingJS = await Deno.readTextFile(mod.bundlingFile)
1210-
bundlingJS = bundlingJS.replace(reHashResolve, (s, key, spaces, ql, importPath, qr) => {
1211-
if (importPath.replace(reHashJs, '') === relativePath) {
1212-
return `${key}${spaces}${ql}${relativePath}.${util.shortHash(sourceHash)}.js${qr}`
1213-
}
1214-
return s
1215-
})
1216-
}
12171207
let sourceMap: string | null = null
12181208
if (existsFileSync(mod.jsFile + '.map')) {
12191209
sourceMap = Deno.readTextFileSync(mod.jsFile + '.map')
12201210
}
12211211
mod.hash = computeHash(jsContent + buildChecksum)
12221212
mod.jsFile = `${mod.jsFile.replace(reHashJs, '')}.${util.shortHash(mod.hash)}.js`
1213+
jsContent = jsContent.split('\n').map(line => {
1214+
if (line.startsWith('//# sourceMappingURL=')) {
1215+
return `//# sourceMappingURL=${path.basename(mod.jsFile).replace(reHashJs, '')}.${util.shortHash(mod.hash)}.js.map`
1216+
}
1217+
return line
1218+
}).join('\n')
12231219
await cleanupCompilation(mod.jsFile)
12241220
await Promise.all([
12251221
ensureTextFile(mod.jsFile.replace(reHashJs, '') + '.meta.json', JSON.stringify({
@@ -1229,7 +1225,6 @@ export class Application {
12291225
deps: mod.deps,
12301226
}, undefined, 4)),
12311227
ensureTextFile(mod.jsFile, jsContent),
1232-
bundlingJS ? ensureTextFile(mod.bundlingFile, bundlingJS) : Promise.resolve(),
12331228
sourceMap ? ensureTextFile(mod.jsFile + '.map', sourceMap) : Promise.resolve(),
12341229
])
12351230
callback && callback(mod)

0 commit comments

Comments
 (0)