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

Commit acec179

Browse files
author
Wenjie Xia
committed
refactor: clean up
1 parent 250cdaa commit acec179

File tree

6 files changed

+18
-13
lines changed

6 files changed

+18
-13
lines changed

compiler/mod.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import { ensureDir, existsSync, path } from '../deps.ts'
1+
import { ensureDir, path } from '../deps.ts'
2+
import { existsFileSync } from '../shared/fs.ts'
3+
import type { ImportMap } from '../types.ts'
24
import { VERSION } from '../version.ts'
35
import { checksum } from './dist/wasm-checksum.js'
46
import { default as init_wasm, transformSync } from './dist/wasm-pack.js'
57

6-
export const buildChecksum = checksum
7-
8-
type ImportMap = Record<string, ReadonlyArray<string>>
9-
108
export interface SWCOptions {
119
target?: 'es5' | 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020'
1210
jsxFactory?: string
@@ -65,7 +63,7 @@ export function transpileSync(code: string, opts?: TransformOptions): TransformR
6563
export const initWasm = async (denoCacheDir: string) => {
6664
const cacheDir = path.join(denoCacheDir, `deps/https/deno.land/aleph@v${VERSION}`)
6765
const cachePath = `${cacheDir}/compiler.${checksum}.wasm`
68-
if (existsSync(cachePath)) {
66+
if (existsFileSync(cachePath)) {
6967
const wasmData = await Deno.readFile(cachePath)
7068
await init_wasm(wasmData)
7169
} else {
@@ -76,3 +74,8 @@ export const initWasm = async (denoCacheDir: string) => {
7674
await Deno.writeFile(cachePath, wasmData)
7775
}
7876
}
77+
78+
/**
79+
* wasm build checksum.
80+
*/
81+
export const buildChecksum = checksum

deps.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ export * as bytes from 'https://deno.land/[email protected]/bytes/mod.ts'
44
export * as base64 from 'https://deno.land/[email protected]/encoding/base64.ts'
55
export * as colors from 'https://deno.land/[email protected]/fmt/colors.ts'
66
export { ensureDir } from 'https://deno.land/[email protected]/fs/ensure_dir.ts'
7-
export { exists, existsSync } from 'https://deno.land/[email protected]/fs/exists.ts'
87
export { walk } from 'https://deno.land/[email protected]/fs/walk.ts'
98
export { Sha1 } from 'https://deno.land/[email protected]/hash/sha1.ts'
109
export { Sha256 } from 'https://deno.land/[email protected]/hash/sha256.ts'

server/app.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import { hashShort, reFullVersion, reHashJs, reHashResolve, reHttp, reLocaleID,
77
import { ensureTextFile, existsDirSync, existsFileSync } from '../shared/fs.ts'
88
import log from '../shared/log.ts'
99
import util from '../shared/util.ts'
10-
import type { Config, RouterURL, ServerRequest } from '../types.ts'
10+
import type { Config, ImportMap, RouterURL, ServerRequest } from '../types.ts'
1111
import { VERSION } from '../version.ts'
1212
import { Request } from './api.ts'
13-
import type { AppliactionOptions, DependencyDescriptor, ImportMap, Module, RenderResult } from './types.ts'
13+
import type { AppliactionOptions, DependencyDescriptor, Module, RenderResult } from './types.ts'
1414
import { AlephRuntimeCode, cleanupCompilation, createHtml, fixImportMap, fixImportUrl, formatBytesWithColor, getAlephPkgUrl, getRelativePath, newModule, respondError } from './util.ts'
1515

1616
const defaultOptions: Required<AppliactionOptions> = {

server/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import type { RouterURL } from '../types.ts'
22

3-
export type ImportMap = Record<string, ReadonlyArray<string>>
4-
53
export type AppliactionOptions = {
64
workingDir?: string
75
mode?: 'development' | 'production'

server/util.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { MB, reHashJs, reHttp, reModuleExt, reStyleModuleExt } from '../shared/c
33
import { existsDirSync } from '../shared/fs.ts'
44
import log from '../shared/log.ts'
55
import util from '../shared/util.ts'
6-
import type { ServerRequest } from '../types.ts'
6+
import type { ImportMap, ServerRequest } from '../types.ts'
77
import { VERSION } from '../version.ts'
8-
import { ImportMap, Module } from './types.ts'
8+
import type { Module } from './types.ts'
99

1010
export const AlephRuntimeCode = `
1111
var __ALEPH = window.__ALEPH || (window.__ALEPH = {

types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,8 @@ export type FormFile = {
153153
filename: string
154154
size: number
155155
}
156+
157+
/**
158+
* ES Import map.
159+
*/
160+
export type ImportMap = Record<string, ReadonlyArray<string>>

0 commit comments

Comments
 (0)