Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
},
"imports": {
"@netlify/edge-functions": "https://edge.netlify.com/v1/index.ts"
}
},
"importMap": "./edge-runtime/vendor/import_map.json"
}
2 changes: 1 addition & 1 deletion edge-runtime/lib/middleware.ts
Original file line number Diff line number Diff line change
@@ -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 = <T>(data: T) => T

Expand Down
10 changes: 8 additions & 2 deletions edge-runtime/lib/response.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -13,6 +17,8 @@ import {
relativizeURL,
} from './util.ts'

await init()

export interface FetchEventResult {
response: Response
waitUntil: Promise<any>
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion edge-runtime/vendor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'