Skip to content

Commit

Permalink
[nextjs] Move the import startsWith next check at end (#228)
Browse files Browse the repository at this point in the history
Co-authored-by: Brijesh Bittu <brijesh42@gmail.com>
  • Loading branch information
brijeshb42 and Brijesh Bittu committed Sep 11, 2024
1 parent 445c9ce commit e1c587d
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions packages/pigment-css-nextjs-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,7 @@ export function withPigment(nextConfig: NextConfig, pigmentConfig?: PigmentOptio
if (what.startsWith('__barrel_optimize__')) {
return require.resolve('../next-font');
}
// Need to point to the react from node_modules during eval time.
// Otherwise, next makes it point to its own version of react that
// has a lot of RSC specific logic which is not actually needed.
if (what.startsWith('@babel') || what.startsWith('react') || what.startsWith('next')) {
return require.resolve(what);
}
if (what === 'next/image') {
if (what === 'next/image' || what === 'next/link') {
return require.resolve('../next-image');
}
if (what.startsWith('next/font')) {
Expand All @@ -76,6 +70,17 @@ export function withPigment(nextConfig: NextConfig, pigmentConfig?: PigmentOptio
if (what.startsWith('@emotion/styled') || what.startsWith('styled-components')) {
return require.resolve('../third-party-styled');
}
// Need to point to the react from node_modules during eval time.
// Otherwise, next makes it point to its own version of react that
// has a lot of RSC specific logic which is not actually needed.
if (
what === 'react' ||
what.startsWith('react-dom/') ||
what.startsWith('@babel/') ||
what.startsWith('next/')
) {
return require.resolve(what);
}
if (asyncResolve) {
return asyncResolve(what, importer, stack);
}
Expand Down

0 comments on commit e1c587d

Please sign in to comment.