Skip to content

Commit

Permalink
fix resolving
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Jun 7, 2023
1 parent 937edb1 commit 5d5837f
Show file tree
Hide file tree
Showing 6 changed files with 776 additions and 650 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
"semver": "7.3.7",
"shell-quote": "1.7.3",
"strip-ansi": "6.0.0",
"styled-components": "6.0.0-beta.5",
"styled-components": "6.0.0-rc.3",
"styled-jsx": "5.1.1",
"styled-jsx-plugin-postcss": "3.0.2",
"swr": "^2.0.0",
Expand Down
16 changes: 9 additions & 7 deletions packages/next/src/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,14 @@ const asyncStoragesRegex =
/next[\\/]dist[\\/]client[\\/]components[\\/](static-generation-async-storage|action-async-storage|request-async-storage)/

// exports.<conditionName>
const edgeConditionNames = ['edge-light', 'worker', 'browser', 'module']
const edgeConditionNames = [
'edge-light',
'worker',
'import',
'module',
'main',
'browser',
]

// packageJson.<mainField>
const mainFieldsPerCompiler: Record<CompilerNameValues, string[]> = {
Expand All @@ -109,8 +116,8 @@ const mainFieldsPerCompiler: Record<CompilerNameValues, string[]> = {
[COMPILER_NAMES.edgeServer]: [
'edge-light',
'worker',
'browser',
'module',
'browser',
'main',
],
}
Expand Down Expand Up @@ -1098,11 +1105,6 @@ export default async function getBaseWebpackConfig(
'next/dist/esm/client/components/navigation',
[require.resolve('next/dist/client/components/headers')]:
'next/dist/esm/client/components/headers',

// 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
2 changes: 1 addition & 1 deletion packages/next/src/server/require-hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function addHookAliases(aliases: [string, string][] = []) {
addHookAliases([
// Use `require.resolve` explicitly to make them statically analyzable
// styled-jsx needs to be resolved as the external dependency.
['styled-jsx', require.resolve('styled-jsx')],
['styled-jsx', dirname(require.resolve('styled-jsx/package.json'))],
['styled-jsx/style', require.resolve('styled-jsx/style')],
['zod', dirname(require.resolve('zod/package.json'))],
])
Expand Down

0 comments on commit 5d5837f

Please sign in to comment.