Skip to content

Commit e716974

Browse files
Merge branch 'canary' into client-only-styled-jsx
2 parents 3f9dbce + cff9fc9 commit e716974

File tree

22 files changed

+73
-98
lines changed

22 files changed

+73
-98
lines changed

docs/basic-features/supported-browsers-features.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,17 @@ description: Browser support and which JavaScript features are supported by Next
44

55
# Supported Browsers and Features
66

7-
Next.js supports **IE11 and all modern browsers** (Edge, Firefox, Chrome, Safari, Opera, et al) with no required configuration.
7+
Next.js supports **modern browsers** with zero configuration.
8+
9+
- Chrome 64+
10+
- Edge 79+
11+
- Firefox 67+
12+
- Opera 51+
13+
- Safari 12+
14+
15+
## Browserslist
16+
17+
If you would like to target specific browsers or features, Next.js supports [Browserslist](https://browsersl.ist) configuration.
818

919
## Polyfills
1020

docs/upgrading.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ description: Learn how to upgrade Next.js.
66

77
## Upgrading from 12 to 13
88

9+
The [Supported Browsers](/docs/basic-features/supported-browsers-features.md) have been changed to drop Internet Explorer and target modern browsers.
10+
911
The minimum Node.js version has been bumped from 12.22.0 to 14.0.0, since 12.x has reached end-of-life.
1012

1113
The `swcMinify` configuration property was changed from `false` to `true`. See [Next.js Compiler](/docs/advanced-features/compiler.md) for more info.
@@ -15,7 +17,7 @@ A [codemod is available](/docs/advanced-features/codemods.md#next-image-to-legac
1517

1618
The `next/link` child can no longer be `<a>`. Add the `legacyBehavior` prop to use the legacy behavior or remove the `<a>` to upgrade. A [codemod is available](/docs/advanced-features/codemods.md#new-link) to automatically upgrade your code.
1719

18-
The `target` configuration option has been removed and superseded by [Output File Tracing](https://nextjs.org/docs/advanced-features/output-file-tracing).
20+
The `target` configuration property has been removed and superseded by [Output File Tracing](https://nextjs.org/docs/advanced-features/output-file-tracing).
1921

2022
## Upgrading to 12.2
2123

packages/next/build/utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1761,8 +1761,9 @@ export function getSupportedBrowsers(
17611761
return browsers
17621762
}
17631763

1764-
// When user does not have browserslist use the default target
1765-
// When `experimental.legacyBrowsers: false` the modern default is used
1764+
// When the user sets `legacyBrowsers: true`, we pass undefined
1765+
// to SWC which is basically ES5 and matches the default behavior
1766+
// prior to Next.js 13
17661767
return config.experimental.legacyBrowsers
17671768
? undefined
17681769
: MODERN_BROWSERSLIST_TARGET

packages/next/build/webpack-config.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -696,9 +696,7 @@ export default async function getBaseWebpackConfig(
696696
fileReading: config.experimental.swcFileReading,
697697
nextConfig: config,
698698
jsConfig,
699-
supportedBrowsers: config.experimental.browsersListForSwc
700-
? supportedBrowsers
701-
: undefined,
699+
supportedBrowsers,
702700
swcCacheDir: path.join(dir, config?.distDir ?? '.next', 'cache', 'swc'),
703701
...extraOptions,
704702
},

packages/next/server/config-schema.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,6 @@ const configSchema = {
240240
},
241241
type: 'object',
242242
},
243-
browsersListForSwc: {
244-
type: 'boolean',
245-
},
246243
cpus: {
247244
type: 'number',
248245
},

packages/next/server/config-shared.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ export interface ExperimentalConfig {
8484
skipTrailingSlashRedirect?: boolean
8585
optimisticClientCache?: boolean
8686
legacyBrowsers?: boolean
87-
browsersListForSwc?: boolean
8887
manualClientBasePath?: boolean
8988
newNextLinkBehavior?: boolean
9089
// custom path to a cache handler to use
@@ -553,9 +552,7 @@ export const defaultConfig: NextConfig = {
553552
optimisticClientCache: true,
554553
runtime: undefined,
555554
manualClientBasePath: false,
556-
// TODO: change default in next major release (current v12.1.5)
557-
legacyBrowsers: true,
558-
browsersListForSwc: false,
555+
legacyBrowsers: false,
559556
newNextLinkBehavior: true,
560557
cpus: Math.max(
561558
1,

packages/next/shared/lib/constants.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,18 @@ export const CLIENT_PUBLIC_FILES_PATH = 'public'
4747
export const CLIENT_STATIC_FILES_PATH = 'static'
4848
export const CLIENT_STATIC_FILES_RUNTIME = 'runtime'
4949
export const STRING_LITERAL_DROP_BUNDLE = '__NEXT_DROP_CLIENT_FILE__'
50+
/**
51+
* These are the browser versions that support all of the following:
52+
* static import: https://caniuse.com/es6-module
53+
* dynamic import: https://caniuse.com/es6-module-dynamic-import
54+
* import.meta: https://caniuse.com/mdn-javascript_operators_import_meta
55+
*/
5056
export const MODERN_BROWSERSLIST_TARGET = [
51-
'chrome 61',
52-
'edge 16',
53-
'firefox 60',
54-
'opera 48',
55-
'safari 11',
57+
'chrome 64',
58+
'edge 79',
59+
'firefox 67',
60+
'opera 51',
61+
'safari 12',
5662
]
5763
export const NEXT_BUILTIN_DOCUMENT = '__NEXT_BUILTIN_DOCUMENT__'
5864
export const NEXT_CLIENT_SSR_ENTRY_SUFFIX = '.__sc_client__'
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
module.exports = {
22
experimental: {
33
appDir: true,
4-
legacyBrowsers: false,
5-
browsersListForSwc: true,
64
},
75
}
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
module.exports = {
22
experimental: {
33
appDir: true,
4-
legacyBrowsers: false,
5-
browsersListForSwc: true,
64
},
75
}
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
module.exports = {
22
experimental: {
33
appDir: true,
4-
legacyBrowsers: false,
5-
browsersListForSwc: true,
64
},
75
}

test/e2e/app-dir/app-static/next.config.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module.exports = {
22
experimental: {
33
appDir: true,
4-
legacyBrowsers: false,
5-
browsersListForSwc: true,
64
},
75
// assetPrefix: '/assets',
86
rewrites: async () => {

test/e2e/app-dir/app/next.config.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module.exports = {
22
experimental: {
33
appDir: true,
4-
legacyBrowsers: false,
5-
browsersListForSwc: true,
64
sri: {
75
algorithm: 'sha256',
86
},

test/e2e/app-dir/asset-prefix/next.config.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module.exports = {
22
experimental: {
33
appDir: true,
4-
legacyBrowsers: false,
5-
browsersListForSwc: true,
64
},
75
assetPrefix: '/assets',
86
rewrites() {

test/e2e/app-dir/next-font/next.config.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module.exports = {
22
experimental: {
33
appDir: true,
4-
legacyBrowsers: false,
5-
browsersListForSwc: true,
64
fontLoaders: [
75
{
86
loader: '@next/font/local',
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module.exports = {
22
experimental: {
33
appDir: true,
4-
legacyBrowsers: false,
5-
browsersListForSwc: true,
64
},
75
trailingSlash: true,
86
}

test/e2e/browserslist/browserslist.test.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ describe('Browserslist', () => {
1414
pages: new FileRef(path.join(appDir, 'pages')),
1515
'.browserslistrc': 'Chrome 73',
1616
},
17-
nextConfig: {
18-
experimental: {
19-
browsersListForSwc: true,
20-
},
21-
},
2217
dependencies: {},
2318
})
2419
})
@@ -36,14 +31,9 @@ describe('Browserslist', () => {
3631
const src = $(el).attr('src')
3732
if (!src) return
3833
if (src.includes('/index')) {
39-
const code = await fetchViaHTTP(next.url, src).then((res) =>
40-
res.text()
41-
)
42-
43-
const isDev = (global as any).isNextDev
44-
expect(
45-
code.includes(isDev ? 'async ()=>{' : 'async()=>{console.log(')
46-
).toBe(true)
34+
const res = await fetchViaHTTP(next.url, src)
35+
const code = await res.text()
36+
expect(code).toMatch('()=>')
4737
finished = true
4838
}
4939
})

test/e2e/browserslist/legacybrowsers-false.test.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,12 @@ describe('legacyBrowsers: false', () => {
1313
files: {
1414
pages: new FileRef(path.join(appDir, 'pages')),
1515
},
16-
nextConfig: {
17-
experimental: {
18-
legacyBrowsers: false,
19-
browsersListForSwc: true,
20-
},
21-
},
2216
dependencies: {},
2317
})
2418
})
2519
afterAll(() => next.destroy())
2620

27-
it('should apply with legacyBrowsers: false correctly', async () => {
21+
it('should apply legacyBrowsers: false by default', async () => {
2822
const html = await renderViaHTTP(next.url, '/')
2923
const $ = cheerio.load(html)
3024

@@ -36,14 +30,9 @@ describe('legacyBrowsers: false', () => {
3630
const src = $(el).attr('src')
3731
if (!src) return
3832
if (src.includes('/index')) {
39-
const code = await fetchViaHTTP(next.url, src).then((res) =>
40-
res.text()
41-
)
42-
43-
const isDev = (global as any).isNextDev
44-
expect(
45-
code.includes(isDev ? 'async ()=>{' : 'async()=>{console.log(')
46-
).toBe(true)
33+
const res = await fetchViaHTTP(next.url, src)
34+
const code = await res.text()
35+
expect(code).toMatch('()=>')
4736
finished = true
4837
}
4938
})

test/e2e/browserslist/legacybrowsers-true.test.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ describe('legacyBrowsers: true', () => {
1515
},
1616
nextConfig: {
1717
experimental: {
18-
browsersListForSwc: true,
18+
legacyBrowsers: true,
1919
},
2020
},
2121
dependencies: {},
2222
})
2323
})
2424
afterAll(() => next.destroy())
2525

26-
it('should apply legacyBrowsers: true by default', async () => {
26+
it('should apply legacyBrowsers: true', async () => {
2727
const html = await renderViaHTTP(next.url, '/')
2828
const $ = cheerio.load(html)
2929

@@ -35,14 +35,9 @@ describe('legacyBrowsers: true', () => {
3535
const src = $(el).attr('src')
3636
if (!src) return
3737
if (src.includes('/index')) {
38-
const code = await fetchViaHTTP(next.url, src).then((res) =>
39-
res.text()
40-
)
41-
42-
const isDev = (global as any).isNextDev
43-
expect(
44-
code.includes(isDev ? 'async ()=>{' : 'async()=>{console.log(')
45-
).toBe(false)
38+
const res = await fetchViaHTTP(next.url, src)
39+
const code = await res.text()
40+
expect(code).not.toMatch('()=>')
4641
finished = true
4742
}
4843
})

test/integration/config-experimental-warning/test/index.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@ describe('Config Experimental Warning', () => {
8484
configFile.write(`
8585
module.exports = {
8686
experimental: {
87+
enableUndici: true,
8788
workerThreads: true,
88-
legacyBrowsers: false,
8989
}
9090
}
9191
`)
9292
const { stderr } = await nextBuild(appDir, [], { stderr: true })
9393
expect(stderr).toMatch(
94-
'You have enabled experimental features (workerThreads, legacyBrowsers) in next.config.js.'
94+
'You have enabled experimental features (enableUndici, workerThreads) in next.config.js.'
9595
)
9696
})
9797

test/integration/css/test/group-1.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ describe('CSS Support', () => {
189189
expect(
190190
cssContent.replace(/\/\*.*?\*\//g, '').trim()
191191
).toMatchInlineSnapshot(
192-
`"@media (min-width:480px) and (max-width:767px){::-moz-placeholder{color:green}:-ms-input-placeholder{color:green}::placeholder{color:green}}.flex-parsing{flex:0 0 calc(50% - var(--vertical-gutter))}.transform-parsing{transform:translate3d(0,0)}.css-grid-shorthand{grid-column:span 2}.g-docs-sidenav .filter::-webkit-input-placeholder{opacity:80%}"`
192+
`"@media (min-width:480px) and (max-width:767px){::placeholder{color:green}}.flex-parsing{flex:0 0 calc(50% - var(--vertical-gutter))}.transform-parsing{transform:translate3d(0,0)}.css-grid-shorthand{grid-column:span 2}.g-docs-sidenav .filter::-webkit-input-placeholder{opacity:80%}"`
193193
)
194194

195195
// Contains a source map
@@ -210,7 +210,7 @@ describe('CSS Support', () => {
210210
const { version, mappings, sourcesContent } = JSON.parse(cssMapContent)
211211
expect({ version, mappings, sourcesContent }).toMatchInlineSnapshot(`
212212
Object {
213-
"mappings": "AAAA,+CACE,mBACE,WACF,CAFA,uBACE,WACF,CAFA,cACE,WACF,CACF,CAEA,cACE,2CACF,CAEA,mBACE,0BACF,CAEA,oBACE,kBACF,CAEA,mDACE,WACF",
213+
"mappings": "AAAA,+CACE,cACE,WACF,CACF,CAEA,cACE,2CACF,CAEA,mBACE,0BACF,CAEA,oBACE,kBACF,CAEA,mDACE,WACF",
214214
"sourcesContent": Array [
215215
"@media (480px <= width < 768px) {
216216
::placeholder {

test/integration/scss/test/group-1.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ describe('SCSS Support', () => {
248248
expect(
249249
cssContent.replace(/\/\*.*?\*\//g, '').trim()
250250
).toMatchInlineSnapshot(
251-
`".redText ::-moz-placeholder{color:red}.redText :-ms-input-placeholder{color:red}.redText ::placeholder{color:red}.flex-parsing{flex:0 0 calc(50% - var(--vertical-gutter))}"`
251+
`".redText ::placeholder{color:red}.flex-parsing{flex:0 0 calc(50% - var(--vertical-gutter))}"`
252252
)
253253

254254
// Contains a source map
@@ -269,7 +269,7 @@ describe('SCSS Support', () => {
269269
const { version, mappings, sourcesContent } = JSON.parse(cssMapContent)
270270
expect({ version, mappings, sourcesContent }).toMatchInlineSnapshot(`
271271
Object {
272-
"mappings": "AAEE,4BACE,SAHE,CAEJ,gCACE,SAHE,CAEJ,uBACE,SAHE,CAON,cACE,2CAAA",
272+
"mappings": "AAEE,uBACE,SAHE,CAON,cACE,2CAAA",
273273
"sourcesContent": Array [
274274
"$var: red;
275275
.redText {

0 commit comments

Comments
 (0)