Skip to content

Commit

Permalink
Remove dead-code elimination for iSSG code
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Oct 31, 2019
1 parent 974fe58 commit 03b31cc
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,21 +180,6 @@ export class TerserPlugin {
inputSourceMap = null
}

// if we are using babel cache we can't rely on the page-config
// plugin to update this value so check for it manually
if (file.match(/pages(\\|\/)/) && input.indexOf(prerenderId) > -1) {
sprStatus.used = true
}

// 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

0 comments on commit 03b31cc

Please sign in to comment.