Skip to content

Commit dc92d11

Browse files
committed
Merge remote-tracking branch 'upstream/canary' into ssg/return-404
2 parents 5866f1b + 71d798c commit dc92d11

File tree

5 files changed

+66
-13
lines changed

5 files changed

+66
-13
lines changed

.github/workflows/build_test_deploy.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,13 @@ jobs:
107107
steps:
108108
- uses: actions/checkout@v2
109109
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
110-
- run: cat package.json | jq '.resolutions.webpack = "^5.0.0-beta.30"' > package.json.tmp && mv package.json.tmp package.json
111-
- run: cat package.json | jq '.resolutions.react = "^17.0.0-rc.1"' > package.json.tmp && mv package.json.tmp package.json
112-
- run: cat package.json | jq '.resolutions."react-dom" = "^17.0.0-rc.1"' > package.json.tmp && mv package.json.tmp package.json
110+
- run: cat packages/next/package.json | jq '.resolutions.webpack = "^5.0.0-beta.30"' > package.json.tmp && mv package.json.tmp packages/next/package.json
111+
- run: cat packages/next/package.json | jq '.resolutions.react = "^17.0.0-rc.1"' > package.json.tmp && mv package.json.tmp packages/next/package.json
112+
- run: cat packages/next/package.json | jq '.resolutions."react-dom" = "^17.0.0-rc.1"' > package.json.tmp && mv package.json.tmp packages/next/package.json
113113
- run: yarn install --check-files
114114
- run: node run-tests.js test/integration/production/test/index.test.js
115115
- run: node run-tests.js test/integration/basic/test/index.test.js
116+
- run: node run-tests.js test/integration/font-optimization/test/index.test.js
116117
- run: node run-tests.js test/acceptance/*
117118

118119
testFirefox:

examples/with-tailwindcss/tailwind.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module.exports = {
22
future: {
33
removeDeprecatedGapUtilities: true,
4+
purgeLayersByDefault: true,
45
},
56
purge: ['./components/**/*.{js,ts,jsx,tsx}', './pages/**/*.{js,ts,jsx,tsx}'],
67
theme: {

packages/next/build/webpack/plugins/font-stylesheet-gathering-plugin.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import {
55
getFontDefinitionFromNetwork,
66
FontManifest,
77
} from '../../../next-server/server/font-utils'
8-
// @ts-ignore
9-
import BasicEvaluatedExpression from 'webpack/lib/BasicEvaluatedExpression'
108
import postcss from 'postcss'
119
import minifier from 'cssnano-simple'
1210
import { OPTIMIZED_FONT_PROVIDERS } from '../../../next-server/lib/constants'
@@ -16,6 +14,13 @@ const { RawSource } = webpack.sources || sources
1614

1715
const isWebpack5 = parseInt(webpack.version!) === 5
1816

17+
let BasicEvaluatedExpression: any
18+
if (isWebpack5) {
19+
BasicEvaluatedExpression = require('webpack/lib/javascript/BasicEvaluatedExpression')
20+
} else {
21+
BasicEvaluatedExpression = require('webpack/lib/BasicEvaluatedExpression')
22+
}
23+
1924
async function minifyCss(css: string): Promise<string> {
2025
return new Promise((resolve) =>
2126
postcss([
@@ -62,13 +67,20 @@ export class FontStylesheetGatheringPlugin {
6267
if (parser?.state?.module?.resource.includes('node_modules')) {
6368
return
6469
}
65-
return node.name === '__jsx'
66-
? new BasicEvaluatedExpression()
67-
//@ts-ignore
68-
.setRange(node.range)
69-
.setExpression(node)
70-
.setIdentifier('__jsx')
71-
: undefined
70+
let result
71+
if (node.name === '__jsx') {
72+
result = new BasicEvaluatedExpression()
73+
// @ts-ignore
74+
result.setRange(node.range)
75+
result.setExpression(node)
76+
result.setIdentifier('__jsx')
77+
78+
// This was added webpack 5.
79+
if (isWebpack5) {
80+
result.getMembers = () => []
81+
}
82+
}
83+
return result
7284
})
7385

7486
parser.hooks.call

packages/next/client/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ if (process.env.__NEXT_i18n_SUPPORT) {
9292
const localePathResult = normalizeLocalePath(asPath, locales)
9393

9494
if (localePathResult.detectedLocale) {
95-
asPath = asPath.substr(localePathResult.detectedLocale.length + 1)
95+
asPath = asPath.substr(localePathResult.detectedLocale.length + 1) || '/'
9696
} else {
9797
// derive the default locale if it wasn't detected in the asPath
9898
// since we don't prerender static pages with all possible default

test/integration/i18n-support/test/index.test.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,45 @@ let buildPagesDir
2929
const locales = ['en-US', 'nl-NL', 'nl-BE', 'nl', 'fr-BE', 'fr', 'en']
3030

3131
function runTests(isDev) {
32+
it('should update asPath on the client correctly', async () => {
33+
for (const check of ['en', 'En']) {
34+
const browser = await webdriver(appPort, `/${check}`)
35+
36+
expect(await browser.elementByCss('html').getAttribute('lang')).toBe('en')
37+
expect(await browser.elementByCss('#router-locale').text()).toBe('en')
38+
expect(
39+
JSON.parse(await browser.elementByCss('#router-locales').text())
40+
).toEqual(locales)
41+
expect(await browser.elementByCss('#router-as-path').text()).toBe('/')
42+
expect(await browser.elementByCss('#router-pathname').text()).toBe('/')
43+
}
44+
})
45+
46+
if (!isDev) {
47+
it('should handle fallback correctly after generating', async () => {
48+
const browser = await webdriver(
49+
appPort,
50+
'/en/gsp/fallback/hello-fallback'
51+
)
52+
53+
// wait for the fallback to be generated/stored to ISR cache
54+
browser.waitForElementByCss('#gsp')
55+
56+
// now make sure we're serving the previously generated file from the cache
57+
const html = await renderViaHTTP(
58+
appPort,
59+
'/en/gsp/fallback/hello-fallback'
60+
)
61+
const $ = cheerio.load(html)
62+
63+
expect($('#gsp').text()).toBe('gsp page')
64+
expect($('#router-locale').text()).toBe('en')
65+
expect(JSON.parse($('#router-locales').text())).toEqual(locales)
66+
expect($('#router-pathname').text()).toBe('/gsp/fallback/[slug]')
67+
expect($('#router-as-path').text()).toBe('/gsp/fallback/hello-fallback')
68+
})
69+
}
70+
3271
it('should use correct default locale for locale domains', async () => {
3372
const res = await fetchViaHTTP(appPort, '/', undefined, {
3473
headers: {

0 commit comments

Comments
 (0)