Unverified Commit d84e2f58 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Set default webpack publicPath value to override auto (#25452)

* Set default webpack publicPath value to override auto

* Add test case

* update size-test
parent b9242077
...@@ -919,6 +919,9 @@ export default async function getBaseWebpackConfig( ...@@ -919,6 +919,9 @@ export default async function getBaseWebpackConfig(
}, },
} }
: {}), : {}),
// we must set publicPath to an empty value to override the default of
// auto which doesn't work in IE11
publicPath: '',
path: path:
isServer && isWebpack5 && !dev isServer && isWebpack5 && !dev
? path.join(outputPath, 'chunks') ? path.join(outputPath, 'chunks')
......
...@@ -123,16 +123,16 @@ describe('Build Output', () => { ...@@ -123,16 +123,16 @@ describe('Build Output', () => {
) )
expect(indexSize.endsWith('B')).toBe(true) expect(indexSize.endsWith('B')).toBe(true)
expect(parseFloat(indexFirstLoad)).toBeCloseTo(gz ? 63.6 : 195, 1) expect(parseFloat(indexFirstLoad)).toBeCloseTo(gz ? 63.4 : 195, 1)
expect(indexFirstLoad.endsWith('kB')).toBe(true) expect(indexFirstLoad.endsWith('kB')).toBe(true)
expect(parseFloat(err404Size)).toBeCloseTo(gz ? 3.06 : 8.15, 1) expect(parseFloat(err404Size)).toBeCloseTo(gz ? 3.06 : 8.15, 1)
expect(err404Size.endsWith('kB')).toBe(true) expect(err404Size.endsWith('kB')).toBe(true)
expect(parseFloat(err404FirstLoad)).toBeCloseTo(gz ? 66.45 : 203, 1) expect(parseFloat(err404FirstLoad)).toBeCloseTo(gz ? 66.3 : 202, 1)
expect(err404FirstLoad.endsWith('kB')).toBe(true) expect(err404FirstLoad.endsWith('kB')).toBe(true)
expect(parseFloat(sharedByAll)).toBeCloseTo(gz ? 63.4 : 195, 1) expect(parseFloat(sharedByAll)).toBeCloseTo(gz ? 63.2 : 194, 1)
expect(sharedByAll.endsWith('kB')).toBe(true) expect(sharedByAll.endsWith('kB')).toBe(true)
const appSizeValue = _appSize.endsWith('kB') const appSizeValue = _appSize.endsWith('kB')
...@@ -144,7 +144,7 @@ describe('Build Output', () => { ...@@ -144,7 +144,7 @@ describe('Build Output', () => {
const webpackSizeValue = webpackSize.endsWith('kB') const webpackSizeValue = webpackSize.endsWith('kB')
? parseFloat(webpackSize) ? parseFloat(webpackSize)
: parseFloat(webpackSize) / 1000 : parseFloat(webpackSize) / 1000
expect(webpackSizeValue).toBeCloseTo(gz ? 0.95 : 1.81, 2) expect(webpackSizeValue).toBeCloseTo(gz ? 0.76 : 1.45, 2)
expect(webpackSize.endsWith('kB') || webpackSize.endsWith(' B')).toBe( expect(webpackSize.endsWith('kB') || webpackSize.endsWith(' B')).toBe(
true true
) )
......
/* eslint-env jest */ /* eslint-env jest */
/* global browserName */ /* global browserName */
import cheerio from 'cheerio' import cheerio from 'cheerio'
import { existsSync } from 'fs' import fs, { existsSync } from 'fs-extra'
import globOriginal from 'glob'
import { import {
nextServer, nextServer,
renderViaHTTP, renderViaHTTP,
...@@ -24,6 +25,10 @@ import { join } from 'path' ...@@ -24,6 +25,10 @@ import { join } from 'path'
import dynamicImportTests from './dynamic' import dynamicImportTests from './dynamic'
import processEnv from './process-env' import processEnv from './process-env'
import security from './security' import security from './security'
import { promisify } from 'util'
const glob = promisify(globOriginal)
const appDir = join(__dirname, '../') const appDir = join(__dirname, '../')
let appPort let appPort
let server let server
...@@ -64,6 +69,23 @@ describe('Production Usage', () => { ...@@ -64,6 +69,23 @@ describe('Production Usage', () => {
expect(output.match(/Generating static pages/g).length).toBe(5) expect(output.match(/Generating static pages/g).length).toBe(5)
}) })
it('should not contain currentScript usage for publicPath', async () => {
const globResult = await glob('webpack-*.js', {
cwd: join(appDir, '.next/static/chunks'),
})
if (!globResult || globResult.length !== 1) {
throw new Error('could not find webpack-hash.js chunk')
}
const content = await fs.readFile(
join(appDir, '.next/static/chunks', globResult[0]),
'utf8'
)
expect(content).not.toContain('.currentScript')
})
describe('With basic usage', () => { describe('With basic usage', () => {
it('should render the page', async () => { it('should render the page', async () => {
const html = await renderViaHTTP(appPort, '/') const html = await renderViaHTTP(appPort, '/')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment