Unverified Commit cfb8cc84 authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

Change .web extension of document page to part of path (#31116)

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
parent ad981783
...@@ -65,7 +65,7 @@ export function createPagesMapping( ...@@ -65,7 +65,7 @@ export function createPagesMapping(
// we alias these in development and allow webpack to // we alias these in development and allow webpack to
// allow falling back to the correct source file so // allow falling back to the correct source file so
// that HMR can work properly when a file is added/removed // that HMR can work properly when a file is added/removed
const documentPage = `_document${hasServerComponents ? '.web' : ''}` const documentPage = `_document${hasServerComponents ? '-web' : ''}`
if (isDev) { if (isDev) {
pages['/_app'] = `${PAGES_DIR_ALIAS}/_app` pages['/_app'] = `${PAGES_DIR_ALIAS}/_app`
pages['/_error'] = `${PAGES_DIR_ALIAS}/_error` pages['/_error'] = `${PAGES_DIR_ALIAS}/_error`
......
...@@ -629,7 +629,7 @@ export default async function getBaseWebpackConfig( ...@@ -629,7 +629,7 @@ export default async function getBaseWebpackConfig(
prev.push(path.join(pagesDir, `_document.${ext}`)) prev.push(path.join(pagesDir, `_document.${ext}`))
return prev return prev
}, [] as string[]), }, [] as string[]),
`next/dist/pages/_document${hasServerComponents ? '.web' : ''}.js`, `next/dist/pages/_document${hasServerComponents ? '-web' : ''}.js`,
] ]
} }
......
// Default _document page for web runtime
import React from 'react' import React from 'react'
import { Html, Head, Main, NextScript } from './_document' import { Html, Head, Main, NextScript } from './_document'
......
...@@ -1123,7 +1123,7 @@ export async function pages_document(task, opts) { ...@@ -1123,7 +1123,7 @@ export async function pages_document(task, opts) {
export async function pages_document_server(task, opts) { export async function pages_document_server(task, opts) {
await task await task
.source('pages/_document.web.tsx') .source('pages/_document-web.tsx')
.swc('client', { dev: opts.dev }) .swc('client', { dev: opts.dev })
.target('dist/pages') .target('dist/pages')
} }
......
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