Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/canary' into conflicting-ssg-e…
Browse files Browse the repository at this point in the history
…rror

# Conflicts:
#	packages/next/build/index.ts
#	packages/next/build/utils.ts
  • Loading branch information
ijjk committed Jan 11, 2021
2 parents 999a815 + 16ff439 commit 38a5fb9
Show file tree
Hide file tree
Showing 76 changed files with 2,570 additions and 2,590 deletions.
30 changes: 27 additions & 3 deletions bench/instrument.js
@@ -1,11 +1,35 @@
// Disable automatic instrumentation
process.env.OTEL_NO_PATCH_MODULES = '*'

const { NodeTracerProvider } = require('@opentelemetry/node')
const { BatchSpanProcessor } = require('@opentelemetry/tracing')
const { SimpleSpanProcessor } = require('@opentelemetry/tracing')
const { ZipkinExporter } = require('@opentelemetry/exporter-zipkin')

const tracerProvider = new NodeTracerProvider()
const tracerProvider = new NodeTracerProvider({
// All automatic instrumentation plugins have to be disabled as it affects worker_thread/child_process bootup performance
plugins: {
mongodb: { enabled: false, path: '@opentelemetry/plugin-mongodb' },
grpc: { enabled: false, path: '@opentelemetry/plugin-grpc' },
'@grpc/grpc-js': { enabled: false, path: '@opentelemetry/plugin-grpc-js' },
http: { enabled: false, path: '@opentelemetry/plugin-http' },
https: { enabled: false, path: '@opentelemetry/plugin-https' },
mysql: { enabled: false, path: '@opentelemetry/plugin-mysql' },
pg: { enabled: false, path: '@opentelemetry/plugin-pg' },
redis: { enabled: false, path: '@opentelemetry/plugin-redis' },
ioredis: { enabled: false, path: '@opentelemetry/plugin-ioredis' },
'pg-pool': { enabled: false, path: '@opentelemetry/plugin-pg-pool' },
express: { enabled: false, path: '@opentelemetry/plugin-express' },
'@hapi/hapi': {
enabled: false,
path: '@opentelemetry/hapi-instrumentation',
},
koa: { enabled: false, path: '@opentelemetry/koa-instrumentation' },
dns: { enabled: false, path: '@opentelemetry/plugin-dns' },
},
})

tracerProvider.addSpanProcessor(
new BatchSpanProcessor(
new SimpleSpanProcessor(
new ZipkinExporter({
serviceName: 'next-js',
})
Expand Down
5 changes: 5 additions & 0 deletions docs/basic-features/environment-variables.md
Expand Up @@ -46,6 +46,11 @@ export async function getStaticProps() {
}
```

> **Note**: In order to keep server-only secrets safe, Next.js replaces `process.env.*` with the correct values
> at build time. This means that `process.env` is not a standard JavaScript object, so you’re not able to
> use [object destructuring](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment).
> Environment variables must be referenced as e.g. `process.env.NEXT_PUBLIC_PUBLISHABLE_KEY`, _not_ `const { NEXT_PUBLIC_PUBLISHABLE_KEY } = process.env`.
> **Note**: Next.js will automatically expand variables (`$VAR`) inside of your `.env*` files.
> This allows you to reference other secrets, like so:
>
Expand Down
15 changes: 15 additions & 0 deletions errors/can-not-output-to-static.md
@@ -0,0 +1,15 @@
# Cannot output to /static

#### Why This Error Occurred

Either you set `distDir` to `static` in your `next.config.js` or during `next export` you tried to export to the `static` directory.

This is not allowed due to `static` being a special folder in Next.js used to serve static assets.

#### Possible Ways to Fix It

Use a different `distDir` or export to a different folder.

### Useful Links

- [Static file serving docs](https://nextjs.org/docs/basic-features/static-file-serving)
2 changes: 2 additions & 0 deletions examples/blog-starter-typescript/package.json
Expand Up @@ -24,6 +24,8 @@
"@types/node": "^14.0.1",
"@types/react": "^16.9.35",
"@types/react-dom": "^16.9.8",
"autoprefixer": "^10.2.1",
"postcss": "^8.2.4",
"postcss-preset-env": "^6.7.0",
"tailwindcss": "^2.0.2"
},
Expand Down
6 changes: 3 additions & 3 deletions examples/blog-starter/package.json
Expand Up @@ -17,10 +17,10 @@
"remark-html": "13.0.1"
},
"devDependencies": {
"autoprefixer": "10.0.4",
"postcss": "8.1.10",
"autoprefixer": "^10.2.1",
"postcss": "^8.2.4",
"postcss-preset-env": "^6.7.0",
"tailwindcss": "2.0.1"
"tailwindcss": "^2.0.2"
},
"license": "MIT"
}
11 changes: 10 additions & 1 deletion examples/cms-graphcms/components/avatar.js
@@ -1,7 +1,16 @@
import Image from 'next/image'

export default function Avatar({ name, picture }) {
return (
<div className="flex items-center">
<img src={picture} className="w-12 h-12 rounded-full mr-4" alt={name} />
<div className="w-12 h-12 relative mr-4">
<Image
src={picture}
layout="fill"
className="rounded-full"
alt={name}
/>
</div>
<div className="text-xl font-bold">{name}</div>
</div>
)
Expand Down
5 changes: 3 additions & 2 deletions examples/cms-graphcms/components/cover-image.js
@@ -1,9 +1,10 @@
import cn from 'classnames'
import Image from 'next/image'
import Link from 'next/link'
import cn from 'classnames'

export default function CoverImage({ title, url, slug }) {
const image = (
<img
<Image
width={2000}
height={1000}
alt={`Cover Image for ${title}`}
Expand Down
2 changes: 1 addition & 1 deletion examples/cms-graphcms/components/more-stories.js
Expand Up @@ -6,7 +6,7 @@ export default function MoreStories({ posts }) {
<h2 className="mb-8 text-6xl md:text-7xl font-bold tracking-tighter leading-tight">
More Stories
</h2>
<div className="grid grid-cols-1 md:grid-cols-2 md:col-gap-16 lg:col-gap-32 row-gap-20 md:row-gap-32 mb-32">
<div className="grid grid-cols-1 md:grid-cols-2 md:gap-x-16 lg:gap-x-32 gap-y-20 md:gap-y-32 mb-32">
{posts.map((post) => (
<PostPreview
key={post.slug}
Expand Down
5 changes: 5 additions & 0 deletions examples/cms-graphcms/next.config.js
@@ -0,0 +1,5 @@
module.exports = {
images: {
domains: ['media.graphcms.com'],
},
}
10 changes: 6 additions & 4 deletions examples/cms-graphcms/package.json
Expand Up @@ -7,16 +7,18 @@
"start": "next start"
},
"dependencies": {
"autoprefixer": "10.1.0",
"classnames": "2.2.6",
"date-fns": "2.10.0",
"next": "latest",
"react": "^16.13.0",
"react-dom": "^16.13.0"
"postcss": "8.2.2",
"react": "17.0.1",
"react-dom": "17.0.1"
},
"devDependencies": {
"postcss-flexbugs-fixes": "^4.2.1",
"postcss-flexbugs-fixes": "^5.0.2",
"postcss-preset-env": "^6.7.0",
"tailwindcss": "^1.4.6"
"tailwindcss": "2.0.2"
},
"license": "MIT"
}
2 changes: 0 additions & 2 deletions examples/with-electron-typescript/README.md
Expand Up @@ -10,8 +10,6 @@ This example show how you can use Next.js inside an Electron application to avoi

For development it's going to run a HTTP server and let Next.js handle routing. In production it use `next export` to pre-generate HTML static files and use them in your app instead of running an HTTP server.

**You can find a detailed documentation about how to build Electron apps with Next.js [here](https://leo.im/2017/electron-next)!**

## How to use

Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init) or [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) to bootstrap the example:
Expand Down
6 changes: 0 additions & 6 deletions examples/with-firebase-cloud-messaging/next.config.js

This file was deleted.

10 changes: 3 additions & 7 deletions examples/with-firebase-cloud-messaging/package.json
Expand Up @@ -2,21 +2,17 @@
"name": "with-firebase-cloud-messaging",
"version": "1.0.0",
"scripts": {
"dev": "node server.js",
"dev": "next dev",
"build": "next build",
"start": "cross-env NODE_ENV=production node server.js"
"start": "next start"
},
"dependencies": {
"cross-env": "^7.0.2",
"express": "^4.14.0",
"firebase": "^7.6.2",
"localforage": "^1.7.3",
"next": "latest",
"react": "^16.7.0",
"react-dom": "^16.7.0"
},
"devDependencies": {
"next-offline": "^3.0.10"
},
"devDependencies": {},
"license": "MIT"
}
41 changes: 0 additions & 41 deletions examples/with-firebase-cloud-messaging/server.js

This file was deleted.

43 changes: 1 addition & 42 deletions examples/with-graphql-hooks/components/app.js
@@ -1,44 +1,3 @@
export default function App({ children }) {
return (
<main>
{children}
<style jsx global>{`
* {
font-family: Menlo, Monaco, 'Lucida Console', 'Liberation Mono',
'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New',
monospace, serif;
}
body {
margin: 0;
padding: 25px 50px;
}
a {
color: #22bad9;
}
p {
font-size: 14px;
line-height: 24px;
}
article {
margin: 0 auto;
max-width: 650px;
}
button {
align-items: center;
background-color: #22bad9;
border: 0;
color: white;
display: flex;
padding: 5px 7px;
}
button:active {
background-color: #1b9db7;
transition: background-color 0.3s;
}
button:focus {
outline: none;
}
`}</style>
</main>
)
return <main>{children}</main>
}
48 changes: 5 additions & 43 deletions examples/with-graphql-hooks/components/post-list.js
Expand Up @@ -4,9 +4,9 @@ import ErrorMessage from './error-message'
import PostUpvoter from './post-upvoter'
import Submit from './submit'

export const allPostsQuery = `
export const ALL_POSTS_QUERY = `
query allPosts($first: Int!, $skip: Int!) {
allPosts(orderBy: createdAt_DESC, first: $first, skip: $skip) {
allPosts(orderBy: { createdAt: desc }, first: $first, skip: $skip) {
id
title
votes
Expand All @@ -32,16 +32,16 @@ export const allPostsQueryOptions = (skip = 0) => ({
export default function PostList() {
const [skip, setSkip] = useState(0)
const { loading, error, data, refetch } = useQuery(
allPostsQuery,
ALL_POSTS_QUERY,
allPostsQueryOptions(skip)
)

if (error) return <ErrorMessage message="Error loading posts." />
if (!data) return <div>Loading</div>

const { allPosts, _allPostsMeta } = data

const areMorePosts = allPosts.length < _allPostsMeta.count

return (
<>
<Submit
Expand All @@ -68,51 +68,13 @@ export default function PostList() {
))}
</ul>
{areMorePosts ? (
<button onClick={() => setSkip(skip + 10)}>
<button className="more" onClick={() => setSkip(skip + 10)}>
{' '}
{loading && !data ? 'Loading...' : 'Show More'}{' '}
</button>
) : (
''
)}
<style jsx>{`
section {
padding-bottom: 20px;
}
li {
display: block;
margin-bottom: 10px;
}
div {
align-items: center;
display: flex;
}
a {
font-size: 14px;
margin-right: 10px;
text-decoration: none;
padding-bottom: 0;
border: 0;
}
span {
font-size: 14px;
margin-right: 5px;
}
ul {
margin: 0;
padding: 0;
}
button:before {
align-self: center;
border-style: solid;
border-width: 6px 4px 0 4px;
border-color: #ffffff transparent transparent transparent;
content: '';
height: 0;
margin-right: 5px;
width: 0;
}
`}</style>
</section>
</>
)
Expand Down

0 comments on commit 38a5fb9

Please sign in to comment.