Unverified Commit 5034e4e1 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Updated entries to not output _app and _document in serverless (#6512)

* Updated entries to not output _app and _document in serverless

* Add test
parent 8e807ca2
...@@ -48,7 +48,7 @@ export function createEntrypoints(pages: PagesMapping, target: 'server'|'serverl ...@@ -48,7 +48,7 @@ export function createEntrypoints(pages: PagesMapping, target: 'server'|'serverl
const absolutePagePath = pages[page] const absolutePagePath = pages[page]
const bundleFile = page === '/' ? '/index.js' : `${page}.js` const bundleFile = page === '/' ? '/index.js' : `${page}.js`
const bundlePath = join('static', buildId, 'pages', bundleFile) const bundlePath = join('static', buildId, 'pages', bundleFile)
if(target === 'serverless') { if(target === 'serverless' && page !== '/_app' && page !== '/_document') {
const serverlessLoaderOptions: ServerlessLoaderQuery = {page, absolutePagePath, ...defaultServerlessOptions} const serverlessLoaderOptions: ServerlessLoaderQuery = {page, absolutePagePath, ...defaultServerlessOptions}
server[join('pages', bundleFile)] = `next-serverless-loader?${stringify(serverlessLoaderOptions)}!` server[join('pages', bundleFile)] = `next-serverless-loader?${stringify(serverlessLoaderOptions)}!`
} else if(target === 'server') { } else if(target === 'server') {
......
/* eslint-env jest */ /* eslint-env jest */
/* global jasmine, test */ /* global jasmine, test */
import { join } from 'path' import { join } from 'path'
import { existsSync } from 'fs'
import { import {
nextBuild, nextBuild,
stopApp, stopApp,
...@@ -65,6 +66,12 @@ describe('Serverless', () => { ...@@ -65,6 +66,12 @@ describe('Serverless', () => {
} }
}) })
it('should not output _app.js and _document.js to serverless build', () => {
const serverlessDir = join(appDir, '.next/serverless/pages')
expect(existsSync(join(serverlessDir, '_app.js'))).toBeFalsy()
expect(existsSync(join(serverlessDir, '_document.js'))).toBeFalsy()
})
describe('With basic usage', () => { describe('With basic usage', () => {
it('should allow etag header support', async () => { it('should allow etag header support', async () => {
const url = `http://localhost:${appPort}/` const url = `http://localhost:${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