@@ -4,18 +4,30 @@ const withMDX = require('@next/mdx')()
44
55module . 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