Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set default webpack publicPath value to override auto #25452

Merged
merged 3 commits into from
May 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/next/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,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:
isServer && isWebpack5 && !dev
? path.join(outputPath, 'chunks')
Expand Down
8 changes: 4 additions & 4 deletions test/integration/build-output/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,16 @@ describe('Build Output', () => {
)
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(parseFloat(err404Size)).toBeCloseTo(gz ? 3.06 : 8.15, 1)
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(parseFloat(sharedByAll)).toBeCloseTo(gz ? 63.4 : 195, 1)
expect(parseFloat(sharedByAll)).toBeCloseTo(gz ? 63.2 : 194, 1)
expect(sharedByAll.endsWith('kB')).toBe(true)

const appSizeValue = _appSize.endsWith('kB')
Expand All @@ -144,7 +144,7 @@ describe('Build Output', () => {
const webpackSizeValue = webpackSize.endsWith('kB')
? parseFloat(webpackSize)
: 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(
true
)
Expand Down
24 changes: 23 additions & 1 deletion test/integration/production/test/index.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* eslint-env jest */
/* global browserName */
import cheerio from 'cheerio'
import { existsSync } from 'fs'
import fs, { existsSync } from 'fs-extra'
import globOriginal from 'glob'
import {
nextServer,
renderViaHTTP,
Expand All @@ -24,6 +25,10 @@ import { join } from 'path'
import dynamicImportTests from './dynamic'
import processEnv from './process-env'
import security from './security'
import { promisify } from 'util'

const glob = promisify(globOriginal)

const appDir = join(__dirname, '../')
let appPort
let server
Expand Down Expand Up @@ -64,6 +69,23 @@ describe('Production Usage', () => {
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', () => {
it('should render the page', async () => {
const html = await renderViaHTTP(appPort, '/')
Expand Down