Skip to content

Commit

Permalink
Merge branch 'canary' into fix/swc-minify-buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Sep 11, 2021
2 parents 156426e + 1f99c30 commit 526124e
Show file tree
Hide file tree
Showing 12 changed files with 455 additions and 408 deletions.
18 changes: 0 additions & 18 deletions packages/next/compiled/zen-observable/LICENSE

This file was deleted.

1 change: 0 additions & 1 deletion packages/next/compiled/zen-observable/esm.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/next/compiled/zen-observable/package.json

This file was deleted.

4 changes: 1 addition & 3 deletions packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@
"@types/text-table": "0.2.1",
"@types/webpack": "5.28.0",
"@types/webpack-sources": "0.1.5",
"@types/zen-observable": "0.8.3",
"@vercel/ncc": "0.27.0",
"@vercel/nft": "0.12.2",
"amphtml-validator": "1.0.33",
Expand Down Expand Up @@ -252,8 +251,7 @@
"unistore": "3.4.1",
"web-vitals": "2.1.0",
"webpack": "4.44.1",
"webpack-sources": "1.4.3",
"zen-observable": "0.8.15"
"webpack-sources": "1.4.3"
},
"engines": {
"node": ">=12.0.0"
Expand Down
34 changes: 17 additions & 17 deletions packages/next/server/render-result.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
import { ServerResponse } from 'http'
import Observable from 'next/dist/compiled/zen-observable'
import { Writable } from 'stream'

export type NodeWritablePiper = (
res: Writable,
next: (err?: Error) => void
) => void

export default class RenderResult {
_response: string | Observable<string>
_result: string | NodeWritablePiper

constructor(response: string | Observable<string>) {
this._response = response
constructor(response: string | NodeWritablePiper) {
this._result = response
}

toUnchunkedString(): string {
if (typeof this._response !== 'string') {
if (typeof this._result !== 'string') {
throw new Error(
'invariant: dynamic responses cannot be unchunked. This is a bug in Next.js'
)
}
return this._response
return this._result
}

async pipe(res: ServerResponse): Promise<void> {
if (typeof this._response === 'string') {
pipe(res: ServerResponse): Promise<void> {
if (typeof this._result === 'string') {
throw new Error(
'invariant: static responses cannot be piped. This is a bug in Next.js'
)
}
const maybeFlush =
typeof (res as any).flush === 'function'
? () => (res as any).flush()
: () => {}
await this._response.forEach((chunk) => {
res.write(chunk)
maybeFlush()
const response = this._result
return new Promise((resolve, reject) => {
response(res, (err) => (err ? reject(err) : resolve()))
})
res.end()
}

isDynamic(): boolean {
return typeof this._response !== 'string'
return typeof this._result !== 'string'
}

static fromStatic(value: string): RenderResult {
Expand Down
Loading

0 comments on commit 526124e

Please sign in to comment.