Skip to content

Commit c7dd294

Browse files
authored
Merge branch 'canary' into async-module-wrap
2 parents e619944 + 1b61d1f commit c7dd294

File tree

21 files changed

+339
-84
lines changed

21 files changed

+339
-84
lines changed

.github/actions/next-stats-action/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:14-buster
1+
FROM node:16-bullseye
22

33
LABEL com.github.actions.name="Next.js PR Stats"
44
LABEL com.github.actions.description="Compares stats of a PR with the main branch"

.github/actions/next-stats-action/src/run/index.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,15 @@ async function runConfigs(
5858
}
5959

6060
const buildStart = Date.now()
61-
await exec(`cd ${statsAppDir} && ${statsConfig.appBuildCommand}`, false, {
62-
env: yarnEnvValues,
63-
})
61+
console.log(
62+
await exec(
63+
`cd ${statsAppDir} && ${statsConfig.appBuildCommand}`,
64+
false,
65+
{
66+
env: yarnEnvValues,
67+
}
68+
)
69+
)
6470
curStats.General.buildDuration = Date.now() - buildStart
6571

6672
// apply renames to get deterministic output names
@@ -153,9 +159,15 @@ async function runConfigs(
153159
}
154160

155161
const secondBuildStart = Date.now()
156-
await exec(`cd ${statsAppDir} && ${statsConfig.appBuildCommand}`, false, {
157-
env: yarnEnvValues,
158-
})
162+
console.log(
163+
await exec(
164+
`cd ${statsAppDir} && ${statsConfig.appBuildCommand}`,
165+
false,
166+
{
167+
env: yarnEnvValues,
168+
}
169+
)
170+
)
159171
curStats.General.buildDurationCached = Date.now() - secondBuildStart
160172

161173
if (statsConfig.appDevCommand) {

docs/advanced-features/middleware.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ export const config = {
5050
}
5151
```
5252

53+
> **Note** the `pageExtensions` config affects middleware as well, [see related documentation here](/docs/api-reference/next.config.js/custom-page-extensions.md).
54+
5355
## Matching Paths
5456

5557
Middleware will be invoked for **every route in your project**. The following is the execution order:

docs/basic-features/script.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ Scripts that use the `afterInteractive` strategy are injected client-side and wi
113113

114114
```jsx
115115
<Script
116+
id="google-analytics"
116117
strategy="afterInteractive"
117118
dangerouslySetInnerHTML={{
118119
__html: `

examples/with-supabase-auth-realtime-db/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ The Vercel deployment will guide you through creating a Supabase account and pro
88

99
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-supabase-auth-realtime-db&project-name=nextjs-with-supabase-auth&repository-name=nextjs-with-supabase-auth&integration-ids=oac_jUduyjQgOyzev1fjrW83NYOv)
1010

11+
## Running Locally
12+
13+
1. `cd` into this directory
14+
1. Run `npm install` to install dependencies
15+
1. Create a Supabase account and new project
16+
1. Copy `.env.local.example` into `.env.local` and add the project keys
17+
1. Run `npm run dev` to start the local development server
18+
1119
## Feedback and issues
1220

1321
Please file feedback and issues over on the [Supabase GitHub org](https://github.com/supabase/supabase/issues/new/choose).

packages/next/build/webpack-config.ts

Lines changed: 68 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,61 +1577,74 @@ export default async function getBaseWebpackConfig(
15771577
},
15781578
{
15791579
resolve: {
1580-
// Full list of old polyfills is accessible here:
1581-
// https://github.com/webpack/webpack/blob/2a0536cf510768111a3a6dceeb14cb79b9f59273/lib/ModuleNotFoundError.js#L13-L42
1582-
fallback: {
1583-
assert: require.resolve('next/dist/compiled/assert'),
1584-
buffer: require.resolve('next/dist/compiled/buffer/'),
1585-
constants: require.resolve(
1586-
'next/dist/compiled/constants-browserify'
1587-
),
1588-
crypto: require.resolve(
1589-
'next/dist/compiled/crypto-browserify'
1590-
),
1591-
domain: require.resolve(
1592-
'next/dist/compiled/domain-browser'
1593-
),
1594-
http: require.resolve('next/dist/compiled/stream-http'),
1595-
https: require.resolve(
1596-
'next/dist/compiled/https-browserify'
1597-
),
1598-
os: require.resolve('next/dist/compiled/os-browserify'),
1599-
path: require.resolve(
1600-
'next/dist/compiled/path-browserify'
1601-
),
1602-
punycode: require.resolve(
1603-
'next/dist/compiled/punycode'
1604-
),
1605-
process: require.resolve('./polyfills/process'),
1606-
// Handled in separate alias
1607-
querystring: require.resolve(
1608-
'next/dist/compiled/querystring-es3'
1609-
),
1610-
stream: require.resolve(
1611-
'next/dist/compiled/stream-browserify'
1612-
),
1613-
string_decoder: require.resolve(
1614-
'next/dist/compiled/string_decoder'
1615-
),
1616-
sys: require.resolve('next/dist/compiled/util/'),
1617-
timers: require.resolve(
1618-
'next/dist/compiled/timers-browserify'
1619-
),
1620-
tty: require.resolve(
1621-
'next/dist/compiled/tty-browserify'
1622-
),
1623-
// Handled in separate alias
1624-
// url: require.resolve('url/'),
1625-
util: require.resolve('next/dist/compiled/util/'),
1626-
vm: require.resolve('next/dist/compiled/vm-browserify'),
1627-
zlib: require.resolve(
1628-
'next/dist/compiled/browserify-zlib'
1629-
),
1630-
events: require.resolve('next/dist/compiled/events/'),
1631-
setImmediate: require.resolve(
1632-
'next/dist/compiled/setimmediate'
1633-
),
1634-
},
1580+
fallback:
1581+
config.experimental.fallbackNodePolyfills === false
1582+
? {}
1583+
: {
1584+
assert: require.resolve(
1585+
'next/dist/compiled/assert'
1586+
),
1587+
buffer: require.resolve(
1588+
'next/dist/compiled/buffer/'
1589+
),
1590+
constants: require.resolve(
1591+
'next/dist/compiled/constants-browserify'
1592+
),
1593+
crypto: require.resolve(
1594+
'next/dist/compiled/crypto-browserify'
1595+
),
1596+
domain: require.resolve(
1597+
'next/dist/compiled/domain-browser'
1598+
),
1599+
http: require.resolve(
1600+
'next/dist/compiled/stream-http'
1601+
),
1602+
https: require.resolve(
1603+
'next/dist/compiled/https-browserify'
1604+
),
1605+
os: require.resolve(
1606+
'next/dist/compiled/os-browserify'
1607+
),
1608+
path: require.resolve(
1609+
'next/dist/compiled/path-browserify'
1610+
),
1611+
punycode: require.resolve(
1612+
'next/dist/compiled/punycode'
1613+
),
1614+
process: require.resolve('./polyfills/process'),
1615+
// Handled in separate alias
1616+
querystring: require.resolve(
1617+
'next/dist/compiled/querystring-es3'
1618+
),
1619+
stream: require.resolve(
1620+
'next/dist/compiled/stream-browserify'
1621+
),
1622+
string_decoder: require.resolve(
1623+
'next/dist/compiled/string_decoder'
1624+
),
1625+
sys: require.resolve('next/dist/compiled/util/'),
1626+
timers: require.resolve(
1627+
'next/dist/compiled/timers-browserify'
1628+
),
1629+
tty: require.resolve(
1630+
'next/dist/compiled/tty-browserify'
1631+
),
1632+
// Handled in separate alias
1633+
// url: require.resolve('url/'),
1634+
util: require.resolve('next/dist/compiled/util/'),
1635+
vm: require.resolve(
1636+
'next/dist/compiled/vm-browserify'
1637+
),
1638+
zlib: require.resolve(
1639+
'next/dist/compiled/browserify-zlib'
1640+
),
1641+
events: require.resolve(
1642+
'next/dist/compiled/events/'
1643+
),
1644+
setImmediate: require.resolve(
1645+
'next/dist/compiled/setimmediate'
1646+
),
1647+
},
16351648
},
16361649
},
16371650
],

packages/next/client/script.tsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ const loadScript = (props: ScriptProps): void => {
6161

6262
const loadPromise = new Promise<void>((resolve, reject) => {
6363
el.addEventListener('load', function (e) {
64+
// add cacheKey to LoadCache when load successfully
65+
LoadCache.add(cacheKey)
66+
6467
resolve()
6568
if (onLoad) {
6669
onLoad.call(this, e)
@@ -79,22 +82,27 @@ const loadScript = (props: ScriptProps): void => {
7982
}
8083
})
8184

82-
if (src) {
83-
ScriptCache.set(src, loadPromise)
84-
}
85-
LoadCache.add(cacheKey)
86-
8785
if (dangerouslySetInnerHTML) {
8886
el.innerHTML = dangerouslySetInnerHTML.__html || ''
87+
88+
// add cacheKey to LoadCache for inline script
89+
LoadCache.add(cacheKey)
8990
} else if (children) {
9091
el.textContent =
9192
typeof children === 'string'
9293
? children
9394
: Array.isArray(children)
9495
? children.join('')
9596
: ''
97+
98+
// add cacheKey to LoadCache for inline script
99+
LoadCache.add(cacheKey)
96100
} else if (src) {
97101
el.src = src
102+
// do not add cacheKey into LoadCache for remote script here
103+
// cacheKey will be added to LoadCache when it is actually loaded (see loadPromise above)
104+
105+
ScriptCache.set(src, loadPromise)
98106
}
99107

100108
for (const [k, value] of Object.entries(props)) {
@@ -207,4 +215,6 @@ function Script(props: ScriptProps): JSX.Element | null {
207215
return null
208216
}
209217

218+
Object.defineProperty(Script, '__nextScript', { value: true })
219+
210220
export default Script

packages/next/lib/typescript/writeConfigurationDefaults.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,6 @@ export function getRequiredConfiguration(
9090
const desiredCompilerOptions = getDesiredCompilerOptions(ts)
9191
for (const optionKey of Object.keys(desiredCompilerOptions)) {
9292
const ev = desiredCompilerOptions[optionKey]
93-
if (optionKey === 'moduleResolution') {
94-
console.log({ optionKey, ev, current: res[optionKey] })
95-
}
9693
if (!('value' in ev)) {
9794
continue
9895
}

packages/next/pages/_document.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import type {
1010
DocumentType,
1111
NEXT_DATA,
1212
} from '../shared/lib/utils'
13+
import type { ScriptProps } from '../client/script'
14+
1315
import { BuildManifest, getPageFiles } from '../server/get-page-files'
14-
import { cleanAmpPath } from '../server/utils'
1516
import { htmlEscapeJsonString } from '../server/htmlescape'
16-
import Script, { ScriptProps } from '../client/script'
1717
import isError from '../lib/is-error'
1818

1919
import { HtmlContext } from '../shared/lib/html-context'
@@ -765,7 +765,10 @@ export class Head extends Component<HeadProps> {
765765
{!hasCanonicalRel && (
766766
<link
767767
rel="canonical"
768-
href={canonicalBase + cleanAmpPath(dangerousAsPath)}
768+
href={
769+
canonicalBase +
770+
require('../server/utils').cleanAmpPath(dangerousAsPath)
771+
}
769772
/>
770773
)}
771774
{/* https://www.ampproject.org/docs/fundamentals/optimize_amp#optimize-the-amp-runtime-loading */}
@@ -871,7 +874,8 @@ function handleDocumentScriptLoaderItems(
871874
React.Children.forEach(combinedChildren, (child: any) => {
872875
if (!child) return
873876

874-
if (child.type === Script) {
877+
// When using the `next/script` component, register it in script loader.
878+
if (child.type?.__nextScript) {
875879
if (child.props.strategy === 'beforeInteractive') {
876880
scriptLoader.beforeInteractive = (
877881
scriptLoader.beforeInteractive || []

packages/next/server/config-schema.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,9 @@ const configSchema = {
258258
externalDir: {
259259
type: 'boolean',
260260
},
261+
fallbackNodePolyfills: {
262+
type: 'boolean',
263+
},
261264
forceSwcTransforms: {
262265
type: 'boolean',
263266
},

0 commit comments

Comments
 (0)