Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to latest @edge-runtime packages #62955

Merged
merged 4 commits into from
Mar 6, 2024
Merged
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@
"@babel/plugin-proposal-object-rest-spread": "7.20.7",
"@babel/preset-flow": "7.22.5",
"@babel/preset-react": "7.22.5",
"@edge-runtime/jest-environment": "2.3.4",
"@edge-runtime/jest-environment": "2.3.10",
"@emotion/cache": "11.11.0",
"@emotion/react": "11.11.1",
"@fullhuman/postcss-purgecss": "1.3.0",
4 changes: 2 additions & 2 deletions packages/next/package.json
Original file line number Diff line number Diff line change
@@ -138,8 +138,8 @@
"@babel/types": "7.22.5",
"@capsizecss/metrics": "2.0.0",
"@edge-runtime/cookies": "4.1.0",
"@edge-runtime/ponyfill": "2.4.1",
"@edge-runtime/primitives": "4.0.2",
"@edge-runtime/ponyfill": "2.4.2",
"@edge-runtime/primitives": "4.1.0",
"@hapi/accept": "5.0.2",
"@jest/transform": "29.5.0",
"@jest/types": "29.5.0",
1 change: 1 addition & 0 deletions packages/next/src/compiled/@edge-runtime/ponyfill/index.js
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ function edge() {
File,
FormData,
Headers,
performance,
PromiseRejectionEvent,
ReadableStream,
ReadableStreamBYOBReader,
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name":"@edge-runtime/ponyfill","version":"2.4.1","main":"./index.js","types":"./index.d.ts","license":"MPL-2.0"}
{"name":"@edge-runtime/ponyfill","version":"2.4.2","main":"./index.js","types":"./index.d.ts","license":"MPL-2.0"}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

This file was deleted.

Empty file.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -313,7 +313,6 @@ declare namespace Event$1 {
declare const EventTargetConstructor: typeof EventTarget
declare const EventConstructor: typeof Event


declare class FetchEvent {
request: Request
response: Response | null

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -24,4 +24,4 @@ declare const FileConstructor: typeof File
declare const FormDataConstructor: typeof FormData
declare const WebSocketConstructor: typeof WebSocket

export { FileConstructor as File, FormDataConstructor as FormData, Headers, Request, RequestInfo, RequestInit, Response, WebSocketConstructor as WebSocket, fetchImplementation as fetch };
export { FileConstructor as File, FormDataConstructor as FormData, Headers, Request, type RequestInfo, type RequestInit, Response, WebSocketConstructor as WebSocket, fetchImplementation as fetch };

Large diffs are not rendered by default.

14 changes: 11 additions & 3 deletions packages/next/src/compiled/@edge-runtime/primitives/index.d.ts
Original file line number Diff line number Diff line change
@@ -2,13 +2,19 @@ export { AbortController, AbortSignal, DOMException } from './abort-controller.d
export { Blob } from './blob.d.js';
export { console } from './console.d.js';
export { Crypto, CryptoKey, SubtleCrypto, crypto } from './crypto.d.js';
export { TextDecoder, TextEncoder, atob, btoa } from './encoding.d.js';
export { Event, EventTarget, FetchEvent, PromiseRejectionEvent } from './events.d.js';
export { File, FormData, Headers, Request, RequestInfo, RequestInit, Response, WebSocket, fetch } from './fetch.d.js';
export { structuredClone } from './structured-clone.d.js';
export { URL, URLPattern, URLSearchParams } from './url.d.js';
export { setInterval, setTimeout } from './timers.d.js';

declare const TextEncoderConstructor: typeof TextEncoder
declare const TextDecoderConstructor: typeof TextDecoder


declare const _atob: typeof atob
declare const _btoa: typeof btoa

/**
* The type of `ReadableStreamBYOBReader` is not included in Typescript so we
* are declaring it inline to not have to worry about bundling.
@@ -18,7 +24,7 @@ declare class ReadableStreamBYOBReader {
get closed(): Promise<undefined>
cancel(reason?: any): Promise<void>
read<T extends ArrayBufferView>(
view: T
view: T,
): Promise<{ done: false; value: T } | { done: true; value: T | undefined }>
releaseLock(): void
}
@@ -33,4 +39,6 @@ declare const WritableStreamDefaultWriterConstructor: typeof WritableStreamDefau
declare const TextDecoderStreamConstructor: typeof TextDecoderStream
declare const TextEncoderStreamConstructor: typeof TextEncoderStream

export { ReadableStreamConstructor as ReadableStream, ReadableStreamBYOBReaderConstructor as ReadableStreamBYOBReader, ReadableStreamDefaultReaderConstructor as ReadableStreamDefaultReader, TextDecoderStreamConstructor as TextDecoderStream, TextEncoderStreamConstructor as TextEncoderStream, TransformStreamConstructor as TransformStream, WritableStreamConstructor as WritableStream, WritableStreamDefaultWriterConstructor as WritableStreamDefaultWriter };
declare const performanceConstructor: typeof performance

export { ReadableStreamConstructor as ReadableStream, ReadableStreamBYOBReaderConstructor as ReadableStreamBYOBReader, ReadableStreamDefaultReaderConstructor as ReadableStreamDefaultReader, TextDecoderConstructor as TextDecoder, TextDecoderStreamConstructor as TextDecoderStream, TextEncoderConstructor as TextEncoder, TextEncoderStreamConstructor as TextEncoderStream, TransformStreamConstructor as TransformStream, WritableStreamConstructor as WritableStream, WritableStreamDefaultWriterConstructor as WritableStreamDefaultWriter, _atob as atob, _btoa as btoa, performanceConstructor as performance };
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ import * as __index from './index';
* ```
*/
declare function load(
scopedContext: Record<string, unknown>
scopedContext: Record<string, unknown>,
): typeof __index

export { load };
11 changes: 3 additions & 8 deletions packages/next/src/compiled/@edge-runtime/primitives/load.js
Original file line number Diff line number Diff line change
@@ -74,19 +74,14 @@ function requireWithFakeGlobalScope(params) {
__name(requireWithFakeGlobalScope, "requireWithFakeGlobalScope");
function load(scopedContext = {}) {
const context = {};
const encodingImpl = requireWithFakeGlobalScope({
context,
id: "encoding.js",
sourceCode: require("./encoding.js.text.js"),
scopedContext
});
assign(context, {
TextDecoder,
TextEncoder,
TextEncoderStream: import_web.TextEncoderStream,
TextDecoderStream: import_web.TextDecoderStream,
atob: encodingImpl.atob,
btoa: encodingImpl.btoa
atob,
btoa,
performance
});
const consoleImpl = requireWithFakeGlobalScope({
context,
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name":"@edge-runtime/primitives","version":"4.0.2","main":"./index.js","license":"MPL-2.0"}
{"name":"@edge-runtime/primitives","version":"4.1.0","main":"./index.js","license":"MPL-2.0"}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
declare const _setTimeout: typeof Number
declare const _setInterval: typeof Number
declare const _setTimeout: (callback: () => void, ms?: number) => number
declare const _setInterval: (callback: () => void, ms?: number) => number

export { _setInterval as setInterval, _setTimeout as setTimeout };

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions packages/next/src/server/web/sandbox/context.ts
Original file line number Diff line number Diff line change
@@ -425,6 +425,8 @@ Learn More: https://nextjs.org/docs/messages/edge-dynamic-code-evaluation`),

Object.assign(context, wasm)

context.performance = performance

context.AsyncLocalStorage = AsyncLocalStorage

// @ts-ignore the timeouts have weird types in the edge runtime
144 changes: 73 additions & 71 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions test/e2e/opentelemetry/app/api/app/[param]/data/edge/route.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// ensure performance is available in edge
console.log(performance.now())

export async function GET() {
return new Response(JSON.stringify({ test: 'data-edge' }))
}
2 changes: 2 additions & 0 deletions test/e2e/opentelemetry/pages/api/pages/[param]/edge.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export const config = {
runtime: 'edge',
}
// ensure performance is available in edge
console.log(performance.now())

export default function handler(req) {
return Response.json({ text: 'hello world' })