-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Build error with NextJs #3502
Copy link
Copy link
Closed
Description
- Check if updating to the latest Preact version resolves the issue
Using Next.js -> package.json:
"next": "12.1.2",
"preact": "^10.7.0",
"react": "18.0.0",
"react-dom": "18.0.0"Describe the bug
I am using Preact to replace React with webpacks alias config. After upgrading to React 18 I get following error when I try to build:
./node_modules/next/dist/client/index.js
Module not found: Package path ./compat/client is not exported from package path\to\project\node_modules\preact (see exports field in path\to\project\node_modules\preact\package.json)
(I removed personal data from the path)
To Reproduce
Steps to reproduce the behavior:
- Create a NextJs project:
yarn create next-app --typescript - Add preact:
yarn add preact - Change next.config.js to:
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
webpack: (config, { dev, isServer }) => {
if (!dev && !isServer) {
// Replace React with Preact only in client production build
Object.assign(config.resolve.alias, {
'react/jsx-runtime.js': 'preact/compat/jsx-runtime',
react: 'preact/compat',
'react-dom/test-utils': 'preact/test-utils',
'react-dom': 'preact/compat',
});
}
return config;
},
};
module.exports = nextConfig;- Run:
yarn build
Expected behavior
Build should succeed without errors.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels