Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: disable script worker in edge and fix rsc loader and runtime #35604

Merged
merged 4 commits into from Mar 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/next/build/index.ts
Expand Up @@ -960,8 +960,10 @@ export default async function build(
let ssgPageRoutes: string[] | null = null
let isMiddlewareRoute = !!page.match(MIDDLEWARE_ROUTE)

const pagePath = pagePaths.find((_path) =>
_path.startsWith(actualPage + '.')
const pagePath = pagePaths.find(
(p) =>
p.startsWith(actualPage + '.') ||
p.startsWith(actualPage + '/index.')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the case of this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

folder/index.server.js, like note/edit/index.server.js. The page is normalized so it doesn’t contain index

)
const pageRuntime =
hasConcurrentFeatures && pagePath
Expand All @@ -974,7 +976,7 @@ export default async function build(
if (
!isMiddlewareRoute &&
!isReservedPage(page) &&
// We currently don't support staic optimization in the Edge runtime.
// We currently don't support static optimization in the Edge runtime.
pageRuntime !== 'edge'
) {
try {
Expand Down
1 change: 1 addition & 0 deletions packages/next/build/webpack-config.ts
Expand Up @@ -981,6 +981,7 @@ export default async function getBaseWebpackConfig(
...(isEdgeRuntime
? [
{
'@builder.io/partytown': '{}',
'next/dist/compiled/etag': '{}',
'next/dist/compiled/chalk': '{}',
'react-dom': '{}',
Expand Down
1 change: 1 addition & 0 deletions packages/next/build/webpack/loaders/utils.ts
Expand Up @@ -14,6 +14,7 @@ export function buildExports(moduleExports: any, isESM: boolean) {

const esmNodeTypes = [
'ImportDeclaration',
'ExportDeclaration',
'ExportNamedDeclaration',
'ExportDefaultExpression',
'ExportDefaultDeclaration',
Expand Down
3 changes: 2 additions & 1 deletion packages/next/pages/_document.tsx
Expand Up @@ -79,7 +79,8 @@ function hasComponentProps(child: any): child is React.ReactElement {
function getPreNextWorkerScripts(context: HtmlProps, props: OriginProps) {
const { assetPrefix, scriptLoader, crossOrigin, nextScriptWorkers } = context

if (!nextScriptWorkers) return null
// disable `nextScriptWorkers` in edge runtime
if (!nextScriptWorkers || process.browser) return null

try {
let {
Expand Down