Skip to content

Commit 2b4320a

Browse files
committed
wip: swap import paths for urls
1 parent 340cfc0 commit 2b4320a

File tree

5 files changed

+27
-29
lines changed

5 files changed

+27
-29
lines changed

edge-runtime/lib/middleware.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Context } from '@netlify/edge-functions'
22

3-
import type { ElementHandlers } from '../../vendor/deno.land/x/[email protected]/src/index.ts'
4-
import { getCookies } from '../../vendor/deno.land/[email protected]/http/cookie.ts'
3+
import type { ElementHandlers } from 'https://deno.land/x/[email protected]/src/index.ts'
4+
import { getCookies } from 'https://deno.land/x/[email protected]/http/cookie.ts'
55

66
type NextDataTransform = <T>(data: T) => T
77

edge-runtime/lib/response.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import type { Context } from '@netlify/edge-functions'
2-
import {
3-
HTMLRewriter,
4-
type TextChunk,
5-
} from '../../vendor/deno.land/x/[email protected]/src/index.ts'
2+
import { HTMLRewriter, type TextChunk } from 'https://deno.land/x/[email protected]/src/index.ts'
63

74
import { updateModifiedHeaders } from './headers.ts'
85
import type { StructuredLogger } from './logging.ts'

edge-runtime/lib/routing.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
* Some types have been re-implemented to be more compatible with Deno or avoid chains of dependent files
66
*/
77

8-
import type { Key } from '../vendor/deno.land/x/[email protected]/index.ts'
8+
import type { Key } from 'https://deno.land/x/[email protected]/index.ts'
99

10-
import { compile, pathToRegexp } from '../vendor/deno.land/x/[email protected]/index.ts'
11-
import { getCookies } from '../vendor/deno.land/[email protected]/http/cookie.ts'
10+
import { compile, pathToRegexp } from 'https://deno.land/x/[email protected]/index.ts'
11+
import { getCookies } from 'https://deno.land/x/[email protected]/http/cookie.ts'
1212

1313
/*
1414
┌─────────────────────────────────────────────────────────────────────────┐

edge-runtime/vendor.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import 'https://deno.land/[email protected]/node/util.ts'
1111
import 'https://deno.land/[email protected]/path/mod.ts'
1212

1313
import 'https://deno.land/x/[email protected]/index.ts'
14-
import 'https://deno.land/x/[email protected]/src/index.ts'
14+
// import 'https://deno.land/x/[email protected]/src/index.ts'
15+
import { HTMLRewriter } from 'https://deno.land/x/[email protected]/pkg/htmlrewriter_bg.wasm'
1516

1617
import 'https://v1-7-0--edge-utils.netlify.app/logger/mod.ts'

tools/build-helpers.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,28 +42,28 @@ export async function vendorDeno({
4242
cwd,
4343
})
4444

45-
if (wasmFilesToDownload.length !== 0) {
46-
console.log(`⬇️ Downloading wasm files...`)
45+
// if (wasmFilesToDownload.length !== 0) {
46+
// console.log(`⬇️ Downloading wasm files...`)
4747

48-
// deno vendor doesn't work well with wasm files
49-
// see https://github.com/denoland/deno/issues/14123
50-
// to workaround this we copy the wasm files manually
51-
// (note Deno 2 allows to vendor wasm files, but it also require modules to import them and not fetch and instantiate them
52-
// se being able to drop downloading is dependent on implementation of wasm handling in external modules as well)
53-
await Promise.all(
54-
wasmFilesToDownload.map(async (urlString) => {
55-
const url = new URL(urlString)
48+
// // deno vendor doesn't work well with wasm files
49+
// // see https://github.com/denoland/deno/issues/14123
50+
// // to workaround this we copy the wasm files manually
51+
// // (note Deno 2 allows to vendor wasm files, but it also require modules to import them and not fetch and instantiate them
52+
// // so being able to drop downloading is dependent on implementation of wasm handling in external modules as well)
53+
// await Promise.all(
54+
// wasmFilesToDownload.map(async (urlString) => {
55+
// const url = new URL(urlString)
5656

57-
const destination = join(vendorDest, url.hostname, url.pathname)
57+
// const destination = join(vendorDest, url.hostname, url.pathname)
5858

59-
const res = await fetch(url)
60-
if (!res.ok)
61-
throw new Error(`Failed to fetch .wasm file to vendor. Response status: ${res.status}`)
62-
const fileStream = createWriteStream(destination, { flags: 'wx' })
63-
await finished(Readable.fromWeb(res.body).pipe(fileStream))
64-
}),
65-
)
66-
}
59+
// const res = await fetch(url)
60+
// if (!res.ok)
61+
// throw new Error(`Failed to fetch .wasm file to vendor. Response status: ${res.status}`)
62+
// const fileStream = createWriteStream(destination, { flags: 'wx' })
63+
// await finished(Readable.fromWeb(res.body).pipe(fileStream))
64+
// }),
65+
// )
66+
// }
6767

6868
console.log(`✅ Vendored Deno modules for '${vendorSource}' into '${vendorDest}'`)
6969
}

0 commit comments

Comments
 (0)