Skip to content

Commit

Permalink
update loader
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Jun 5, 2023
1 parent 17c32c5 commit af39410
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 2 additions & 0 deletions packages/next/src/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,8 @@ export default async function getBaseWebpackConfig(

// TODO: This is a temp fix, investigate the module not found for zod
zod: path.dirname(require.resolve('zod/package.json')),
'styled-jsx': require.resolve('styled-jsx/package.json'),
'styled-jsx/style': require.resolve('styled-jsx/style'),
}
: undefined),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ const nextEdgeFunctionLoader: webpack.LoaderDefinitionFunction<EdgeFunctionLoade
enhanceGlobals()
import * as _mod from ${stringifiedPagePath}
const mod = { ..._mod }
const handler = mod.middleware || mod.default
import handler from ${stringifiedPagePath}
if (typeof handler !== 'function') {
throw new Error('The Edge Function "pages${page}" must export a \`default\` function');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ export default function middlewareLoader(this: any) {
enhanceGlobals()
var mod = require(${stringifiedPagePath})
var handler = mod.middleware || mod.default;
import * as _mod from ${stringifiedPagePath}
const mod = { ..._mod }
const handler = mod.middleware || mod.default
if (typeof handler !== 'function') {
throw new Error('The Middleware "pages${page}" must export a \`middleware\` or a \`default\` function');
Expand Down
1 change: 0 additions & 1 deletion packages/next/src/server/require-hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ addHookAliases([
// styled-jsx needs to be resolved as the external dependency.
['styled-jsx', require.resolve('styled-jsx')],
['styled-jsx/style', require.resolve('styled-jsx/style')],
['styled-jsx/style', require.resolve('styled-jsx/style')],
['zod', dirname(require.resolve('zod/package.json'))],
])

Expand Down

0 comments on commit af39410

Please sign in to comment.