Skip to content

Commit

Permalink
Merge branch 'vercel:canary' into update-typescript-eslint-parser
Browse files Browse the repository at this point in the history
  • Loading branch information
ytkg committed Apr 15, 2022
2 parents af3e58b + 1582e11 commit 0ce93d7
Show file tree
Hide file tree
Showing 42 changed files with 265 additions and 59 deletions.
3 changes: 2 additions & 1 deletion .alexrc
Expand Up @@ -16,6 +16,7 @@
"hook",
"hooks",
"host-hostess",
"invalid"
"invalid",
"remains"
]
}
6 changes: 3 additions & 3 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Expand Up @@ -2,9 +2,9 @@
# https://help.github.com/en/articles/about-code-owners

* @timneutkens @ijjk @shuding @huozhi
/.github/ @timneutkens @ijjk @shuding @styfle @huozhi @padmaia
/docs/ @timneutkens @ijjk @shuding @styfle @huozhi @padmaia @leerob @lfades @molebox
/examples/ @timneutkens @ijjk @shuding @leerob @lfades @steven-tey
/.github/ @timneutkens @ijjk @shuding @styfle @huozhi @padmaia @balazsorban44
/docs/ @timneutkens @ijjk @shuding @styfle @huozhi @padmaia @leerob @balazsorban44
/examples/ @timneutkens @ijjk @shuding @leerob @steven-tey @balazsorban44

# SWC Build (@padmaia)

Expand Down
2 changes: 1 addition & 1 deletion docs/basic-features/data-fetching/get-static-props.md
Expand Up @@ -20,8 +20,8 @@ You should use `getStaticProps` if:

- The data required to render the page is available at build time ahead of a user’s request
- The data comes from a headless CMS
- The data can be publicly cached (not user-specific)
- The page must be pre-rendered (for SEO) and be very fast — `getStaticProps` generates `HTML` and `JSON` files, both of which can be cached by a CDN for performance
- The data can be publicly cached (not user-specific). This condition can be bypassed in certain specific situation by using a Middleware to rewrite the path.

## When does getStaticProps run

Expand Down
6 changes: 4 additions & 2 deletions docs/migrating/from-create-react-app.md
Expand Up @@ -39,7 +39,7 @@ Here's an example `package.json`:

## Static Assets and Compiled Output

Create React App uses the `public` directory for the [entry HTML file](https://create-react-app.dev/docs/using-the-public-folder), whereas Next.js uses it for static assets. It's possible to add static assets here, but Create React App recommends importing them directly from JavaScript files.
Create React App uses the `public` directory for the [entry HTML file](https://create-react-app.dev/docs/using-the-public-folder) as well as static assets, but Next.js only uses it for static assets. When migrating from Create React App, the location of the `public` directory remains the same.

- Move any images, fonts, or other static assets to `public`.
- Convert `index.html` (the entry point of your application) to Next.js. Any `<head>` code should be moved to a [custom `_document.js`](/docs/advanced-features/custom-document.md). Any shared layout between all pages should be moved to a [custom `_app.js`](/docs/advanced-features/custom-app.md).
Expand All @@ -50,7 +50,9 @@ Create React App uses the `public` directory for the [entry HTML file](https://c

With Create React App, you're likely using React Router. Instead of using a third-party library, Next.js includes its own [file-system based routing](/docs/routing/introduction.md).

- Convert all `Route` components to new files in the `pages` directory.
- Create a [`pages`](/docs/basic-features/pages.md) directory at the root of your project.
- Then, move the `src/App.js` file to `pages/index.js`. This file is the [index page](https://nextjs.org/docs/routing/introduction#index-routes) of your Next.js application. Populate this file with code that is used to display the index route in your Create React App.
- Convert all other `Route` components to new files in the `pages` directory.
- For routes that require dynamic content (e.g. `/blog/:slug`), you can use [Dynamic Routes](/docs/routing/dynamic-routes.md) with Next.js (e.g. `pages/blog/[slug].js`). The value of `slug` is accessible through a [query parameter](/docs/routing/dynamic-routes.md). For example, the route `/blog/first-post` would forward the query object `{ 'slug': 'first-post' }` to `pages/blog/[slug].js` ([learn more here](/docs/basic-features/data-fetching/get-static-paths.md)).

For more information, see [Migrating from React Router](/docs/migrating/from-react-router.md).
Expand Down
2 changes: 1 addition & 1 deletion docs/upgrading.md
Expand Up @@ -12,7 +12,7 @@ The minimum Node.js version has been bumped from 12.0.0 to 12.22.0 which is the

### Upgrade React version to latest

To upgrade you can run the following command:
The minimum required React version is `17.0.2`. To upgrade you can run the following command in the terminal:

```
npm install react@latest react-dom@latest
Expand Down
4 changes: 4 additions & 0 deletions errors/manifest.json
Expand Up @@ -649,6 +649,10 @@
{
"title": "invalid-getserversideprops-return-value",
"path": "/errors/invalid-getserversideprops-return-value.md"
},
{
"title": "no-assign-module-variable",
"path": "/errors/no-assign-module-variable.md"
}
]
}
Expand Down
13 changes: 13 additions & 0 deletions errors/no-assign-module-variable.md
@@ -0,0 +1,13 @@
# No assign module variable

#### Why This Error Occurred

A value is being assigned to the `module` variable. The `module` variable is already used and it is highly likely that assigning to this variable will cause errors.

#### Possible Ways to Fix It

Use a different variable name:

```js
let myModule = {...}
```
2 changes: 1 addition & 1 deletion lerna.json
Expand Up @@ -16,5 +16,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "12.1.6-canary.0"
"version": "12.1.6-canary.1"
}
2 changes: 1 addition & 1 deletion packages/create-next-app/package.json
@@ -1,6 +1,6 @@
{
"name": "create-next-app",
"version": "12.1.6-canary.0",
"version": "12.1.6-canary.1",
"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.1.6-canary.0",
"version": "12.1.6-canary.1",
"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.1.6-canary.0",
"@next/eslint-plugin-next": "12.1.6-canary.1",
"@rushstack/eslint-patch": "1.0.8",
"@typescript-eslint/parser": "5.19.0",
"eslint-import-resolver-node": "0.3.4",
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-plugin-next/lib/index.js
Expand Up @@ -20,6 +20,7 @@ module.exports = {
'no-duplicate-head': require('./rules/no-duplicate-head'),
'inline-script-id': require('./rules/inline-script-id'),
'next-script-for-ga': require('./rules/next-script-for-ga'),
'no-assign-module-variable': require('./rules/no-assign-module-variable'),
},
configs: {
recommended: {
Expand All @@ -45,6 +46,7 @@ module.exports = {
'@next/next/no-typos': 1,
'@next/next/no-duplicate-head': 2,
'@next/next/inline-script-id': 2,
'@next/next/no-assign-module-variable': 2,
},
},
'core-web-vitals': {
Expand Down
30 changes: 30 additions & 0 deletions packages/eslint-plugin-next/lib/rules/no-assign-module-variable.js
@@ -0,0 +1,30 @@
module.exports = {
meta: {
docs: {
description: `Prohibit assignment to the 'module' variable`,
recommended: true,
url: 'https://nextjs.org/docs/messages/no-assign-module-variable',
},
},

create: function (context) {
return {
VariableDeclaration(node) {
// Checks node.declarations array for variable with id.name of 'module'
const moduleVariableFound = node.declarations.some(
(declaration) => declaration.id.name === 'module'
)

// Return early if no 'module' variable is found
if (!moduleVariableFound) {
return
}

context.report({
node,
message: `Do not assign to the variable 'module'. See: https://nextjs.org/docs/messages/no-assign-module-variable`,
})
},
}
},
}
2 changes: 1 addition & 1 deletion packages/eslint-plugin-next/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/eslint-plugin-next",
"version": "12.1.6-canary.0",
"version": "12.1.6-canary.1",
"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.1.6-canary.0",
"version": "12.1.6-canary.1",
"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.1.6-canary.0",
"version": "12.1.6-canary.1",
"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.1.6-canary.0",
"version": "12.1.6-canary.1",
"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.1.6-canary.0",
"version": "12.1.6-canary.1",
"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.1.6-canary.0",
"version": "12.1.6-canary.1",
"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.1.6-canary.0",
"version": "12.1.6-canary.1",
"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.1.6-canary.0",
"version": "12.1.6-canary.1",
"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.1.6-canary.0",
"version": "12.1.6-canary.1",
"private": true,
"scripts": {
"build-native": "napi build --platform --cargo-name next_swc_napi native",
Expand Down
5 changes: 1 addition & 4 deletions packages/next/build/utils.ts
Expand Up @@ -1172,10 +1172,7 @@ export async function copyTracedFiles(

if (symlink) {
console.log('symlink', path.relative(tracingRoot, symlink))
await fs.symlink(
path.relative(tracingRoot, symlink),
fileOutputPath
)
await fs.symlink(symlink, fileOutputPath)
} else {
await fs.copyFile(tracedFilePath, fileOutputPath)
}
Expand Down
8 changes: 4 additions & 4 deletions packages/next/compiled/use-subscription/index.js

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

14 changes: 7 additions & 7 deletions packages/next/package.json
@@ -1,6 +1,6 @@
{
"name": "next",
"version": "12.1.6-canary.0",
"version": "12.1.6-canary.1",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
Expand Down Expand Up @@ -69,7 +69,7 @@
]
},
"dependencies": {
"@next/env": "12.1.6-canary.0",
"@next/env": "12.1.6-canary.1",
"caniuse-lite": "^1.0.30001283",
"postcss": "8.4.5",
"styled-jsx": "5.0.1"
Expand Down Expand Up @@ -117,11 +117,11 @@
"@hapi/accept": "5.0.2",
"@napi-rs/cli": "2.4.4",
"@napi-rs/triples": "1.1.0",
"@next/polyfill-module": "12.1.6-canary.0",
"@next/polyfill-nomodule": "12.1.6-canary.0",
"@next/react-dev-overlay": "12.1.6-canary.0",
"@next/react-refresh-utils": "12.1.6-canary.0",
"@next/swc": "12.1.6-canary.0",
"@next/polyfill-module": "12.1.6-canary.1",
"@next/polyfill-nomodule": "12.1.6-canary.1",
"@next/react-dev-overlay": "12.1.6-canary.1",
"@next/react-refresh-utils": "12.1.6-canary.1",
"@next/swc": "12.1.6-canary.1",
"@peculiar/webcrypto": "1.3.1",
"@taskr/clear": "1.1.0",
"@taskr/esnext": "1.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/next/server/api-utils/node.ts
Expand Up @@ -442,7 +442,7 @@ function sendJson(res: NextApiResponse, jsonBody: any): void {
res.setHeader('Content-Type', 'application/json; charset=utf-8')

// Use send to handle request
res.send(jsonBody)
res.send(JSON.stringify(jsonBody))
}

function isNotValidData(str: string): boolean {
Expand Down
11 changes: 2 additions & 9 deletions packages/next/server/render.tsx
Expand Up @@ -431,14 +431,7 @@ function createServerComponentRenderer(
return root
}

// Although it's not allowed to attach some static methods to Component,
// we still re-assign all the component APIs to keep the behavior unchanged.
for (const methodName of [
'getInitialProps',
'getStaticProps',
'getServerSideProps',
'getStaticPaths',
]) {
for (const methodName of Object.keys(Component)) {
const method = (Component as any)[methodName]
if (method) {
;(ServerComponentWrapper as any)[methodName] = method
Expand Down Expand Up @@ -1375,7 +1368,7 @@ export async function renderToHTML(
<AppContainerWithIsomorphicFiberStructure>
{isServerComponent && !!AppMod.__next_rsc__ ? (
// _app.server.js is used.
<Component {...props.pageProps} router={router} />
<Component {...props.pageProps} />
) : (
<App {...props} Component={Component} router={router} />
)}
Expand Down
3 changes: 1 addition & 2 deletions packages/next/server/web-server.ts
Expand Up @@ -169,8 +169,7 @@ export default class NextWebServer extends BaseServer {
if (options.result.isDynamic()) {
const writer = res.transformStream.writable.getWriter()
options.result.pipe({
write: (chunk: Uint8Array) =>
writer.write(new TextDecoder().decode(chunk)),
write: (chunk: Uint8Array) => writer.write(chunk),
end: () => writer.close(),
destroy: (err: Error) => writer.abort(err),
cork: () => {},
Expand Down
1 change: 1 addition & 0 deletions packages/next/taskfile.js
Expand Up @@ -313,6 +313,7 @@ export async function ncc_use_subscription(task, opts) {
react: 'react',
'react-dom': 'react-dom',
},
target: 'es5',
})
.target('compiled/use-subscription')
}
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.1.6-canary.0",
"version": "12.1.6-canary.1",
"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.1.6-canary.0",
"version": "12.1.6-canary.1",
"description": "An experimental package providing utilities for React Refresh.",
"repository": {
"url": "vercel/next.js",
Expand Down
3 changes: 3 additions & 0 deletions test/integration/api-support/pages/api/json-null.js
@@ -0,0 +1,3 @@
export default (req, res) => {
res.json(null)
}
3 changes: 3 additions & 0 deletions test/integration/api-support/pages/api/json-string.js
@@ -0,0 +1,3 @@
export default (req, res) => {
res.json('Hello world!')
}

0 comments on commit 0ce93d7

Please sign in to comment.