Skip to content

Commit c2d8483

Browse files
committed
Update order in serverless target instead
1 parent e15db11 commit c2d8483

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

packages/next/build/webpack/loaders/next-serverless-loader/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ const nextServerlessLoader: webpack.loader.Loader = function () {
138138
}
139139
import { getPageHandler } from 'next/dist/build/webpack/loaders/next-serverless-loader/page-handler'
140140
141+
const documentModule = require("${absoluteDocumentPath}")
142+
141143
const appMod = require('${absoluteAppPath}')
142144
let App = appMod.default || appMod.then && appMod.then(mod => mod.default);
143145
@@ -163,7 +165,7 @@ const nextServerlessLoader: webpack.loader.Loader = function () {
163165
pageComponent: Component,
164166
pageConfig: config,
165167
appModule: App,
166-
documentModule: require("${absoluteDocumentPath}"),
168+
documentModule: documentModule,
167169
errorModule: require("${absoluteErrorPath}"),
168170
notFoundModule: ${
169171
absolute404Path ? `require("${absolute404Path}")` : undefined

packages/next/next-server/server/load-components.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ export async function loadComponents(
5959
} as LoadComponentsReturnType
6060
}
6161

62-
const AppMod = await requirePage('/_app', distDir, serverless)
6362
const DocumentMod = await requirePage('/_document', distDir, serverless)
63+
const AppMod = await requirePage('/_app', distDir, serverless)
6464
const ComponentMod = await requirePage(pathname, distDir, serverless)
6565

6666
const [

test/integration/app-document-import-order/test/index.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe('Root components import order', () => {
3838
const html = await res.text()
3939
const $ = cheerio.load(html)
4040

41-
const expectSideEffectsOrder = ['_app', '_document', 'page']
41+
const expectSideEffectsOrder = ['_document', '_app', 'page']
4242

4343
const sideEffectCalls = $('.side-effect-calls')
4444

@@ -87,7 +87,7 @@ describe('Root components import order', () => {
8787
afterAll(() => killApp(app))
8888

8989
it(
90-
'root components should be imported in this order _app > _document > page in order to respect side effects',
90+
'root components should be imported in this order _document > _app > page in order to respect side effects',
9191
respectsSideEffects
9292
)
9393

0 commit comments

Comments
 (0)