Skip to content

Commit

Permalink
fix next-app-loader on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Aug 16, 2022
1 parent 5061167 commit 5081ba8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions packages/next/build/webpack/loaders/next-app-loader.ts
Expand Up @@ -25,7 +25,7 @@ async function createTreeCodeFromPath({
// First item in the list is the page which can't have layouts by itself
if (i === segments.length - 1) {
// Use '' for segment as it's the page. There can't be a segment called '' so this is the safest way to add it.
tree = `['', {}, {page: () => require('${pagePath}')}]`
tree = `['', {}, {page: () => require(${JSON.stringify(pagePath)})}]`
continue
}

Expand All @@ -48,12 +48,12 @@ async function createTreeCodeFromPath({
}, {
${
resolvedLayoutPath
? `layout: () => require('${resolvedLayoutPath}'),`
? `layout: () => require(${JSON.stringify(resolvedLayoutPath)}),`
: ''
}
${
resolvedLoadingPath
? `loading: () => require('${resolvedLoadingPath}'),`
? `loading: () => require(${JSON.stringify(resolvedLoadingPath)}),`
: ''
}
}]`
Expand Down
9 changes: 6 additions & 3 deletions packages/next/server/dev/hot-reloader.ts
Expand Up @@ -4,7 +4,7 @@ import type { CustomRoutes } from '../../lib/load-custom-routes'
import { getOverlayMiddleware } from 'next/dist/compiled/@next/react-dev-overlay/dist/middleware'
import { IncomingMessage, ServerResponse } from 'http'
import { WebpackHotMiddleware } from './hot-middleware'
import { join, relative, isAbsolute } from 'path'
import { join, relative, isAbsolute, posix } from 'path'
import { UrlObject } from 'url'
import {
createEntrypoints,
Expand Down Expand Up @@ -666,9 +666,12 @@ export default class HotReloader {
this.appDir && bundlePath.startsWith('app/')
? getAppEntry({
name: bundlePath,
pagePath: join(
pagePath: posix.join(
APP_DIR_ALIAS,
relative(this.appDir!, entryData.absolutePagePath)
posix.relative(
this.appDir!,
entryData.absolutePagePath
)
),
appDir: this.appDir!,
pageExtensions: this.config.pageExtensions,
Expand Down

0 comments on commit 5081ba8

Please sign in to comment.