Skip to content

Commit

Permalink
refactor: use edge runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed May 30, 2022
1 parent ec572b0 commit 6eceae6
Show file tree
Hide file tree
Showing 44 changed files with 571 additions and 2,071 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"@babel/plugin-proposal-object-rest-spread": "7.14.7",
"@babel/preset-flow": "7.14.5",
"@babel/preset-react": "7.14.5",
"@edge-runtime/jest-environment": "1.0.1-beta.10",
"@fullhuman/postcss-purgecss": "1.3.0",
"@mdx-js/loader": "0.18.0",
"@next/bundle-analyzer": "workspace:*",
Expand Down Expand Up @@ -191,7 +192,6 @@
"turbo": "1.2.9",
"typescript": "4.6.3",
"wait-port": "0.2.2",
"web-streams-polyfill": "2.1.1",
"webpack": "link:./node_modules/webpack5",
"webpack-bundle-analyzer": "4.3.0",
"worker-loader": "3.0.7"
Expand Down
1 change: 0 additions & 1 deletion packages/next/compiled/@peculiar/webcrypto/package.json

This file was deleted.

21 changes: 0 additions & 21 deletions packages/next/compiled/abort-controller/LICENSE

This file was deleted.

1 change: 0 additions & 1 deletion packages/next/compiled/abort-controller/package.json

This file was deleted.

21 changes: 0 additions & 21 deletions packages/next/compiled/formdata-node/LICENSE

This file was deleted.

1 change: 0 additions & 1 deletion packages/next/compiled/formdata-node/package.json

This file was deleted.

1 change: 0 additions & 1 deletion packages/next/compiled/uuid/package.json

This file was deleted.

22 changes: 0 additions & 22 deletions packages/next/compiled/web-streams-polyfill/LICENSE

This file was deleted.

1 change: 0 additions & 1 deletion packages/next/compiled/web-streams-polyfill/package.json

This file was deleted.

5 changes: 2 additions & 3 deletions packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
},
"dependencies": {
"@next/env": "12.1.7-canary.23",
"edge-runtime": "1.0.1-beta.10",
"@edge-runtime/primitives": "1.0.1-beta.10",
"caniuse-lite": "^1.0.30001332",
"postcss": "8.4.5",
"styled-jsx": "5.0.2",
Expand Down Expand Up @@ -123,7 +125,6 @@
"@next/react-dev-overlay": "12.1.7-canary.23",
"@next/react-refresh-utils": "12.1.7-canary.23",
"@next/swc": "12.1.7-canary.23",
"@peculiar/webcrypto": "1.3.1",
"@taskr/clear": "1.1.0",
"@taskr/esnext": "1.1.0",
"@taskr/watch": "1.1.0",
Expand Down Expand Up @@ -196,7 +197,6 @@
"events": "3.3.0",
"find-cache-dir": "3.3.1",
"find-up": "4.1.0",
"formdata-node": "4.3.0",
"fresh": "0.5.2",
"get-orientation": "1.1.2",
"glob": "7.1.7",
Expand Down Expand Up @@ -268,7 +268,6 @@
"uuid": "8.3.2",
"vm-browserify": "1.1.2",
"watchpack": "2.3.1",
"web-streams-polyfill": "3.0.3",
"web-vitals": "2.1.0",
"webpack-sources1": "npm:webpack-sources@1.4.3",
"webpack-sources3": "npm:webpack-sources@3.2.3",
Expand Down
4 changes: 2 additions & 2 deletions packages/next/server/body-streams.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import Primitives from '@edge-runtime/primitives'
import type { IncomingMessage } from 'http'
import { Readable } from 'stream'
import { TransformStream } from 'next/dist/compiled/web-streams-polyfill'

type BodyStream = ReadableStream<Uint8Array>

/**
* Creates a ReadableStream from a Node.js HTTP request
*/
function requestToBodyStream(request: IncomingMessage): BodyStream {
const transform = new TransformStream<Uint8Array, Uint8Array>({
const transform = new Primitives.TransformStream<Uint8Array, Uint8Array>({
start(controller) {
request.on('data', (chunk) => controller.enqueue(chunk))
request.on('end', () => controller.terminate())
Expand Down
9 changes: 3 additions & 6 deletions packages/next/server/node-polyfill-web-streams.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import {
ReadableStream,
TransformStream,
} from 'next/dist/compiled/web-streams-polyfill'
import Primitives from '@edge-runtime/primitives'

// Polyfill Web Streams for the Node.js runtime.
if (!global.ReadableStream) {
global.ReadableStream = ReadableStream
global.ReadableStream = Primitives.ReadableStream
}
if (!global.TransformStream) {
global.TransformStream = TransformStream
global.TransformStream = Primitives.TransformStream
}
2 changes: 1 addition & 1 deletion packages/next/server/web/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { fromNodeHeaders } from './utils'
import { NextFetchEvent } from './spec-extension/fetch-event'
import { NextRequest } from './spec-extension/request'
import { NextResponse } from './spec-extension/response'
import { waitUntilSymbol } from './spec-compliant/fetch-event'
import { waitUntilSymbol } from './spec-extension/fetch-event'
import { NextURL } from './next-url'

export async function adapter(params: {
Expand Down
73 changes: 0 additions & 73 deletions packages/next/server/web/form-data.ts

This file was deleted.

80 changes: 0 additions & 80 deletions packages/next/server/web/is.ts

This file was deleted.

Loading

0 comments on commit 6eceae6

Please sign in to comment.