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

Commit ec13d35

Browse files
committed
chore: use import map instead of deps.ts
1 parent e2c5bc9 commit ec13d35

39 files changed

+170
-111
lines changed

cli.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { flags, path, walk } from './deps.ts'
2-
import { localProxy } from './server/localproxy.ts'
1+
import * as path from 'std/path/mod.ts'
2+
import { walk } from 'std/fs/walk.ts'
3+
import * as flags from 'std/flags/mod.ts'
34
import { existsDirSync } from './shared/fs.ts'
45
import type { LevelNames } from './shared/log.ts'
56
import log from './shared/log.ts'
@@ -88,6 +89,7 @@ async function main() {
8889
// proxy https://deno.land/x/aleph on localhost
8990
const v = Deno.env.get('ALEPH_DEV_PORT')
9091
if (v !== undefined && /^\d+$/.test(v)) {
92+
const { localProxy } = await import('./server/localproxy.ts')
9193
localProxy(parseInt(v))
9294
}
9395

cli/init.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { colors, ensureDir, gzipDecode, path, Untar } from '../deps.ts'
1+
import { Untar } from 'std/archive/tar.ts'
2+
import { green, dim } from 'std/fmt/colors.ts'
3+
import { ensureDir } from 'std/fs/ensure_dir.ts'
4+
import { join } from 'std/path/mod.ts'
5+
import { gzipDecode } from 'gzip'
26
import { ensureTextFile } from '../shared/fs.ts'
37
import util from '../shared/util.ts'
48
import { VERSION } from '../version.ts'
@@ -35,7 +39,7 @@ export default async function (nameArg?: string) {
3539

3640
for await (const entry of entryList) {
3741
if (entry.fileName.startsWith(`alephjs-templates-${rev}/${template}/`)) {
38-
const fp = path.join(cwd, name, util.trimPrefix(entry.fileName, `alephjs-templates-${rev}/${template}/`))
42+
const fp = join(cwd, name, util.trimPrefix(entry.fileName, `alephjs-templates-${rev}/${template}/`))
3943
if (entry.type === 'directory') {
4044
await ensureDir(fp)
4145
continue
@@ -63,8 +67,8 @@ export default async function (nameArg?: string) {
6367
scopes: {}
6468
}
6569
await Promise.all([
66-
Deno.writeTextFile(path.join(cwd, name, '.gitignore'), gitignore.join('\n')),
67-
Deno.writeTextFile(path.join(cwd, name, 'import_map.json'), JSON.stringify(importMap, undefined, 4))
70+
Deno.writeTextFile(join(cwd, name, '.gitignore'), gitignore.join('\n')),
71+
Deno.writeTextFile(join(cwd, name, 'import_map.json'), JSON.stringify(importMap, undefined, 4))
6872
])
6973

7074
if (vscode) {
@@ -78,21 +82,21 @@ export default async function (nameArg?: string) {
7882
'deno.unstable': true,
7983
'deno.importMap': './import_map.json'
8084
}
81-
await ensureDir(path.join(name, '.vscode'))
85+
await ensureDir(join(name, '.vscode'))
8286
await Promise.all([
83-
Deno.writeTextFile(path.join(name, '.vscode', 'extensions.json'), JSON.stringify(extensions, undefined, 4)),
84-
Deno.writeTextFile(path.join(name, '.vscode', 'settings.json'), JSON.stringify(settigns, undefined, 4))
87+
Deno.writeTextFile(join(name, '.vscode', 'extensions.json'), JSON.stringify(extensions, undefined, 4)),
88+
Deno.writeTextFile(join(name, '.vscode', 'settings.json'), JSON.stringify(settigns, undefined, 4))
8589
])
8690
}
8791

8892
console.log('Done')
89-
console.log(colors.dim('---'))
90-
console.log(colors.green('Aleph.js is ready to go!'))
91-
console.log(`${colors.dim('$')} cd ${name}`)
92-
console.log(`${colors.dim('$')} aleph dev ${colors.dim('# start the app in `development` mode')}`)
93-
console.log(`${colors.dim('$')} aleph start ${colors.dim('# start the app in `production` mode')}`)
94-
console.log(`${colors.dim('$')} aleph build ${colors.dim('# build the app to a static site (SSG)')}`)
95-
console.log(colors.dim('---'))
93+
console.log(dim('---'))
94+
console.log(green('Aleph.js is ready to go!'))
95+
console.log(`${dim('$')} cd ${name}`)
96+
console.log(`${dim('$')} aleph dev ${dim('# start the app in `development` mode')}`)
97+
console.log(`${dim('$')} aleph start ${dim('# start the app in `production` mode')}`)
98+
console.log(`${dim('$')} aleph build ${dim('# build the app to a static site (SSG)')}`)
99+
console.log(dim('---'))
96100
Deno.exit(0)
97101
}
98102

cli/upgrade.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { colors, path } from '../deps.ts'
1+
import { red } from 'https://deno.land/[email protected]/fmt/colors.ts'
2+
import { dirname, join } from 'https://deno.land/[email protected]/path/mod.ts'
23
import { existsFileSync } from '../shared/fs.ts'
34

45
const versionMetaUrl = 'https://cdn.deno.land/aleph/meta/versions.json'
@@ -20,13 +21,13 @@ export default async function (version = 'latest') {
2021
} else if (!versions.includes(version)) {
2122
version = 'v' + version
2223
if (!versions.includes(version)) {
23-
console.log(`${colors.red('error')}: version(${version}) not found!`)
24+
console.log(`${red('error')}: version(${version}) not found!`)
2425
Deno.exit(1)
2526
}
2627
}
2728

2829
const denoExecPath = Deno.execPath()
29-
const cmdExists = existsFileSync(path.join(path.dirname(denoExecPath), 'aleph'))
30+
const cmdExists = existsFileSync(join(dirname(denoExecPath), 'aleph'))
3031
const p = Deno.run({
3132
cmd: [
3233
denoExecPath,
@@ -36,6 +37,7 @@ export default async function (version = 'latest') {
3637
'--unstable',
3738
'-n', 'aleph',
3839
'--location', 'https://deno.land/x/aleph',
40+
'--import-map', 'https://deno.land/x/aleph@{version}/import_map.json',
3941
`https://deno.land/x/aleph@${version}/cli.ts`
4042
],
4143
stdout: 'null',
@@ -44,9 +46,9 @@ export default async function (version = 'latest') {
4446
const status = await p.status()
4547
if (status.success) {
4648
if (cmdExists) {
47-
console.log(`Aleph.js is up to ${version}!`)
49+
console.log(`Aleph.js is up to ${version}`)
4850
} else {
49-
console.log('Aleph.js was installed successfully!')
51+
console.log('Aleph.js was installed successfully')
5052
console.log(`Run 'aleph --help' to get started`)
5153
}
5254
}

compiler/build.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { base64, brotli, createHash, ensureDir } from '../deps.ts'
1+
import { encode } from 'https://deno.land/[email protected]/encoding/base64.ts'
2+
import { ensureDir } from 'https://deno.land/[email protected]/fs/ensure_dir.ts'
3+
import { createHash } from 'https://deno.land/[email protected]/hash/mod.ts'
4+
import { compress } from 'https://deno.land/x/[email protected]/mod.ts'
25

36
async function run(cmd: string[]) {
47
const p = Deno.run({
@@ -15,16 +18,17 @@ if (import.meta.main) {
1518
if (await run(['wasm-pack', 'build', '--target', 'web'])) {
1619
const wasmData = await Deno.readFile('./pkg/aleph_compiler_bg.wasm')
1720
const wasmPackJS = await Deno.readTextFile('./pkg/aleph_compiler.js')
18-
const data = brotli.compress(wasmData)
19-
const dataBase64 = base64.encode(data)
21+
const data = compress(wasmData)
22+
const dataBase64 = encode(data)
2023
const hash = createHash('sha1').update(data).toString()
2124
await ensureDir('./dist')
2225
await Deno.writeTextFile(
2326
'./dist/wasm.js',
2427
[
25-
`import { base64, brotli } from "../../deps.ts";`,
28+
`import { decode } from "https://deno.land/[email protected]/encoding/base64.ts";`,
29+
`import { decompress } from "https://deno.land/x/[email protected]/mod.ts";`,
2630
`const dataRaw = "${dataBase64}";`,
27-
`export default () => brotli.decompress(base64.decode(dataRaw));`
31+
`export default () => decompress(decode(dataRaw));`
2832
].join('\n')
2933
)
3034
await Deno.writeTextFile(

compiler/dist/wasm.js

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

compiler/mod.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { ensureDir, path } from '../deps.ts'
1+
import { join } from 'https://deno.land/[email protected]/path/mod.ts'
2+
import { ensureDir } from 'https://deno.land/[email protected]/fs/ensure_dir.ts'
23
import { existsFileSync } from '../shared/fs.ts'
34
import log from '../shared/log.ts'
45
import type { LoaderPlugin } from '../types.ts'
@@ -69,7 +70,7 @@ async function getDenoDir() {
6970
}
7071

7172
export async function initWasm() {
72-
const cacheDir = path.join(await getDenoDir(), `deps/https/deno.land/aleph@v${VERSION}`)
73+
const cacheDir = join(await getDenoDir(), `deps/https/deno.land/aleph@v${VERSION}`)
7374
const cachePath = `${cacheDir}/compiler.${checksum}.wasm`
7475
if (existsFileSync(cachePath)) {
7576
const wasmData = await Deno.readFile(cachePath)

deps.ts

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

examples/42-wasm/aleph.config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import css from '../../plugins/css.ts'
2-
import sass from '../../plugins/sass.ts'
3-
import wasm from '../../plugins/wasm.ts'
4-
import type { Config } from '../../types.ts'
1+
import css from 'aleph/plugins/css.ts'
2+
import sass from 'aleph/plugins/sass.ts'
3+
import wasm from 'aleph/plugins/wasm.ts'
4+
import type { Config } from 'aleph/types.ts'
55

66
export default (): Config => ({
77
plugins: [css(), sass(), wasm()]

examples/hello-world-spa/aleph.config.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import css from '../../plugins/css.ts'
2-
import type { Config } from '../../types.ts'
1+
import css from 'aleph/plugins/css.ts'
2+
import type { Config } from 'aleph/types.ts'
33

44
export default (): Config => ({
5-
ssr: false,
65
plugins: [
76
css({
87
postcss: { plugins: ['autoprefixer'] }

examples/hello-world-src-dir/aleph.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import css from '../../plugins/css.ts'
2-
import type { Config } from '../../types.ts'
1+
import css from 'aleph/plugins/css.ts'
2+
import type { Config } from 'aleph/types.ts'
33

44
export default (): Config => ({
55
plugins: [

0 commit comments

Comments
 (0)