Skip to content

Commit

Permalink
Change .web extension of document page to part of path (#31116)
Browse files Browse the repository at this point in the history
Fixes: #31104

This effecting users who are using expo with next (`@expo/next-adapter`) since react-native use `.web`, `.ios` and `.android` to identify platform. [Reference](https://docs.expo.dev/guides/using-electron/#%F0%9F%A7%B8-behavior)

Change `document.web.js` to `document-web.js` as fallback page in web runtime
  • Loading branch information
huozhi committed Nov 7, 2021
1 parent ad98178 commit cfb8cc8
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/next/build/entries.ts
Expand Up @@ -65,7 +65,7 @@ export function createPagesMapping(
// we alias these in development and allow webpack to
// allow falling back to the correct source file so
// that HMR can work properly when a file is added/removed
const documentPage = `_document${hasServerComponents ? '.web' : ''}`
const documentPage = `_document${hasServerComponents ? '-web' : ''}`
if (isDev) {
pages['/_app'] = `${PAGES_DIR_ALIAS}/_app`
pages['/_error'] = `${PAGES_DIR_ALIAS}/_error`
Expand Down
2 changes: 1 addition & 1 deletion packages/next/build/webpack-config.ts
Expand Up @@ -629,7 +629,7 @@ export default async function getBaseWebpackConfig(
prev.push(path.join(pagesDir, `_document.${ext}`))
return prev
}, [] as string[]),
`next/dist/pages/_document${hasServerComponents ? '.web' : ''}.js`,
`next/dist/pages/_document${hasServerComponents ? '-web' : ''}.js`,
]
}

Expand Down
@@ -1,3 +1,5 @@
// Default _document page for web runtime

import React from 'react'
import { Html, Head, Main, NextScript } from './_document'

Expand Down
2 changes: 1 addition & 1 deletion packages/next/taskfile.js
Expand Up @@ -1123,7 +1123,7 @@ export async function pages_document(task, opts) {

export async function pages_document_server(task, opts) {
await task
.source('pages/_document.web.tsx')
.source('pages/_document-web.tsx')
.swc('client', { dev: opts.dev })
.target('dist/pages')
}
Expand Down

0 comments on commit cfb8cc8

Please sign in to comment.