Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pigment][next] Warn about unsupported turbo mode in Next.js #41445

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions packages/pigment-css-nextjs-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,16 @@ const extractionFile = path.join(
'zero-virtual.css',
);

export function withPigment(nextConfig: NextConfig, pigmentConfig: PigmentOptions) {
const { babelOptions, asyncResolve, ...rest } = pigmentConfig;
export function withPigment(nextConfig: NextConfig, pigmentConfig?: PigmentOptions) {
const { babelOptions = {}, asyncResolve, ...rest } = pigmentConfig ?? {};
if (process.env.TURBOPACK === '1') {
Copy link
Member

@siriwatknp siriwatknp Mar 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a link to where TURBOPACK is coming from? Would be nice to have a comment about this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's undocumented. I had to go through next.js code to find it.

// eslint-disable-next-line no-console
console.log(
`\x1B[33m${process.env.PACKAGE_NAME}: Turbo mode is not supported yet. Please disable it by removing the "--turbo" flag from your "next dev" command to use Pigment CSS.\x1B[39m`,
);
return nextConfig;
}

const webpack: Exclude<NextConfig['webpack'], undefined> = (config, context) => {
const { dir, dev, isServer, config: resolvedNextConfig } = context;

Expand Down Expand Up @@ -73,7 +81,7 @@ export function withPigment(nextConfig: NextConfig, pigmentConfig: PigmentOption
}
config.ignoreWarnings = config.ignoreWarnings ?? [];
config.ignoreWarnings.push({
module: /(zero-virtual\.css)|(runtime\/styles\.css)/,
module: /(zero-virtual\.css)|(react\/styles\.css)/,
});
return config;
};
Expand Down
2 changes: 1 addition & 1 deletion packages/pigment-css-react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ All of the components that you create are also available as CSS selectors. For e

```jsx
const Wrapper = styled.div({
[`& .${Heading}`]: {
[`& ${Heading}`]: {
color: 'blue',
},
});
Expand Down
4 changes: 0 additions & 4 deletions packages/pigment-css-react/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Options, defineConfig } from 'tsup';
import config from '../../tsup.config';
import packageJson from './package.json';

const processors = ['styled', 'sx', 'keyframes', 'generateAtomics', 'css', 'createUseThemeProps'];
const external = ['react', 'react-is', 'prop-types'];
Expand All @@ -9,9 +8,6 @@ const baseConfig: Options = {
...(config as Options),
tsconfig: './tsconfig.build.json',
external,
env: {
PACKAGE_NAME: packageJson.name,
},
};

export default defineConfig([
Expand Down
3 changes: 3 additions & 0 deletions tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@ export default defineConfig({
banner: {
js: licenseText,
},
env: {
PACKAGE_NAME: pkgJson.name,
},
});
Loading