Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message #41636

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion examples/with-apivideo/pages/videos/[videoId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const VideoView: NextPage<IVideoViewProps> = ({
.<br />
It provides multiple properties to customize your video player.
</p>
<p>Try 3 of them just bellow 👇</p>
<p>Try 3 of them just below 👇</p>
</div>

<div className="inputs-container">
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "12.3.2-canary.32"
"version": "12.3.2-canary.33"
}
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"@types/html-validator": "5.0.3",
"@types/http-proxy": "1.17.3",
"@types/jest": "24.0.13",
"@types/node": "13.11.0",
"@types/node": "14.14.31",
"@types/node-fetch": "2.6.1",
"@types/react": "16.9.17",
"@types/react-dom": "16.9.4",
Expand Down Expand Up @@ -178,8 +178,11 @@
"random-seed": "0.3.0",
"react": "18.2.0",
"react-17": "npm:react@17.0.2",
"react-builtin": "npm:react@0.0.0-experimental-9cdf8a99e-20221018",
"react-dom": "18.2.0",
"react-dom-17": "npm:react-dom@17.0.2",
"react-dom-builtin": "npm:react-dom@0.0.0-experimental-9cdf8a99e-20221018",
"react-server-dom-webpack": "0.0.0-experimental-9cdf8a99e-20221018",
"react-ssr-prepass": "1.0.8",
"react-virtualized": "9.22.3",
"relay-compiler": "13.0.2",
Expand All @@ -194,6 +197,7 @@
"shell-quote": "1.7.3",
"styled-components": "5.3.3",
"styled-jsx-plugin-postcss": "3.0.2",
"swr": "2.0.0-rc.0",
"tailwindcss": "1.1.3",
"taskr": "1.1.0",
"tree-kill": "1.2.2",
Expand Down
14 changes: 10 additions & 4 deletions packages/create-next-app/create-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,21 @@ export async function createApp({
example,
examplePath,
typescript,
experimentalApp,
}: {
appPath: string
packageManager: PackageManager
example?: string
examplePath?: string
typescript?: boolean
typescript: boolean
experimentalApp: boolean
}): Promise<void> {
let repoInfo: RepoInfo | undefined
const template = typescript ? 'typescript' : 'default'
const template = experimentalApp
? 'experimental-app'
: typescript
? 'typescript'
: 'default'

if (example) {
let repoUrl: URL | undefined
Expand Down Expand Up @@ -238,7 +244,7 @@ export async function createApp({
/**
* TypeScript projects will have type definitions and other devDependencies.
*/
if (typescript) {
if (template !== 'default') {
devDependencies.push(
'typescript',
'@types/react',
Expand Down Expand Up @@ -273,7 +279,7 @@ export async function createApp({
const devInstallFlags = { devDependencies: true, ...installFlags }
await install(root, devDependencies, devInstallFlags)
}
console.log()
console.log('\nInitializing project with template: ', template, '\n')
/**
* Copy the template files to the target directory.
*/
Expand Down
9 changes: 9 additions & 0 deletions packages/create-next-app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ const program = new Commander.Command(packageJson.name)
`

Initialize as a TypeScript project.
`
)
.option(
'--experimental-app',
`

Initialize as a \`app/\` directory project.
`
)
.option(
Expand Down Expand Up @@ -136,6 +143,7 @@ async function run(): Promise<void> {
example: example && example !== 'default' ? example : undefined,
examplePath: program.examplePath,
typescript: program.typescript,
experimentalApp: program.experimentalApp,
})
} catch (reason) {
if (!(reason instanceof DownloadError)) {
Expand All @@ -158,6 +166,7 @@ async function run(): Promise<void> {
appPath: resolvedProjectPath,
packageManager,
typescript: program.typescript,
experimentalApp: program.experimentalApp,
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/create-next-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-next-app",
"version": "12.3.2-canary.32",
"version": "12.3.2-canary.33",
"keywords": [
"react",
"next",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`.

The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
10 changes: 10 additions & 0 deletions packages/create-next-app/templates/experimental-app/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default function RootLayout({ children }) {
return (
<html lang="en">
<head>
<title>Create Next App</title>
</head>
<body>{children}</body>
</html>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function Page() {
return (
<h1>
Welcome to <a href="https://nextjs.org">Next.js!</a>
</h1>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
36 changes: 36 additions & 0 deletions packages/create-next-app/templates/experimental-app/gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
appDir: true,
},
}

module.exports = nextConfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import type { NextApiRequest, NextApiResponse } from 'next'

type Data = {
name: string
}

export default function handler(
req: NextApiRequest,
res: NextApiResponse<Data>
) {
res.status(200).json({ name: 'John Doe' })
}
25 changes: 25 additions & 0 deletions packages/create-next-app/templates/experimental-app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
]
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
4 changes: 1 addition & 3 deletions packages/create-next-app/templates/typescript/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import '../styles/globals.css'
import type { AppProps } from 'next/app'

function MyApp({ Component, pageProps }: AppProps) {
export default function App({ Component, pageProps }: AppProps) {
return <Component {...pageProps} />
}

export default MyApp
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import type { NextPage } from 'next'
import Head from 'next/head'
import Image from 'next/image'
import styles from '../styles/Home.module.css'

const Home: NextPage = () => {
export default function Home() {
return (
<div className={styles.container}>
<Head>
Expand Down Expand Up @@ -70,5 +69,3 @@ const Home: NextPage = () => {
</div>
)
}

export default Home
4 changes: 2 additions & 2 deletions packages/eslint-config-next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-config-next",
"version": "12.3.2-canary.32",
"version": "12.3.2-canary.33",
"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.3.2-canary.32",
"@next/eslint-plugin-next": "12.3.2-canary.33",
"@rushstack/eslint-patch": "^1.1.3",
"@typescript-eslint/parser": "^5.21.0",
"eslint-import-resolver-node": "^0.3.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/eslint-plugin-next",
"version": "12.3.2-canary.32",
"version": "12.3.2-canary.33",
"description": "ESLint plugin for NextJS.",
"main": "dist/index.js",
"license": "MIT",
Expand Down
8 changes: 7 additions & 1 deletion packages/font/google/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
throw new Error('@next/font/google is not correctly configured')
let message = '@next/font/google failed to run or is incorrectly configured.'
if (process.env.NODE_ENV === 'development') {
message +=
'\nIf you just installed `@next/font`, please try restarting `next dev` and resaving your file.'
}

throw new Error(message)
8 changes: 7 additions & 1 deletion packages/font/local/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
throw new Error('@next/font/local is not correctly configured')
let message = '@next/font/local failed to run or is incorrectly configured.'
if (process.env.NODE_ENV === 'development') {
message +=
'\nIf you just installed `@next/font`, please try restarting `next dev` and resaving your file.'
}

throw new Error(message)
2 changes: 1 addition & 1 deletion packages/font/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/font",
"version": "12.3.2-canary.32",
"version": "12.3.2-canary.33",
"repository": {
"url": "vercel/next.js",
"directory": "packages/font"
Expand Down
17 changes: 13 additions & 4 deletions packages/font/src/google/loader.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import type { AdjustFontFallback, FontLoader } from 'next/font'
// @ts-ignore
import { calculateSizeAdjustValues } from 'next/dist/server/font-utils'
// @ts-ignore
import * as Log from 'next/dist/build/output/log'
// @ts-ignore
import chalk from 'next/dist/compiled/chalk'
import {
fetchCSSFromGoogleFonts,
fetchFontFile,
Expand All @@ -19,10 +23,15 @@ const downloadGoogleFonts: FontLoader = async ({
emitFontFile,
}) => {
if (!config?.subsets) {
throw new Error(
'Please specify subsets for `@next/font/google` in your `next.config.js`'
Log.warn(
`${chalk.bold('@next/font/google')} is missing ${chalk.bold(
'options.subsets'
)} in your ${chalk.bold(
'next.config.js'
)}. Please specify subsets, otherwise no fonts will be preloaded.`
)
}
const subsets = config?.subsets || []

const {
fontFamily,
Expand Down Expand Up @@ -63,7 +72,7 @@ const downloadGoogleFonts: FontLoader = async ({
if (googleFontFileUrl) {
fontFiles.push({
googleFontFileUrl,
preloadFontFile: !!preload && config.subsets.includes(currentSubset),
preloadFontFile: !!preload && subsets.includes(currentSubset),
})
}
}
Expand Down Expand Up @@ -121,7 +130,7 @@ const downloadGoogleFonts: FontLoader = async ({
sizeAdjust: `${sizeAdjust}%`,
}
} catch {
console.error(
Log.error(
`Failed to find font override values for font \`${fontFamily}\``
)
}
Expand Down
Loading