Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
feedthejim committed Sep 8, 2023
1 parent a2b85da commit 791dff6
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions packages/next/src/server/require-hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ const hookPropertyMap = new Map()
let aliasedPrebundledReact = false

// that env var is only set in app router
const isApp = !!process.env.__NEXT_PRIVATE_PREBUNDLED_REACT
const currentRuntime = `${
isApp
? 'next/dist/compiled/next-server/app-page.runtime'
: 'next/dist/compiled/next-server/pages.runtime'
}.prod`

const resolve = process.env.NEXT_MINIMAL
? // @ts-ignore
Expand Down Expand Up @@ -133,6 +127,11 @@ mod._resolveFilename = function (
if (process.env.NODE_ENV !== 'development' && !process.env.TURBOPACK) {
mod.prototype.require = function (request: string) {
if (request.endsWith('.shared-runtime')) {
const currentRuntime = `${
!!process.env.__NEXT_PRIVATE_PREBUNDLED_REACT
? 'next/dist/compiled/next-server/app-page.runtime'
: 'next/dist/compiled/next-server/pages.runtime'
}.prod`
const base = path.basename(request, '.shared-runtime')
const camelized = base.replace(/-([a-z])/g, (g) => g[1].toUpperCase())
const instance = originalRequire.call(this, currentRuntime)
Expand Down

0 comments on commit 791dff6

Please sign in to comment.