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

Commit 52b9aec

Browse files
author
Wenjie Xia
committed
refactor: move compiler build
1 parent adc4662 commit 52b9aec

File tree

7 files changed

+14
-13
lines changed

7 files changed

+14
-13
lines changed

compiler/dist/wasm-checksum.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const checksum = "8c8672abb23f6a74f64d453dbbfe64c9ccd18cd8"
File renamed without changes.

compiler/dist/wasm.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compiler/mod.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { ensureDir, existsSync, path } from '../deps.ts'
22
import { VERSION } from '../version.ts'
3-
import { checksum } from './wasm-checksum.js'
4-
import { default as init_wasm, transformSync } from './wasm-pack.js'
3+
import { checksum } from './dist/wasm-checksum.js'
4+
import { default as init_wasm, transformSync } from './dist/wasm-pack.js'
5+
6+
export const buildChecksum = checksum
57

68
type ImportMap = Record<string, ReadonlyArray<string>>
79

@@ -67,7 +69,7 @@ export const initWasm = async (denoCacheDir: string) => {
6769
const wasmData = await Deno.readFile(cachePath)
6870
await init_wasm(wasmData)
6971
} else {
70-
const { default: getWasmData } = await import('./wasm.js')
72+
const { default: getWasmData } = await import('./dist/wasm.js')
7173
const wasmData = getWasmData()
7274
await init_wasm(wasmData)
7375
await ensureDir(cacheDir)

compiler/wasm-checksum.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

compiler/wasm.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

server/project.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { initWasm, SWCOptions, TransformOptions, transpileSync } from '../compiler/mod.ts'
2-
import { checksum as compilerChecksum } from '../compiler/wasm-checksum.js'
1+
import { buildChecksum, initWasm, SWCOptions, TransformOptions, transpileSync } from '../compiler/mod.ts'
32
import type { AcceptedPlugin, ECMA, ServerRequest } from '../deps.ts'
43
import { CleanCSS, colors, ensureDir, minify, path, postcss, Sha1, Sha256, walk } from '../deps.ts'
54
import { EventEmitter } from '../framework/core/events.ts'
@@ -1086,7 +1085,7 @@ export class Project {
10861085

10871086
if (fsync) {
10881087
if (!options?.bundleMode) {
1089-
mod.hash = (new Sha1).update(compilerChecksum).update(jsContent).hex()
1088+
mod.hash = (new Sha1).update(buildChecksum).update(jsContent).hex()
10901089
mod.jsFile = path.join(saveDir, name + (isRemote ? '' : `.${mod.hash.slice(0, hashShort)}`) + '.js')
10911090
await cleanupCompilation(mod.jsFile)
10921091
await Promise.all([
@@ -1142,7 +1141,7 @@ export class Project {
11421141
}
11431142
return s
11441143
})
1145-
mod.hash = (new Sha1).update(compilerChecksum).update(jsContent).hex()
1144+
mod.hash = (new Sha1).update(buildChecksum).update(jsContent).hex()
11461145
mod.jsFile = `${mod.jsFile.replace(reHashJs, '')}.${mod.hash.slice(0, hashShort)}.js`
11471146
cleanupCompilation(mod.jsFile).then(() => {
11481147
Promise.all([
@@ -1283,7 +1282,7 @@ export class Project {
12831282

12841283
// create and copy polyfill
12851284
const polyfillMode = newModule('/polyfill.js')
1286-
const hash = (new Sha1).update(compilerChecksum).update(AlephRuntimeCode).update(`${this.config.buildTarget}-${VERSION}`).hex()
1285+
const hash = (new Sha1).update(buildChecksum).update(AlephRuntimeCode).update(`${this.config.buildTarget}-${VERSION}`).hex()
12871286
const polyfillFile = path.join(this.buildDir, `polyfill.${hash.slice(0, hashShort)}.js`)
12881287
if (!existsFileSync(polyfillFile)) {
12891288
const rawPolyfillFile = `${alephPkgUrl}/compiler/polyfills/${this.config.buildTarget}/polyfill.js`
@@ -1311,7 +1310,7 @@ export class Project {
13111310
}).flat().join('\n')
13121311
const bundlingCode = imports
13131312
const mod = newModule(`/${name}.bundling.js`)
1314-
const hash = (new Sha1).update(compilerChecksum).update(header).update(bundlingCode).hex()
1313+
const hash = (new Sha1).update(buildChecksum).update(header).update(bundlingCode).hex()
13151314
const bundlingFile = path.join(this.buildDir, mod.url)
13161315
const bundleFile = path.join(this.buildDir, `${name}.bundle.${hash.slice(0, hashShort)}.js`)
13171316
const saveAs = path.join(this.outputDir, `_aleph/${name}.${hash.slice(0, hashShort)}.js`)

0 commit comments

Comments
 (0)