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

refactor: remove edge condition for module proxy path #54167

Merged
merged 1 commit into from
Aug 17, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/next/src/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,7 @@ export default async function getBaseWebpackConfig(
// let this alias hit before `next` alias.
...(isEdgeServer
? {
'next/dist/build': 'next/dist/esm/build',
'next/dist/client': 'next/dist/esm/client',
'next/dist/shared': 'next/dist/esm/shared',
'next/dist/pages': 'next/dist/esm/pages',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { getRSCModuleInformation } from '../../../analysis/get-page-static-info'
import { getModuleBuildInfo } from '../get-module-build-info'

const noopHeadPath = require.resolve('next/dist/client/components/noop-head')
// For edge runtime it will be aliased to esm version by webpack
const MODULE_PROXY_PATH =
'next/dist/build/webpack/loaders/next-flight-loader/module-proxy'

export default function transformSource(
this: any,
Expand All @@ -16,11 +19,6 @@ export default function transformSource(
throw new Error('Expected source to have been transformed to a string.')
}

const moduleProxy =
this._compiler.name === 'edge-server'
? 'next/dist/esm/build/webpack/loaders/next-flight-loader/module-proxy'
: 'next/dist/build/webpack/loaders/next-flight-loader/module-proxy'

// Assign the RSC meta information to buildInfo.
// Exclude next internal files which are not marked as client files
const buildInfo = getModuleBuildInfo(this._module)
Expand Down Expand Up @@ -62,7 +60,7 @@ export default function transformSource(
}

let esmSource = `\
import { createProxy } from "${moduleProxy}"
import { createProxy } from "${MODULE_PROXY_PATH}"
const proxy = createProxy(String.raw\`${this.resourcePath}\`)

// Accessing the __esModule property and exporting $$typeof are required here.
Expand Down Expand Up @@ -102,7 +100,7 @@ export { e${cnt++} as ${ref} };`

this.callback(
null,
source.replace(RSC_MOD_REF_PROXY_ALIAS, moduleProxy),
source.replace(RSC_MOD_REF_PROXY_ALIAS, MODULE_PROXY_PATH),
sourceMap
)
}
Loading