diff --git a/.github/workflows/deno-test.yml b/.github/workflows/deno-test.yml index 803abf8e3a..24a76be0e5 100644 --- a/.github/workflows/deno-test.yml +++ b/.github/workflows/deno-test.yml @@ -11,8 +11,8 @@ jobs: - name: Setup Deno uses: denoland/setup-deno@v1 with: - deno-version: v1.x.x + deno-version: v2.x.x - name: Vendor Deno modules - run: deno vendor edge-runtime/vendor.ts --output=edge-runtime/vendor --force + run: deno --allow-import edge-runtime/vendor.ts - name: Test run: deno test -A edge-runtime/ diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index c523c269c4..e7a20467a6 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -24,7 +24,7 @@ jobs: uses: denoland/setup-deno@v1 with: # Should match the `DENO_VERSION_RANGE` from https://github.com/netlify/build/blob/main/packages/edge-bundler/node/bridge.ts#L20 - deno-version: v1.46.3 + deno-version: v2.3.1 - name: Extract tag and version id: extract run: |- diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 16f08ab457..4e88dcc883 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -32,7 +32,7 @@ jobs: uses: denoland/setup-deno@v1 with: # Should match the `DENO_VERSION_RANGE` from https://github.com/netlify/build/blob/main/packages/edge-bundler/node/bridge.ts#L20 - deno-version: v1.46.3 + deno-version: v2.3.1 - name: Build run: npm run build if: ${{ steps.release.outputs.release_created }} diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 96bce88839..d5bf8525e7 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -68,7 +68,7 @@ jobs: uses: denoland/setup-deno@v1 with: # Should match the `DENO_VERSION_RANGE` from https://github.com/netlify/build/blob/main/packages/edge-bundler/node/bridge.ts#L20 - deno-version: v1.46.3 + deno-version: v2.3.1 - name: 'Install dependencies' run: npm ci - name: 'Prepare Netlify CLI' @@ -151,7 +151,7 @@ jobs: uses: denoland/setup-deno@v1 with: # Should match the `DENO_VERSION_RANGE` from https://github.com/netlify/edge-bundler/blob/e55f825bd985d3c92e21d1b765d71e70d5628fba/node/bridge.ts#L17 - deno-version: v1.46.3 + deno-version: v2.3.1 - name: 'Install dependencies' run: npm ci - name: 'Build' @@ -218,7 +218,7 @@ jobs: uses: denoland/setup-deno@v1 with: # Should match the `DENO_VERSION_RANGE` from https://github.com/netlify/build/blob/main/packages/edge-bundler/node/bridge.ts#L20 - deno-version: v1.46.3 + deno-version: v2.3.1 - name: 'Install dependencies' run: npm ci - name: 'Build' diff --git a/.github/workflows/size-check.yml b/.github/workflows/size-check.yml index 7a61c3308c..52b887fa62 100644 --- a/.github/workflows/size-check.yml +++ b/.github/workflows/size-check.yml @@ -24,7 +24,7 @@ jobs: uses: denoland/setup-deno@v1 with: # Should match the `DENO_VERSION_RANGE` from https://github.com/netlify/build/blob/main/packages/edge-bundler/node/bridge.ts#L20 - deno-version: v1.46.3 + deno-version: v2.3.1 - run: npm ci - name: Package size report diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 1e9d847535..1cb1006440 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -165,7 +165,7 @@ jobs: uses: denoland/setup-deno@v1 with: # Should match the `DENO_VERSION_RANGE` from https://github.com/netlify/build/blob/main/packages/edge-bundler/node/bridge.ts#L20 - deno-version: v1.46.3 + deno-version: v2.3.1 - name: install runtime run: npm install --ignore-scripts diff --git a/deno.json b/deno.json index 561c910ed5..fa5e81d84c 100644 --- a/deno.json +++ b/deno.json @@ -7,5 +7,5 @@ "imports": { "@netlify/edge-functions": "https://edge.netlify.com/v1/index.ts" }, - "importMap": "./edge-runtime/vendor/import_map.json" + "vendor": true } diff --git a/edge-runtime/lib/middleware.ts b/edge-runtime/lib/middleware.ts index f2ed78e861..910aa90bfc 100644 --- a/edge-runtime/lib/middleware.ts +++ b/edge-runtime/lib/middleware.ts @@ -1,7 +1,7 @@ import type { Context } from '@netlify/edge-functions' -import type { ElementHandlers } from '../vendor/deno.land/x/htmlrewriter@v1.0.0/src/index.ts' -import { getCookies } from '../vendor/deno.land/std@0.175.0/http/cookie.ts' +import type { ElementHandlers } from 'https://deno.land/x/htmlrewriter@v1.0.0/src/index.ts' +import { getCookies } from 'https://deno.land/x/std@0.175.0/http/cookie.ts' type NextDataTransform = (data: T) => T diff --git a/edge-runtime/lib/response.ts b/edge-runtime/lib/response.ts index 31bb7ead7b..54546367dc 100644 --- a/edge-runtime/lib/response.ts +++ b/edge-runtime/lib/response.ts @@ -1,8 +1,5 @@ import type { Context } from '@netlify/edge-functions' -import { - HTMLRewriter, - type TextChunk, -} from '../vendor/deno.land/x/htmlrewriter@v1.0.0/src/index.ts' +import { HTMLRewriter, type TextChunk } from 'https://deno.land/x/htmlrewriter@v1.0.0/src/index.ts' import { updateModifiedHeaders } from './headers.ts' import type { StructuredLogger } from './logging.ts' diff --git a/edge-runtime/lib/routing.ts b/edge-runtime/lib/routing.ts index e9fbaf137c..ba8d43cb5b 100644 --- a/edge-runtime/lib/routing.ts +++ b/edge-runtime/lib/routing.ts @@ -5,10 +5,10 @@ * Some types have been re-implemented to be more compatible with Deno or avoid chains of dependent files */ -import type { Key } from '../vendor/deno.land/x/path_to_regexp@v6.2.1/index.ts' +import type { Key } from 'https://deno.land/x/path_to_regexp@v6.2.1/index.ts' -import { compile, pathToRegexp } from '../vendor/deno.land/x/path_to_regexp@v6.2.1/index.ts' -import { getCookies } from '../vendor/deno.land/std@0.175.0/http/cookie.ts' +import { compile, pathToRegexp } from 'https://deno.land/x/path_to_regexp@v6.2.1/index.ts' +import { getCookies } from 'https://deno.land/x/std@0.175.0/http/cookie.ts' /* ┌─────────────────────────────────────────────────────────────────────────┐ diff --git a/src/build/functions/edge.ts b/src/build/functions/edge.ts index af6405b57c..7c0f3664e8 100644 --- a/src/build/functions/edge.ts +++ b/src/build/functions/edge.ts @@ -92,12 +92,12 @@ const writeHandlerFile = async (ctx: PluginContext, { matchers, name }: NextDefi JSON.stringify(minimalNextConfig), ) - const htmlRewriterWasm = await readFile( - join( - ctx.pluginDir, - 'edge-runtime/vendor/deno.land/x/htmlrewriter@v1.0.0/pkg/htmlrewriter_bg.wasm', - ), - ) + // const htmlRewriterWasm = await readFile( + // join( + // ctx.pluginDir, + // 'edge-runtime/vendor/deno.land/x/htmlrewriter@v1.0.0/pkg/htmlrewriter_bg.wasm', + // ), + // ) // Writing the function entry file. It wraps the middleware code with the // compatibility layer mentioned above. @@ -108,10 +108,6 @@ const writeHandlerFile = async (ctx: PluginContext, { matchers, name }: NextDefi import { handleMiddleware } from './edge-runtime/middleware.ts'; import handler from './server/${name}.js'; - await htmlRewriterInit({ module_or_path: Uint8Array.from(${JSON.stringify([ - ...htmlRewriterWasm, - ])}) }); - export default (req, context) => handleMiddleware(req, context, handler); `, ) diff --git a/tools/build-helpers.js b/tools/build-helpers.js index 0d2feb0f06..12adfa8edf 100644 --- a/tools/build-helpers.js +++ b/tools/build-helpers.js @@ -38,33 +38,32 @@ export async function vendorDeno({ } console.log(`📦 Vendoring Deno modules for '${vendorSource}' into '${vendorDest}'...`) - // --output=${vendorDest} - await execaCommand(`deno vendor ${vendorSource} --force`, { + await execaCommand(`deno --allow-import ${vendorSource}`, { cwd, }) - if (wasmFilesToDownload.length !== 0) { - console.log(`⬇️ Downloading wasm files...`) + // if (wasmFilesToDownload.length !== 0) { + // console.log(`⬇️ Downloading wasm files...`) - // deno vendor doesn't work well with wasm files - // see https://github.com/denoland/deno/issues/14123 - // to workaround this we copy the wasm files manually - // (note Deno 2 allows to vendor wasm files, but it also require modules to import them and not fetch and instantiate them - // se being able to drop downloading is dependent on implementation of wasm handling in external modules as well) - await Promise.all( - wasmFilesToDownload.map(async (urlString) => { - const url = new URL(urlString) + // // deno vendor doesn't work well with wasm files + // // see https://github.com/denoland/deno/issues/14123 + // // to workaround this we copy the wasm files manually + // // (note Deno 2 allows to vendor wasm files, but it also require modules to import them and not fetch and instantiate them + // // so being able to drop downloading is dependent on implementation of wasm handling in external modules as well) + // await Promise.all( + // wasmFilesToDownload.map(async (urlString) => { + // const url = new URL(urlString) - const destination = join(vendorDest, url.hostname, url.pathname) + // const destination = join(vendorDest, url.hostname, url.pathname) - const res = await fetch(url) - if (!res.ok) - throw new Error(`Failed to fetch .wasm file to vendor. Response status: ${res.status}`) - const fileStream = createWriteStream(destination, { flags: 'wx' }) - await finished(Readable.fromWeb(res.body).pipe(fileStream)) - }), - ) - } + // const res = await fetch(url) + // if (!res.ok) + // throw new Error(`Failed to fetch .wasm file to vendor. Response status: ${res.status}`) + // const fileStream = createWriteStream(destination, { flags: 'wx' }) + // await finished(Readable.fromWeb(res.body).pipe(fileStream)) + // }), + // ) + // } console.log(`✅ Vendored Deno modules for '${vendorSource}' into '${vendorDest}'`) }