diff --git a/packages/next/server/web/sandbox/polyfills.ts b/packages/next/server/web/sandbox/polyfills.ts index 2a02824f99f7811..75d168e3662a4d9 100644 --- a/packages/next/server/web/sandbox/polyfills.ts +++ b/packages/next/server/web/sandbox/polyfills.ts @@ -1,7 +1,5 @@ -import { - Crypto as WebCrypto, - CryptoKey, -} from 'next/dist/compiled/@peculiar/webcrypto' +import { Crypto as WebCrypto } from 'next/dist/compiled/@peculiar/webcrypto' +import { CryptoKey } from 'next/dist/compiled/@peculiar/webcrypto' import { TransformStream } from 'next/dist/compiled/web-streams-polyfill' import { v4 as uuid } from 'next/dist/compiled/uuid' import crypto from 'crypto' @@ -14,48 +12,6 @@ export function btoa(str: string) { return Buffer.from(str, 'binary').toString('base64') } -class TextEncoderRuntime { - encoder: TextEncoder - - constructor() { - this.encoder = new TextEncoder() - } - - get encoding() { - return this.encoder.encoding - } - - public encode(input: string) { - return this.encoder.encode(input) - } -} - -class TextDecoderRuntime { - decoder: TextDecoder - - constructor() { - this.decoder = new TextDecoder() - } - - get encoding() { - return this.decoder.encoding - } - - get fatal() { - return this.decoder.fatal - } - - get ignoreBOM() { - return this.decoder.ignoreBOM - } - - public decode(input: BufferSource, options?: TextDecodeOptions) { - return this.decoder.decode(input, options) - } -} - -export { TextDecoderRuntime as TextDecoder } -export { TextEncoderRuntime as TextEncoder } export { CryptoKey } export class Crypto extends WebCrypto { diff --git a/packages/next/server/web/sandbox/sandbox.ts b/packages/next/server/web/sandbox/sandbox.ts index 688a0ebb78905a8..af77b0680f6a4aa 100644 --- a/packages/next/server/web/sandbox/sandbox.ts +++ b/packages/next/server/web/sandbox/sandbox.ts @@ -82,8 +82,8 @@ export async function run(params: { ReadableStream: polyfills.ReadableStream, setInterval, setTimeout, - TextDecoder: polyfills.TextDecoder, - TextEncoder: polyfills.TextEncoder, + TextDecoder, + TextEncoder, TransformStream, URL, URLSearchParams,