Skip to content

Commit 06effa9

Browse files
committed
Fix Next.js example
1 parent 5f1defb commit 06effa9

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

examples/next/next-env.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/// <reference types="next" />
22
/// <reference types="next/image-types/global" />
3+
/// <reference path="./.next/types/routes.d.ts" />
34

45
// NOTE: This file should not be edited
5-
// see https://nextjs.org/docs/basic-features/typescript for more information.
6+
// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information.

examples/next/next.config.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,30 @@ const withMDX = require('@next/mdx')()
44

55
module.exports = withMDX({
66
pageExtensions: ['js', 'jsx', 'ts', 'tsx', 'mdx'],
7-
webpack(config) {
8-
// This is just for the sake of example app.
9-
// yarn link doesn't play well with React hooks.
10-
// https://github.com/facebook/react/issues/14257
7+
webpack(config, { isServer }) {
8+
// Ensure single instances of React and theme-ui packages in the monorepo
119
Object.assign(config.resolve.alias, {
1210
react: path.resolve(__dirname, './node_modules/react'),
1311
'react-dom': path.resolve(__dirname, './node_modules/react-dom'),
12+
'theme-ui': path.resolve(__dirname, '../../packages/theme-ui'),
13+
'@theme-ui/core': path.resolve(__dirname, '../../packages/core'),
14+
'@theme-ui/css': path.resolve(__dirname, '../../packages/css'),
15+
'@theme-ui/color-modes': path.resolve(__dirname, '../../packages/color-modes'),
16+
'@theme-ui/components': path.resolve(__dirname, '../../packages/components'),
17+
'@theme-ui/theme-provider': path.resolve(__dirname, '../../packages/theme-provider'),
18+
'@emotion/react': path.resolve(__dirname, './node_modules/@emotion/react'),
1419
})
1520

21+
// Don't follow symlinks - use package.json exports to resolve to built files
22+
config.resolve.symlinks = false
23+
24+
// Use CJS on server to avoid async ESM module interop issues with @emotion
25+
if (isServer) {
26+
config.resolve.conditionNames = ['require', 'node', 'default']
27+
}
28+
1629
return config
1730
},
18-
// don't typecheck the packages in the example build
1931
typescript: {
2032
ignoreBuildErrors: true,
2133
},

0 commit comments

Comments
 (0)