Commit aafbd53c authored by JJ Kasper's avatar JJ Kasper Committed by Joe Haddad

Remove dead code elimination for when iSSG isn't used (#9267)

* Don't rely on page-config plugin to detect iSSG usage

* Make sure to only update sprStatus if page file

* Remove dead-code elimination for iSSG code

* Revert next-page-config.ts

* Update index.js

* Update index.test.js
parent 81066a39
......@@ -6,7 +6,6 @@ import { SourceMapConsumer } from 'source-map'
import { SourceMapSource, RawSource } from 'webpack-sources'
import { RequestShortener } from 'webpack'
import TaskRunner from './TaskRunner'
import { sprStatus } from '../../../../babel/plugins/next-page-config'
const warningRegex = /\[.+:([0-9]+),([0-9]+)\]/
......@@ -177,15 +176,6 @@ export class TerserPlugin {
inputSourceMap = null
}
// force dead-code elimination for SPR related code if not used
const { compress } = this.options.terserOptions
if (compress) {
if (!compress.global_defs) {
compress.global_defs = {}
}
compress.global_defs['self.__HAS_SPR'] = !!sprStatus.used
}
const task = {
file,
input,
......
......@@ -625,11 +625,7 @@ export default class Router implements BaseRouter {
const { Component: App } = this.components['/_app']
let props
if (
// @ts-ignore workaround for dead-code elimination
(self.__HAS_SPR || process.env.NODE_ENV !== 'production') &&
(Component as any).__NEXT_SPR
) {
if ((Component as any).__NEXT_SPR) {
let status: any
// pathname should have leading slash
let { pathname } = parse(ctx.asPath || ctx.pathname)
......
......@@ -81,7 +81,7 @@ describe('Production response size', () => {
)
// These numbers are without gzip compression!
expect(responseSizeKilobytes).toBeLessThanOrEqual(221) // Kilobytes
expect(responseSizeKilobytes).toBeLessThanOrEqual(222) // Kilobytes
})
it('should not increase the overall response size of modern build', async () => {
......@@ -99,6 +99,6 @@ describe('Production response size', () => {
)
// These numbers are without gzip compression!
expect(responseSizeKilobytes).toBeLessThanOrEqual(199) // Kilobytes
expect(responseSizeKilobytes).toBeLessThanOrEqual(200) // Kilobytes
})
})
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