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

Commit d7f6bfa

Browse files
authored
Merge pull request #367 from alephjs/vercel-functions
Support vercel functions
2 parents 35b3ba7 + 070b804 commit d7f6bfa

27 files changed

+163
-146
lines changed

bundler/esbuild.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { join } from 'https://deno.land/std@0.100.0/path/mod.ts'
1+
import { join } from 'https://deno.land/std@0.106.0/path/mod.ts'
22
import { cache } from '../server/cache.ts'
33
import util from '../shared/util.ts'
4-
// @deno-types="https://deno.land/x/[email protected].22/mod.d.ts"
5-
import { build, stop, Plugin } from 'https://deno.land/x/[email protected].22/mod.js'
4+
// @deno-types="https://deno.land/x/[email protected].24/mod.d.ts"
5+
import { build, stop, Plugin } from 'https://deno.land/x/[email protected].24/mod.js'
66

77
export {
88
build as esbuild,

bundler/mod.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { dirname, join } from 'https://deno.land/std@0.100.0/path/mod.ts'
2-
import { ensureDir } from 'https://deno.land/std@0.100.0/fs/ensure_dir.ts'
3-
import { createHash } from 'https://deno.land/std@0.100.0/hash/mod.ts'
1+
import { dirname, join } from 'https://deno.land/std@0.106.0/path/mod.ts'
2+
import { ensureDir } from 'https://deno.land/std@0.106.0/fs/ensure_dir.ts'
3+
import { createHash } from 'https://deno.land/std@0.106.0/hash/mod.ts'
44
import { SourceType, transform } from '../compiler/mod.ts'
55
import { trimBuiltinModuleExts } from '../framework/core/module.ts'
66
import { cssLoader } from '../plugins/css.ts'

cli.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { resolve } from 'https://deno.land/std@0.100.0/path/mod.ts'
2-
import { parse } from 'https://deno.land/std@0.100.0/flags/mod.ts'
1+
import { resolve } from 'https://deno.land/std@0.106.0/path/mod.ts'
2+
import { parse } from 'https://deno.land/std@0.106.0/flags/mod.ts'
33
import { existsDir } from './shared/fs.ts'
44
import log, { LevelNames } from './shared/log.ts'
55
import util from './shared/util.ts'
@@ -24,10 +24,9 @@ Usage:
2424
aleph <command> [...options]
2525
2626
Commands:
27-
${
28-
Object.entries(commands).map(([name, desc]) => `${name.padEnd(15)}${desc}`)
29-
.join('\n ')
30-
}
27+
${Object.entries(commands).map(([name, desc]) => `${name.padEnd(15)}${desc}`)
28+
.join('\n ')
29+
}
3130
3231
Options:
3332
-v, --version Prints version number

commands/analyze.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { serve } from 'https://deno.land/std@0.100.0/http/server.ts'
1+
import { serve } from 'https://deno.land/std@0.106.0/http/server.ts'
22
import { Aleph } from '../server/aleph.ts'
33
import { getFlag, parsePortNumber } from '../shared/flags.ts'
44
import log from '../shared/log.ts'

commands/init.ts

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { Untar } from 'https://deno.land/std@0.100.0/archive/tar.ts'
2-
import { Buffer } from 'https://deno.land/std@0.100.0/io/buffer.ts'
3-
import { readAll } from 'https://deno.land/std@0.100.0/io/util.ts'
4-
import { green, blue, dim, red, cyan } from 'https://deno.land/std@0.100.0/fmt/colors.ts'
5-
import { ensureDir } from 'https://deno.land/std@0.100.0/fs/ensure_dir.ts'
6-
import { join } from 'https://deno.land/std@0.100.0/path/mod.ts'
1+
import { Untar } from 'https://deno.land/std@0.106.0/archive/tar.ts'
2+
import { Buffer } from 'https://deno.land/std@0.106.0/io/buffer.ts'
3+
import { readAll } from 'https://deno.land/std@0.106.0/io/util.ts'
4+
import { green, blue, dim, red, cyan } from 'https://deno.land/std@0.106.0/fmt/colors.ts'
5+
import { ensureDir } from 'https://deno.land/std@0.106.0/fs/ensure_dir.ts'
6+
import { join } from 'https://deno.land/std@0.106.0/path/mod.ts'
77
import { gunzip } from 'https://deno.land/x/[email protected]/mod.ts'
88
import { ensureTextFile, existsDir } from '../shared/fs.ts'
99
import util from '../shared/util.ts'
@@ -57,6 +57,7 @@ export default async function (
5757

5858
// ask to create vscode files
5959
const vscode = await confirm('Using VS Code?')
60+
const vercel = await confirm('Deploy to Vercel?')
6061

6162
// download template
6263
console.log('Downloading template. This might take a moment...')
@@ -139,13 +140,26 @@ export default async function (
139140
])
140141
}
141142

143+
if (vercel) {
144+
Deno.writeTextFile(
145+
join(name, 'vercel.json'),
146+
JSON.stringify({
147+
functions: {
148+
'api/**/*.{j,t}s': {
149+
runtime: '[email protected]'
150+
}
151+
}
152+
}, undefined, 2),
153+
)
154+
}
155+
142156
// cache deps in import maps
143157
console.log('Cache deps...')
144158
const urls = Object.values(importMap.imports).filter((v) => !v.endsWith('/'))
145159
const p = Deno.run({
146160
cmd: [Deno.execPath(), 'cache', ...urls, deno_x_brotli, deno_x_flate],
147-
stderr: 'null',
148-
stdout: 'null',
161+
stderr: 'inherit',
162+
stdout: 'inherit',
149163
})
150164
await p.status()
151165
p.close()
@@ -159,7 +173,8 @@ ${dim('▲')} aleph start ${dim('# start the app in `production` mode')}
159173
${dim('▲')} aleph build ${dim('# build the app to a static site (SSG)')}
160174
161175
Docs: ${cyan('https://alephjs.org/docs')}
162-
Bugs: ${cyan('https://alephjs.org.com/alephjs/aleph.js/issues')}`
176+
Bugs: ${cyan('https://alephjs.org.com/alephjs/aleph.js/issues')}
177+
`
163178
)
164179

165180
Deno.exit(0)

compiler/Cargo.lock

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

compiler/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@ pathdiff = "0.2.0"
2323
regex = "1.5.4"
2424
relative-path = "1.5.0"
2525
sha-1 = "0.9.7"
26-
serde = { version = "1.0.127", features = ["derive"] }
26+
serde = { version = "1.0.129", features = ["derive"] }
2727
url = "2.2.2"
2828

2929
# swc
3030
# docs: https://swc.rs
3131
# crate: https://crates.io/search?q=swc
3232
swc_atoms = "0.2.7"
33-
swc_common = { version = "0.11.6", features = ["sourcemap"] }
34-
swc_ecmascript = { version = "0.57.0", features = ["codegen", "parser", "react", "transforms", "visit"] }
33+
swc_common = { version = "0.11.7", features = ["sourcemap"] }
34+
swc_ecmascript = { version = "0.58.0", features = ["codegen", "parser", "react", "transforms", "visit"] }
3535
swc_ecma_transforms_proposal = "0.34.0"
3636
swc_ecma_transforms_typescript = "0.36.0"
37-
swc_ecma_ast = "0.49.4"
37+
swc_ecma_ast = "0.49.5"
3838
swc_ecma_visit = "0.35.2"
39-
swc_ecma_utils = "0.41.3"
39+
swc_ecma_utils = "0.41.4"
4040

4141
# wasm-bindgen
4242
# docs: https://rustwasm.github.io/docs/wasm-bindgen

compiler/build.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { dim } from 'https://deno.land/std@0.100.0/fmt/colors.ts'
2-
import { encode } from 'https://deno.land/std@0.100.0/encoding/base64.ts'
3-
import { exists } from 'https://deno.land/std@0.100.0/fs/exists.ts'
4-
import { ensureDir } from 'https://deno.land/std@0.100.0/fs/ensure_dir.ts'
5-
import { createHash } from 'https://deno.land/std@0.100.0/hash/mod.ts'
1+
import { dim } from 'https://deno.land/std@0.106.0/fmt/colors.ts'
2+
import { encode } from 'https://deno.land/std@0.106.0/encoding/base64.ts'
3+
import { exists } from 'https://deno.land/std@0.106.0/fs/exists.ts'
4+
import { ensureDir } from 'https://deno.land/std@0.106.0/fs/ensure_dir.ts'
5+
import { createHash } from 'https://deno.land/std@0.106.0/hash/mod.ts'
66
import { compress } from 'https://deno.land/x/[email protected]/mod.ts'
77
import util from '../shared/util.ts'
88

@@ -31,7 +31,7 @@ if (import.meta.main) {
3131
await Deno.writeTextFile(
3232
'./dist/wasm.js',
3333
[
34-
`import { decode } from "https://deno.land/std@0.100.0/encoding/base64.ts";`,
34+
`import { decode } from "https://deno.land/std@0.106.0/encoding/base64.ts";`,
3535
`import { decompress } from "https://deno.land/x/[email protected]/mod.ts";`,
3636
`const dataRaw = "${encode(compress(wasmData))}";`,
3737
`export default () => decompress(decode(dataRaw));`
@@ -43,7 +43,7 @@ if (import.meta.main) {
4343
)
4444
await Deno.writeTextFile(
4545
'./dist/compiler.js',
46-
`import { red } from 'https://deno.land/std@0.100.0/fmt/colors.ts';` + jsCode.replace('console.error(getStringFromWasm0(arg0, arg1));', `
46+
`import { red } from 'https://deno.land/std@0.106.0/fmt/colors.ts';` + jsCode.replace('console.error(getStringFromWasm0(arg0, arg1));', `
4747
const msg = getStringFromWasm0(arg0, arg1);
4848
if (msg.includes('DiagnosticBuffer(["')) {
4949
const diagnostic = msg.split('DiagnosticBuffer(["')[1].split('"])')[0]

compiler/dist/compiler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { red } from "https://deno.land/std@0.100.0/fmt/colors.ts";
1+
import { red } from "https://deno.land/std@0.106.0/fmt/colors.ts";
22
let wasm;
33

44
let cachedTextDecoder = new TextDecoder("utf-8", {

compiler/dist/wasm.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)