diff --git a/deno.json b/deno.json index 28e8ea6c3c..561c910ed5 100644 --- a/deno.json +++ b/deno.json @@ -6,5 +6,6 @@ }, "imports": { "@netlify/edge-functions": "https://edge.netlify.com/v1/index.ts" - } + }, + "importMap": "./edge-runtime/vendor/import_map.json" } diff --git a/edge-runtime/lib/middleware.ts b/edge-runtime/lib/middleware.ts index 46bbef6888..2ae25c1d34 100644 --- a/edge-runtime/lib/middleware.ts +++ b/edge-runtime/lib/middleware.ts @@ -1,6 +1,6 @@ import type { Context } from '@netlify/edge-functions' -import { ElementHandlers } from '../vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/index.ts' +import type { ElementHandlers } from '../vendor/deno.land/x/htmlrewriter@v1.0.0/src/index.ts' type NextDataTransform = (data: T) => T diff --git a/edge-runtime/lib/response.ts b/edge-runtime/lib/response.ts index 3fd82c5ab0..b09ea896a9 100644 --- a/edge-runtime/lib/response.ts +++ b/edge-runtime/lib/response.ts @@ -1,5 +1,9 @@ import type { Context } from '@netlify/edge-functions' -import { HTMLRewriter } from '../vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/index.ts' +import { + HTMLRewriter, + init, + type TextChunk, +} from '../vendor/deno.land/x/htmlrewriter@v1.0.0/src/index.ts' import { updateModifiedHeaders } from './headers.ts' import type { StructuredLogger } from './logging.ts' @@ -13,6 +17,8 @@ import { relativizeURL, } from './util.ts' +await init() + export interface FetchEventResult { response: Response waitUntil: Promise @@ -79,7 +85,7 @@ export const buildResponse = async ({ if (response.dataTransforms.length > 0) { rewriter.on('script[id="__NEXT_DATA__"]', { - text(textChunk) { + text(textChunk: TextChunk) { // Grab all the chunks in the Next data script tag buffer += textChunk.text if (textChunk.lastInTextNode) { diff --git a/edge-runtime/vendor.ts b/edge-runtime/vendor.ts index e8c6720d4d..df153912c3 100644 --- a/edge-runtime/vendor.ts +++ b/edge-runtime/vendor.ts @@ -12,6 +12,6 @@ import 'https://deno.land/std@0.175.0/node/util.ts' import 'https://deno.land/std@0.175.0/path/mod.ts' import 'https://deno.land/x/path_to_regexp@v6.2.1/index.ts' -import 'https://deno.land/x/html_rewriter@v0.1.0-pre.17/index.ts' +import 'https://deno.land/x/htmlrewriter@v1.0.0/src/index.ts' import 'https://v1-7-0--edge-utils.netlify.app/logger/mod.ts'