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

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

Merged
merged 8 commits into from
Oct 31, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -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]+)\]/

Expand Down Expand Up @@ -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,
Expand Down
6 changes: 1 addition & 5 deletions packages/next/next-server/lib/router/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions test/integration/size-limit/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -99,6 +99,6 @@ describe('Production response size', () => {
)

// These numbers are without gzip compression!
expect(responseSizeKilobytes).toBeLessThanOrEqual(199) // Kilobytes
expect(responseSizeKilobytes).toBeLessThanOrEqual(200) // Kilobytes
})
})