Unverified Commit 344ccf2b authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

Fix edge runtim path slashes mismatch on windows (#46302)

<!--
Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:
-->

Closes NEXT-620

Test with app-playground locally on windows VM

## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

---------
Co-authored-by: 's avatarkodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
parent 0305d0cb
...@@ -594,7 +594,10 @@ export class FlightClientEntryPlugin { ...@@ -594,7 +594,10 @@ export class FlightClientEntryPlugin {
const clientLoader = `next-flight-client-entry-loader?${stringify({ const clientLoader = `next-flight-client-entry-loader?${stringify({
modules: this.isEdgeServer modules: this.isEdgeServer
? clientImports.map((importPath) => ? clientImports.map((importPath) =>
importPath.replace('next/dist/esm/', 'next/dist/') importPath.replace(
/[\\/]next[\\/]dist[\\/]esm[\\/]/,
'/next/dist/'.replace(/\//g, path.sep)
)
) )
: clientImports, : clientImports,
server: false, server: false,
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
import path from 'path'
import { webpack, sources } from 'next/dist/compiled/webpack/webpack' import { webpack, sources } from 'next/dist/compiled/webpack/webpack'
import { import {
CLIENT_REFERENCE_MANIFEST, CLIENT_REFERENCE_MANIFEST,
...@@ -325,9 +326,13 @@ export class FlightManifestPlugin { ...@@ -325,9 +326,13 @@ export class FlightManifestPlugin {
// The client compiler will always use the CJS Next.js build, so here we // The client compiler will always use the CJS Next.js build, so here we
// also add the mapping for the ESM build (Edge runtime) to consume. // also add the mapping for the ESM build (Edge runtime) to consume.
if (/\/next\/dist\//.test(resource)) { if (/[\\/]next[\\/]dist[\\/]/.test(resource)) {
manifest[resource.replace(/\/next\/dist\//, '/next/dist/esm/')] = manifest[
moduleExports resource.replace(
/[\\/]next[\\/]dist[\\/]/,
'/next/dist/esm/'.replace(/\//g, path.sep)
)
] = moduleExports
} }
manifest.__ssr_module_mapping__ = moduleIdMapping manifest.__ssr_module_mapping__ = moduleIdMapping
......
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