|
| 1 | +import { createWriteStream } from 'node:fs' |
1 | 2 | import { cp, rm } from 'node:fs/promises'
|
2 |
| -import { resolve, join } from 'node:path' |
| 3 | +import { join, resolve } from 'node:path' |
| 4 | +import { Readable } from 'stream' |
| 5 | +import { finished } from 'stream/promises' |
3 | 6 |
|
4 | 7 | import { build, context } from 'esbuild'
|
5 | 8 | import { execaCommand } from 'execa'
|
@@ -94,6 +97,22 @@ async function vendorDeno() {
|
94 | 97 | console.log(`📦 Vendoring Deno modules into '${vendorDest}'...`)
|
95 | 98 |
|
96 | 99 | await execaCommand(`deno vendor ${vendorSource} --output=${vendorDest} --force`)
|
| 100 | + |
| 101 | + // htmlrewriter contains wasm files and those don't currently work great with vendoring |
| 102 | + // see https://github.com/denoland/deno/issues/14123 |
| 103 | + // to workaround this we copy the wasm files manually |
| 104 | + const filesToDownload = ['https://deno.land/x/[email protected]/pkg/htmlrewriter_bg.wasm'] |
| 105 | + await Promise.all( |
| 106 | + filesToDownload.map(async (urlString) => { |
| 107 | + const url = new URL(urlString) |
| 108 | + |
| 109 | + const destination = join(vendorDest, url.hostname, url.pathname) |
| 110 | + |
| 111 | + const res = await fetch(url) |
| 112 | + const fileStream = createWriteStream(destination, { flags: 'wx' }) |
| 113 | + await finished(Readable.fromWeb(res.body).pipe(fileStream)) |
| 114 | + }), |
| 115 | + ) |
97 | 116 | }
|
98 | 117 |
|
99 | 118 | const args = new Set(process.argv.slice(2))
|
|
0 commit comments