Skip to content

Commit

Permalink
Fix edge runtim path slashes mismatch on windows (#46302)
Browse files Browse the repository at this point in the history
<!--
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: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
huozhi and kodiakhq[bot] authored Feb 23, 2023
1 parent 0305d0c commit 344ccf2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,10 @@ export class FlightClientEntryPlugin {
const clientLoader = `next-flight-client-entry-loader?${stringify({
modules: this.isEdgeServer
? clientImports.map((importPath) =>
importPath.replace('next/dist/esm/', 'next/dist/')
importPath.replace(
/[\\/]next[\\/]dist[\\/]esm[\\/]/,
'/next/dist/'.replace(/\//g, path.sep)
)
)
: clientImports,
server: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

import path from 'path'
import { webpack, sources } from 'next/dist/compiled/webpack/webpack'
import {
CLIENT_REFERENCE_MANIFEST,
Expand Down Expand Up @@ -325,9 +326,13 @@ export class FlightManifestPlugin {

// 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.
if (/\/next\/dist\//.test(resource)) {
manifest[resource.replace(/\/next\/dist\//, '/next/dist/esm/')] =
moduleExports
if (/[\\/]next[\\/]dist[\\/]/.test(resource)) {
manifest[
resource.replace(
/[\\/]next[\\/]dist[\\/]/,
'/next/dist/esm/'.replace(/\//g, path.sep)
)
] = moduleExports
}

manifest.__ssr_module_mapping__ = moduleIdMapping
Expand Down

0 comments on commit 344ccf2

Please sign in to comment.