Commit 7863b60e authored by Lukáš Huvar's avatar Lukáš Huvar Committed by Tim Neutkens

Prettier fix (#8754)

parent a0341ea1
...@@ -10,6 +10,7 @@ This handling has been moved up the tree so the `<Container>` component is no lo ...@@ -10,6 +10,7 @@ This handling has been moved up the tree so the `<Container>` component is no lo
Remove the `<Container>` component from your Custom `<App>` (`./pages/_app.js`). Remove the `<Container>` component from your Custom `<App>` (`./pages/_app.js`).
**Before** **Before**
```jsx ```jsx
import React from 'react' import React from 'react'
import App, { Container } from 'next/app' import App, { Container } from 'next/app'
...@@ -29,6 +30,7 @@ export default MyApp ...@@ -29,6 +30,7 @@ export default MyApp
``` ```
**After** **After**
```jsx ```jsx
import React from 'react' import React from 'react'
import App from 'next/app' import App from 'next/app'
......
...@@ -7,12 +7,13 @@ Somewhere you are utilizing the `next/link` component, `Router#push`, or `Router ...@@ -7,12 +7,13 @@ Somewhere you are utilizing the `next/link` component, `Router#push`, or `Router
Note: this error will only show when the `next/link` component is clicked not when only rendered. Note: this error will only show when the `next/link` component is clicked not when only rendered.
**Incompatible `href` and `as`** **Incompatible `href` and `as`**
```jsx ```jsx
import Link from 'next/link' import Link from 'next/link'
export default () => ( export default () => (
<> <>
<Link href='/[post]' as='/post-1/comments'> <Link href="/[post]" as="/post-1/comments">
<a>Invalid link</a> <a>Invalid link</a>
</Link> </Link>
</> </>
...@@ -20,12 +21,13 @@ export default () => ( ...@@ -20,12 +21,13 @@ export default () => (
``` ```
**Compatible `href` and `as`** **Compatible `href` and `as`**
```jsx ```jsx
import Link from 'next/link' import Link from 'next/link'
export default () => ( export default () => (
<> <>
<Link href='/[post]' as='/post-1'> <Link href="/[post]" as="/post-1">
<a>Valid link</a> <a>Valid link</a>
</Link> </Link>
</> </>
......
...@@ -12,4 +12,3 @@ This severely degrades your application's performance at runtime. It can also re ...@@ -12,4 +12,3 @@ This severely degrades your application's performance at runtime. It can also re
Be sure your `next.config.js` has not modified `optimization.minimize` or `optimization.minimizer`. Be sure your `next.config.js` has not modified `optimization.minimize` or `optimization.minimizer`.
You can file an issue on our GitHub if you do not understand why minification is being disabled by your `next.config.js`. You can file an issue on our GitHub if you do not understand why minification is being disabled by your `next.config.js`.
...@@ -3,10 +3,7 @@ ...@@ -3,10 +3,7 @@
"target": "esnext", "target": "esnext",
"module": "esnext", "module": "esnext",
"jsx": "preserve", "jsx": "preserve",
"lib": [ "lib": ["dom", "es2017"],
"dom",
"es2017"
],
"baseUrl": ".", "baseUrl": ".",
"moduleResolution": "node", "moduleResolution": "node",
"strict": true, "strict": true,
...@@ -24,15 +21,6 @@ ...@@ -24,15 +21,6 @@
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"resolveJsonModule": true "resolveJsonModule": true
}, },
"exclude": [ "exclude": ["dist", ".next", "out", "next.config.js"],
"dist", "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
".next",
"out",
"next.config.js"
],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
]
} }
...@@ -30,16 +30,21 @@ cd with-aws-amplify-typescript ...@@ -30,16 +30,21 @@ cd with-aws-amplify-typescript
#### Install & Configure Amplify #### Install & Configure Amplify
1. [Sign up](https://portal.aws.amazon.com/billing/signup#/start) for an AWS account 1. [Sign up](https://portal.aws.amazon.com/billing/signup#/start) for an AWS account
2. Install the AWS Amplify cli: 2. Install the AWS Amplify cli:
```sh
```sh
npm install -g @aws-amplify/cli npm install -g @aws-amplify/cli
``` ```
3. Configure the Amplify cli
```sh 3. Configure the Amplify cli
```sh
amplify configure amplify configure
``` ```
[Read More](https://aws-amplify.github.io/docs/cli-toolchain/quickstart?sdk=js)
[Read More](https://aws-amplify.github.io/docs/cli-toolchain/quickstart?sdk=js)
</details> </details>
#### Initialize Amplify #### Initialize Amplify
...@@ -129,5 +134,3 @@ Two routes are implemented : ...@@ -129,5 +134,3 @@ Two routes are implemented :
- `/` : A static route that uses getInitialProps to load data from AppSync and renders it on the server (Code in [pages/index.tsx](/pages/index.tsx)) - `/` : A static route that uses getInitialProps to load data from AppSync and renders it on the server (Code in [pages/index.tsx](/pages/index.tsx))
- `/todo/[id]` : A dynamic route that uses getInitialProps and the id from the provided context to load a single todo from AppSync and render it on the server. (Code in [pages/todo/:[id].tsx](/pages/todo/[id].tsx)) - `/todo/[id]` : A dynamic route that uses getInitialProps and the id from the provided context to load a single todo from AppSync and render it on the server. (Code in [pages/todo/:[id].tsx](/pages/todo/[id].tsx))
{ {
"compilerOptions": { "compilerOptions": {
"target": "es5", "target": "es5",
"lib": [ "lib": ["dom", "dom.iterable", "esnext"],
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true, "allowJs": true,
"skipLibCheck": true, "skipLibCheck": true,
"strict": false, "strict": false,
...@@ -18,12 +14,6 @@ ...@@ -18,12 +14,6 @@
"isolatedModules": true, "isolatedModules": true,
"jsx": "preserve" "jsx": "preserve"
}, },
"exclude": [ "exclude": ["node_modules"],
"node_modules" "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
]
} }
...@@ -30,16 +30,21 @@ cd with-aws-amplify ...@@ -30,16 +30,21 @@ cd with-aws-amplify
#### Install & Configure Amplify #### Install & Configure Amplify
1. [Sign up](https://portal.aws.amazon.com/billing/signup#/start) for an AWS account 1. [Sign up](https://portal.aws.amazon.com/billing/signup#/start) for an AWS account
2. Install the AWS Amplify cli: 2. Install the AWS Amplify cli:
```sh
```sh
npm install -g @aws-amplify/cli npm install -g @aws-amplify/cli
``` ```
3. Configure the Amplify cli
```sh 3. Configure the Amplify cli
```sh
amplify configure amplify configure
``` ```
[Read More](https://aws-amplify.github.io/docs/cli-toolchain/quickstart?sdk=js)
[Read More](https://aws-amplify.github.io/docs/cli-toolchain/quickstart?sdk=js)
</details> </details>
#### Initialize Amplify #### Initialize Amplify
...@@ -142,5 +147,3 @@ Two routes are implemented : ...@@ -142,5 +147,3 @@ Two routes are implemented :
- `/` : A static route that uses getInitialProps to load data from AppSync and renders it on the server (Code in [pages/index.js](/pages/index.js)) - `/` : A static route that uses getInitialProps to load data from AppSync and renders it on the server (Code in [pages/index.js](/pages/index.js))
- `/todo/[id]` : A dynamic route that uses getInitialProps and the id from the provided context to load a single todo from AppSync and render it on the server. (Code in [pages/todo/:[id].js](/pages/todo/[id].js)) - `/todo/[id]` : A dynamic route that uses getInitialProps and the id from the provided context to load a single todo from AppSync and render it on the server. (Code in [pages/todo/:[id].js](/pages/todo/[id].js))
...@@ -24,6 +24,7 @@ cd with-electron-typescript ...@@ -24,6 +24,7 @@ cd with-electron-typescript
``` ```
To install and start dev build: To install and start dev build:
```bash ```bash
yarn install && yarn build && yarn start yarn install && yarn build && yarn start
``` ```
...@@ -43,8 +44,8 @@ Available commands: ...@@ -43,8 +44,8 @@ Available commands:
This example show how you can use Next.js inside an Electron application to avoid a lot of configuration, use Next.js router as view and use server-render to speed up the initial render of the application. Both Next.js and Electron layers are written in TypeScript and compiled to JavaScript during the build process. This example show how you can use Next.js inside an Electron application to avoid a lot of configuration, use Next.js router as view and use server-render to speed up the initial render of the application. Both Next.js and Electron layers are written in TypeScript and compiled to JavaScript during the build process.
| Part| Source code (Typescript) | Builds (JavaScript) | | Part | Source code (Typescript) | Builds (JavaScript) |
| -- | -- | -- | | ---------- | ------------------------ | ------------------- |
| Next.js | `/renderer` | `/renderer` | | Next.js | `/renderer` | `/renderer` |
| Electron | `/electron-src` | `/main` | | Electron | `/electron-src` | `/main` |
| Production | | `/dist` | | Production | | `/dist` |
...@@ -54,6 +55,7 @@ For development it's going to run a HTTP server and let Next.js handle routing. ...@@ -54,6 +55,7 @@ For development it's going to run a HTTP server and let Next.js handle routing.
You can create the production app using `npm run dist`. You can create the production app using `npm run dist`.
_note regarding types:_ _note regarding types:_
* Electron provides its own type definitions, so you don't need @types/electron installed!
source: https://www.npmjs.com/package/@types/electron - Electron provides its own type definitions, so you don't need @types/electron installed!
* There were no types available for `electron-next` at the time of creating this example, so until they are available there is a file `electron-next.d.ts` in `electron-src` directory. source: https://www.npmjs.com/package/@types/electron
- There were no types available for `electron-next` at the time of creating this example, so until they are available there is a file `electron-next.d.ts` in `electron-src` directory.
declare module "electron-next" { declare module 'electron-next' {
function adjustRenderer(directory: string): void
function adjustRenderer (directory: string): void; function devServer(dir: string, port?: number): void
function devServer (dir: string, port?: number): void;
interface Directories { interface Directories {
production: string, production: string
development: string development: string
} }
export default function(directories: Directories | string, port?: number): adjustRenderer | devServer; export default function(
directories: Directories | string,
port?: number
): adjustRenderer | devServer
} }
...@@ -16,8 +16,8 @@ app.on('ready', async () => { ...@@ -16,8 +16,8 @@ app.on('ready', async () => {
height: 600, height: 600,
webPreferences: { webPreferences: {
nodeIntegration: false, nodeIntegration: false,
preload: join(__dirname, 'preload.js') preload: join(__dirname, 'preload.js'),
} },
}) })
const url = isDev const url = isDev
...@@ -25,7 +25,7 @@ app.on('ready', async () => { ...@@ -25,7 +25,7 @@ app.on('ready', async () => {
: format({ : format({
pathname: join(__dirname, '../renderer/index.html'), pathname: join(__dirname, '../renderer/index.html'),
protocol: 'file:', protocol: 'file:',
slashes: true slashes: true,
}) })
mainWindow.loadURL(url) mainWindow.loadURL(url)
......
...@@ -3,7 +3,7 @@ import { ipcRenderer, IpcRenderer } from 'electron' ...@@ -3,7 +3,7 @@ import { ipcRenderer, IpcRenderer } from 'electron'
declare global { declare global {
namespace NodeJS { namespace NodeJS {
interface Global { interface Global {
ipcRenderer: IpcRenderer; ipcRenderer: IpcRenderer
} }
} }
} }
......
...@@ -6,10 +6,7 @@ ...@@ -6,10 +6,7 @@
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"isolatedModules": true, "isolatedModules": true,
"jsx": "preserve", "jsx": "preserve",
"lib": [ "lib": ["dom", "es2017"],
"dom",
"es2017"
],
"module": "commonjs", "module": "commonjs",
"moduleResolution": "node", "moduleResolution": "node",
"noEmit": false, "noEmit": false,
...@@ -20,14 +17,8 @@ ...@@ -20,14 +17,8 @@
"skipLibCheck": true, "skipLibCheck": true,
"strict": true, "strict": true,
"target": "esnext", "target": "esnext",
"outDir": "../main", "outDir": "../main"
}, },
"exclude": [ "exclude": ["node_modules"],
"node_modules" "include": ["**/*.ts", "**/*.tsx", "**/*.js"]
],
"include": [
"**/*.ts",
"**/*.tsx",
"**/*.js"
]
} }
...@@ -6,10 +6,7 @@ ...@@ -6,10 +6,7 @@
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"isolatedModules": true, "isolatedModules": true,
"jsx": "preserve", "jsx": "preserve",
"lib": [ "lib": ["dom", "es2017"],
"dom",
"es2017"
],
"module": "esnext", "module": "esnext",
"moduleResolution": "node", "moduleResolution": "node",
"noEmit": true, "noEmit": true,
...@@ -21,12 +18,6 @@ ...@@ -21,12 +18,6 @@
"strict": true, "strict": true,
"target": "esnext" "target": "esnext"
}, },
"exclude": [ "exclude": ["node_modules"],
"node_modules" "include": ["**/*.ts", "**/*.tsx", "**/*.js"]
],
"include": [
"**/*.ts",
"**/*.tsx",
"**/*.js"
]
} }
...@@ -16,23 +16,13 @@ ...@@ -16,23 +16,13 @@
"skipLibCheck": true, "skipLibCheck": true,
"sourceMap": true, "sourceMap": true,
"noEmit": true, "noEmit": true,
"lib": [ "lib": ["es6", "dom", "es2016"],
"es6",
"dom",
"es2016"
],
"baseUrl": ".", "baseUrl": ".",
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"esModuleInterop": true, "esModuleInterop": true,
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": true "isolatedModules": true
}, },
"exclude": [ "exclude": ["node_modules"],
"node_modules" "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
]
} }
{ {
"compilerOptions": { "compilerOptions": {
"lib": [ "lib": ["es6", "dom", "es2016"],
"es6",
"dom",
"es2016"
],
"module": "commonjs", "module": "commonjs",
"strict": true, "strict": true,
"outDir": "../../dist/functions", "outDir": "../../dist/functions",
......
...@@ -14,14 +14,8 @@ ...@@ -14,14 +14,8 @@
"sourceMap": true, "sourceMap": true,
"skipLibCheck": true, "skipLibCheck": true,
"baseUrl": ".", "baseUrl": ".",
"typeRoots": [ "typeRoots": ["./node_modules/@types"],
"./node_modules/@types" "lib": ["dom", "es2015", "es2016"],
],
"lib": [
"dom",
"es2015",
"es2016"
],
"strict": false, "strict": false,
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"noEmit": true, "noEmit": true,
...@@ -36,9 +30,5 @@ ...@@ -36,9 +30,5 @@
"**/*.test.ts", "**/*.test.ts",
"**/*.test.tsx" "**/*.test.tsx"
], ],
"include": [ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
]
} }
import { FormattedMessage, FormattedNumber, defineMessages, useIntl } from 'react-intl' import {
FormattedMessage,
FormattedNumber,
defineMessages,
useIntl
} from 'react-intl'
import Head from 'next/head' import Head from 'next/head'
import Layout from '../components/Layout' import Layout from '../components/Layout'
......
...@@ -27,7 +27,9 @@ const localeDataCache = new Map() ...@@ -27,7 +27,9 @@ const localeDataCache = new Map()
const getLocaleDataScript = locale => { const getLocaleDataScript = locale => {
const lang = locale.split('-')[0] const lang = locale.split('-')[0]
if (!localeDataCache.has(lang)) { if (!localeDataCache.has(lang)) {
const localeDataFile = require.resolve(`@formatjs/intl-relativetimeformat/dist/locale-data/${lang}`) const localeDataFile = require.resolve(
`@formatjs/intl-relativetimeformat/dist/locale-data/${lang}`
)
const localeDataScript = readFileSync(localeDataFile, 'utf8') const localeDataScript = readFileSync(localeDataFile, 'utf8')
localeDataCache.set(lang, localeDataScript) localeDataCache.set(lang, localeDataScript)
} }
......
...@@ -3,10 +3,7 @@ ...@@ -3,10 +3,7 @@
"target": "esnext", "target": "esnext",
"module": "esnext", "module": "esnext",
"jsx": "preserve", "jsx": "preserve",
"lib": [ "lib": ["dom", "es2017"],
"dom",
"es2017"
],
"moduleResolution": "node", "moduleResolution": "node",
"allowJs": true, "allowJs": true,
"noEmit": true, "noEmit": true,
...@@ -23,12 +20,6 @@ ...@@ -23,12 +20,6 @@
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": true "isolatedModules": true
}, },
"exclude": [ "exclude": ["node_modules"],
"node_modules" "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
]
} }
...@@ -6,10 +6,7 @@ ...@@ -6,10 +6,7 @@
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"isolatedModules": true, "isolatedModules": true,
"jsx": "preserve", "jsx": "preserve",
"lib": [ "lib": ["dom", "es2017"],
"dom",
"es2017"
],
"module": "esnext", "module": "esnext",
"moduleResolution": "node", "moduleResolution": "node",
"noEmit": true, "noEmit": true,
...@@ -21,11 +18,6 @@ ...@@ -21,11 +18,6 @@
"strict": true, "strict": true,
"target": "esnext" "target": "esnext"
}, },
"exclude": [ "exclude": ["node_modules"],
"node_modules" "include": ["**/*.ts", "**/*.tsx"]
],
"include": [
"**/*.ts",
"**/*.tsx"
]
} }
{ {
"version": 2, "version": 2,
"builds": [ "builds": [{ "src": "packages/web-app/package.json", "use": "@now/next" }],
{ "src": "packages/web-app/package.json", "use": "@now/next" } "routes": [{ "src": "(.*)", "dest": "packages/web-app$1", "continue": true }]
],
"routes": [
{ "src": "(.*)", "dest": "packages/web-app$1", "continue": true }
]
} }
...@@ -45,7 +45,7 @@ yarn dev ...@@ -45,7 +45,7 @@ yarn dev
- All pages should be unique across zones. For example, the 'home' app should not have a `pages/blog/index.js` page. - All pages should be unique across zones. For example, the 'home' app should not have a `pages/blog/index.js` page.
- The 'blog' app sets `assetPrefix` so that generated JS bundles are within the `/blog` subfolder. - The 'blog' app sets `assetPrefix` so that generated JS bundles are within the `/blog` subfolder.
- To also support the plain `next dev` scenario, `assetPrefix` is set dynamically based on the `BUILDING_FOR_NOW` environment variable, see [`now.json`](now.json) and [`blog/next.config.js`](blog/next.config.js). - To also support the plain `next dev` scenario, `assetPrefix` is set dynamically based on the `BUILDING_FOR_NOW` environment variable, see [`now.json`](now.json) and [`blog/next.config.js`](blog/next.config.js).
- Images and other `/static` assets have to be prefixed manually, e.g., ``<img src={`${process.env.ASSET_PREFIX}/static/image.png`} />``, see [`blog/pages/blog/index.js`](blog/pages/blog/index.js). - Images and other `/static` assets have to be prefixed manually, e.g., `` <img src={`${process.env.ASSET_PREFIX}/static/image.png`} /> ``, see [`blog/pages/blog/index.js`](blog/pages/blog/index.js).
## Production Deployment ## Production Deployment
......
{ {
"npmClient": "yarn", "npmClient": "yarn",
"useWorkspaces": true, "useWorkspaces": true,
"packages": [ "packages": ["packages/*"],
"packages/*"
],
"command": { "command": {
"version": { "version": {
"exact": true "exact": true
}, },
"publish": { "publish": {
"npmClient": "npm", "npmClient": "npm",
"allowBranch": [ "allowBranch": ["master", "canary"],
"master",
"canary"
],
"registry": "https://registry.npmjs.org/" "registry": "https://registry.npmjs.org/"
} }
}, },
......
...@@ -2164,8 +2164,8 @@ In some cases this indicator might not be as useful like when working on electro ...@@ -2164,8 +2164,8 @@ In some cases this indicator might not be as useful like when working on electro
```js ```js
module.exports = { module.exports = {
devIndicators: { devIndicators: {
autoPrerender: false autoPrerender: false,
} },
} }
``` ```
......
{ {
"compilerOptions": { "compilerOptions": {
"target": "es5", "target": "es5",
"lib": [ "lib": ["dom", "dom.iterable", "esnext"],
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true, "allowJs": true,
"skipLibCheck": true, "skipLibCheck": true,
"strict": false, "strict": false,
...@@ -18,12 +14,6 @@ ...@@ -18,12 +14,6 @@
"isolatedModules": true, "isolatedModules": true,
"jsx": "preserve" "jsx": "preserve"
}, },
"exclude": [ "exclude": ["node_modules"],
"node_modules" "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
]
} }
...@@ -4,11 +4,7 @@ ...@@ -4,11 +4,7 @@
"module": "esnext", "module": "esnext",
"jsx": "preserve", "jsx": "preserve",
"target": "es5", "target": "es5",
"lib": [ "lib": ["dom", "dom.iterable", "esnext"],
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true, "allowJs": true,
"skipLibCheck": true, "skipLibCheck": true,
"strict": false, "strict": false,
...@@ -18,12 +14,6 @@ ...@@ -18,12 +14,6 @@
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": true "isolatedModules": true
}, },
"exclude": [ "exclude": ["node_modules"],
"node_modules" "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
]
} }
{ {
"compilerOptions": { "compilerOptions": {
"target": "es5", "target": "es5",
"lib": [ "lib": ["dom", "dom.iterable", "esnext"],
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true, "allowJs": true,
"skipLibCheck": true, "skipLibCheck": true,
"strict": false, "strict": false,
...@@ -18,12 +14,6 @@ ...@@ -18,12 +14,6 @@
"isolatedModules": true, "isolatedModules": true,
"jsx": "preserve" "jsx": "preserve"
}, },
"exclude": [ "exclude": ["node_modules"],
"node_modules" "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
]
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment