Skip to content

Commit

Permalink
Merge branch 'canary' into add/styled-jsx-ts-warning
Browse files Browse the repository at this point in the history
  • Loading branch information
padmaia committed Feb 10, 2022
2 parents 6cebd43 + 49fbbf4 commit dca5051
Show file tree
Hide file tree
Showing 20 changed files with 73 additions and 43 deletions.
2 changes: 2 additions & 0 deletions docs/advanced-features/preview-mode.md
Expand Up @@ -186,6 +186,8 @@ export default function handler(req, res) {
}
```

> **Note:** If calling this route using `Link` component, you must pass in `prefetch={false}` to prevent calling `clearPreviewData` during prefetch.
### Specify the preview mode duration

`setPreviewData` takes an optional second parameter which should be an options object. It accepts the following keys:
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Expand Up @@ -16,5 +16,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "12.0.11-canary.10"
"version": "12.0.11-canary.11"
}
2 changes: 1 addition & 1 deletion packages/create-next-app/package.json
@@ -1,6 +1,6 @@
{
"name": "create-next-app",
"version": "12.0.11-canary.10",
"version": "12.0.11-canary.11",
"keywords": [
"react",
"next",
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config-next/package.json
@@ -1,6 +1,6 @@
{
"name": "eslint-config-next",
"version": "12.0.11-canary.10",
"version": "12.0.11-canary.11",
"description": "ESLint configuration used by NextJS.",
"main": "index.js",
"license": "MIT",
Expand All @@ -9,7 +9,7 @@
"directory": "packages/eslint-config-next"
},
"dependencies": {
"@next/eslint-plugin-next": "12.0.11-canary.10",
"@next/eslint-plugin-next": "12.0.11-canary.11",
"@rushstack/eslint-patch": "^1.0.8",
"@typescript-eslint/parser": "^5.0.0",
"eslint-import-resolver-node": "^0.3.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-next/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/eslint-plugin-next",
"version": "12.0.11-canary.10",
"version": "12.0.11-canary.11",
"description": "ESLint plugin for NextJS.",
"main": "lib/index.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-bundle-analyzer/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/bundle-analyzer",
"version": "12.0.11-canary.10",
"version": "12.0.11-canary.11",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-codemod/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/codemod",
"version": "12.0.11-canary.10",
"version": "12.0.11-canary.11",
"license": "MIT",
"dependencies": {
"chalk": "4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-env/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/env",
"version": "12.0.11-canary.10",
"version": "12.0.11-canary.11",
"keywords": [
"react",
"next",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-mdx/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/mdx",
"version": "12.0.11-canary.10",
"version": "12.0.11-canary.11",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-storybook/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-storybook",
"version": "12.0.11-canary.10",
"version": "12.0.11-canary.11",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-storybook"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-module/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-module",
"version": "12.0.11-canary.10",
"version": "12.0.11-canary.11",
"description": "A standard library polyfill for ES Modules supporting browsers (Edge 16+, Firefox 60+, Chrome 61+, Safari 10.1+)",
"main": "dist/polyfill-module.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-nomodule/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-nomodule",
"version": "12.0.11-canary.10",
"version": "12.0.11-canary.11",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-swc/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/swc",
"version": "12.0.11-canary.10",
"version": "12.0.11-canary.11",
"private": true,
"scripts": {
"build-native": "napi build --platform --cargo-name next_swc_napi native",
Expand Down
5 changes: 2 additions & 3 deletions packages/next/build/index.ts
Expand Up @@ -572,9 +572,8 @@ export default async function build(
hasServerComponents
? path.join(
SERVER_DIRECTORY,
MIDDLEWARE_FLIGHT_MANIFEST + runtime === 'edge'
? '.js'
: '.json'
MIDDLEWARE_FLIGHT_MANIFEST +
(runtime === 'edge' ? '.js' : '.json')
)
: null,
REACT_LOADABLE_MANIFEST,
Expand Down
14 changes: 7 additions & 7 deletions packages/next/package.json
@@ -1,6 +1,6 @@
{
"name": "next",
"version": "12.0.11-canary.10",
"version": "12.0.11-canary.11",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
Expand Down Expand Up @@ -69,7 +69,7 @@
]
},
"dependencies": {
"@next/env": "12.0.11-canary.10",
"@next/env": "12.0.11-canary.11",
"caniuse-lite": "^1.0.30001283",
"postcss": "8.4.5",
"styled-jsx": "5.0.0",
Expand Down Expand Up @@ -117,11 +117,11 @@
"@hapi/accept": "5.0.2",
"@napi-rs/cli": "1.2.1",
"@napi-rs/triples": "1.0.3",
"@next/polyfill-module": "12.0.11-canary.10",
"@next/polyfill-nomodule": "12.0.11-canary.10",
"@next/react-dev-overlay": "12.0.11-canary.10",
"@next/react-refresh-utils": "12.0.11-canary.10",
"@next/swc": "12.0.11-canary.10",
"@next/polyfill-module": "12.0.11-canary.11",
"@next/polyfill-nomodule": "12.0.11-canary.11",
"@next/react-dev-overlay": "12.0.11-canary.11",
"@next/react-refresh-utils": "12.0.11-canary.11",
"@next/swc": "12.0.11-canary.11",
"@peculiar/webcrypto": "1.1.7",
"@taskr/clear": "1.1.0",
"@taskr/esnext": "1.1.0",
Expand Down
31 changes: 20 additions & 11 deletions packages/next/server/next-server.ts
Expand Up @@ -95,7 +95,7 @@ export interface NodeRequestHandler {
}

export default class NextNodeServer extends BaseServer {
private imageResponseCache: ResponseCache
private imageResponseCache?: ResponseCache

constructor(options: Options) {
// Initialize super class
Expand All @@ -117,15 +117,17 @@ export default class NextNodeServer extends BaseServer {
process.env.__NEXT_OPTIMIZE_CSS = JSON.stringify(true)
}

const { ImageOptimizerCache } =
require('./image-optimizer') as typeof import('./image-optimizer')
if (!this.minimalMode) {
const { ImageOptimizerCache } =
require('./image-optimizer') as typeof import('./image-optimizer')

this.imageResponseCache = new ResponseCache(
new ImageOptimizerCache({
distDir: this.distDir,
nextConfig: this.nextConfig,
})
)
this.imageResponseCache = new ResponseCache(
new ImageOptimizerCache({
distDir: this.distDir,
nextConfig: this.nextConfig,
})
)
}
}

private compression =
Expand Down Expand Up @@ -170,8 +172,6 @@ export default class NextNodeServer extends BaseServer {
}

protected generateImageRoutes(): Route[] {
const { getHash, ImageOptimizerCache, sendResponse, ImageError } =
require('./image-optimizer') as typeof import('./image-optimizer')
return [
{
match: route('/_next/image'),
Expand All @@ -185,6 +185,15 @@ export default class NextNodeServer extends BaseServer {
finished: true,
}
}
const { getHash, ImageOptimizerCache, sendResponse, ImageError } =
require('./image-optimizer') as typeof import('./image-optimizer')

if (!this.imageResponseCache) {
throw new Error(
'invariant image optimizer cache was not initialized'
)
}

const imagesConfig = this.nextConfig.images

if (imagesConfig.loader !== 'default') {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dev-overlay/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/react-dev-overlay",
"version": "12.0.11-canary.10",
"version": "12.0.11-canary.11",
"description": "A development-only overlay for developing React applications.",
"repository": {
"url": "vercel/next.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-refresh-utils/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/react-refresh-utils",
"version": "12.0.11-canary.10",
"version": "12.0.11-canary.11",
"description": "An experimental package providing utilities for React Refresh.",
"repository": {
"url": "vercel/next.js",
Expand Down
Expand Up @@ -148,16 +148,25 @@ describe('Edge runtime - prod', () => {

it('should generate middleware SSR manifests for edge runtime', async () => {
const distServerDir = join(distDir, 'server')
const hasFile = (filename) => fs.existsSync(join(distServerDir, filename))

const files = [
'middleware-build-manifest.js',
'middleware-flight-manifest.js',
'middleware-ssr-runtime.js',
'middleware-manifest.json',
]

const requiredServerFiles = (
await fs.readJSON(join(distDir, 'required-server-files.json'))
).files

files.forEach((file) => {
expect(hasFile(file)).toBe(true)
const filepath = join(distServerDir, file)
expect(fs.existsSync(filepath)).toBe(true)
})

requiredServerFiles.forEach((file) => {
const requiredFilePath = join(appDir, file)
expect(fs.existsSync(requiredFilePath)).toBe(true)
})
})

Expand Down Expand Up @@ -250,17 +259,25 @@ const nodejsRuntimeBasicSuite = {
if (env === 'prod') {
it('should generate middleware SSR manifests for Node.js', async () => {
const distServerDir = join(distDir, 'server')
const hasFile = (filename) =>
fs.existsSync(join(distServerDir, filename))

const requiredServerFiles = (
await fs.readJSON(join(distDir, 'required-server-files.json'))
).files

const files = [
'middleware-build-manifest.js',
'middleware-flight-manifest.json',
'middleware-manifest.json',
]

files.forEach((file) => {
if (!hasFile(file)) console.log(file)
expect(hasFile(file)).toBe(true)
const filepath = join(distServerDir, file)
expect(fs.existsSync(filepath)).toBe(true)
})

requiredServerFiles.forEach((file) => {
const requiredFilePath = join(appDir, file)
expect(fs.existsSync(requiredFilePath)).toBe(true)
})
})
}
Expand Down
3 changes: 3 additions & 0 deletions test/production/required-server-files.test.ts
Expand Up @@ -21,6 +21,9 @@ describe('should set-up next', () => {
let requiredFilesManifest

beforeAll(async () => {
// test build against environment with next support
process.env.NOW_BUILDER = '1'

next = await createNext({
files: {
pages: new FileRef(join(__dirname, 'required-server-files/pages')),
Expand Down

0 comments on commit dca5051

Please sign in to comment.