Skip to content

Commit

Permalink
Fix ie11 support with webpack 5 (#25014)
Browse files Browse the repository at this point in the history
This fixes ie11 compatibility that broke in #24656 from the polyfills not being loaded first, our existing ie11 test caught this but was failing, this ensures the test is passing again. This also updates the `hrefValue` optional chaining in the eslint plugin as these files aren't transpiled and related tests were failing in azure 

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
  • Loading branch information
ijjk authored May 12, 2021
1 parent 6ad9172 commit 9a0fc42
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
6 changes: 3 additions & 3 deletions packages/eslint-plugin-next/lib/rules/google-font-display.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ module.exports = {
}

const hrefValue = attributes.value('href')
const isGoogleFont = hrefValue?.startsWith(
'https://fonts.googleapis.com/css'
)
const isGoogleFont =
typeof hrefValue === 'string' &&
hrefValue.startsWith('https://fonts.googleapis.com/css')

if (isGoogleFont) {
const params = new URLSearchParams(hrefValue.split('?')[1])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ module.exports = {
attributes.value('rel') !== 'preconnect'

if (
hrefValue?.startsWith('https://fonts.gstatic.com') &&
typeof hrefValue === 'string' &&
hrefValue.startsWith('https://fonts.gstatic.com') &&
preconnectMissing
) {
context.report({
Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin-next/lib/rules/no-page-custom-font.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ module.exports = {
}

const hrefValue = attributes.value('href')
const isGoogleFont = hrefValue?.startsWith(
'https://fonts.googleapis.com/css'
)
const isGoogleFont =
typeof hrefValue === 'string' &&
hrefValue.startsWith('https://fonts.googleapis.com/css')

if (isGoogleFont) {
context.report({
Expand Down
9 changes: 7 additions & 2 deletions packages/next/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ export default async function getBaseWebpackConfig(
// and all other chunk depend on them so there is no
// duplication that need to be pulled out.
chunks: isWebpack5
? (chunk) => !/^(main|pages\/_app)$/.test(chunk.name)
? (chunk) => !/^(polyfills|main|pages\/_app)$/.test(chunk.name)
: 'all',
cacheGroups: {
framework: {
Expand Down Expand Up @@ -1624,7 +1624,12 @@ export default async function getBaseWebpackConfig(

if (isWebpack5 && !isServer) {
for (const name of Object.keys(entry)) {
if (name === 'main' || name === 'amp' || name === 'react-refresh')
if (
name === 'polyfills' ||
name === 'main' ||
name === 'amp' ||
name === 'react-refresh'
)
continue
const dependOn =
name.startsWith('pages/') && name !== 'pages/_app'
Expand Down

0 comments on commit 9a0fc42

Please sign in to comment.