Skip to content

Commit 6783ef4

Browse files
committed
test: wat3
1 parent 9a08f25 commit 6783ef4

File tree

3 files changed

+54
-2
lines changed

3 files changed

+54
-2
lines changed

.github/workflows/run-tests.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ jobs:
8181
- name: 'Build'
8282
run: npm run build
8383
- name: 'Vendor deno helpers for integration tests'
84-
run: deno vendor eszip.ts
85-
working-directory: tools/deno
84+
run: node tools/vendor-deno-tools.js
8685
- name: Resolve Next.js version
8786
id: resolve-next-version
8887
shell: bash

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ node_modules/
22
dist/
33
.next
44
edge-runtime/vendor
5+
tools/deno/vendor
56

67
# Local Netlify folder
78
.netlify

tools/vendor-deno-tools.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { createWriteStream } from 'node:fs'
2+
import { rm, writeFile } from 'node:fs/promises'
3+
import { dirname, join } from 'node:path'
4+
import { fileURLToPath } from 'node:url'
5+
import { Readable } from 'stream'
6+
import { finished } from 'stream/promises'
7+
8+
import { execaCommand } from 'execa'
9+
10+
const denoToolsDirectory = join(dirname(fileURLToPath(import.meta.url)), 'deno')
11+
12+
try {
13+
await execaCommand('deno --version')
14+
} catch {
15+
throw new Error('Could not check the version of Deno. Is it installed on your system?')
16+
}
17+
18+
const vendorDest = join(denoToolsDirectory, 'vendor')
19+
20+
console.log(`🧹 Deleting '${vendorDest}'...`)
21+
await rm(vendorDest, { force: true, recursive: true })
22+
23+
const denoJsonPath = join(denoToolsDirectory, 'deno.json')
24+
25+
console.log(`🧹 Generating clean '${denoJsonPath}`)
26+
27+
await writeFile(denoJsonPath, '{}')
28+
29+
console.log(`📦 Vendoring Deno modules into '${vendorDest}'...`)
30+
31+
await execaCommand('deno vendor eszip.ts', {
32+
cwd: denoToolsDirectory,
33+
})
34+
35+
// eszip contains wasm files and those don't currently work great with vendoring
36+
// see https://github.com/denoland/deno/issues/14123
37+
// to workaround this we copy the wasm files manually
38+
const filesToDownload = ['https://deno.land/x/[email protected]/eszip_wasm_bg.wasm']
39+
await Promise.all(
40+
filesToDownload.map(async (urlString) => {
41+
const url = new URL(urlString)
42+
43+
const destination = join(vendorDest, url.hostname, url.pathname)
44+
45+
const res = await fetch(url)
46+
if (!res.ok) throw new Error('Failed to fetch .wasm file to vendor', { cause: err })
47+
const fileStream = createWriteStream(destination, { flags: 'wx' })
48+
await finished(Readable.fromWeb(res.body).pipe(fileStream))
49+
}),
50+
)
51+
52+
console.log('📦 Vendored dependencies for eszip helper')

0 commit comments

Comments
 (0)