fix(nextjs): show a warning when user uses emotion with appDir layout (#16636)

This commit is contained in:
Jack Hsu 2023-04-28 12:41:09 -04:00 committed by GitHub
parent 920352215c
commit a7c4009d28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -18,10 +18,13 @@ import { addStyleDependencies } from '../../utils/styles';
import { addLinting } from './lib/add-linting';
import { customServerGenerator } from '../custom-server/custom-server';
import { updateCypressTsConfig } from './lib/update-cypress-tsconfig';
import { showPossibleWarnings } from './lib/show-possible-warnings';
export async function applicationGenerator(host: Tree, schema: Schema) {
const options = normalizeOptions(host, schema);
showPossibleWarnings(host, options);
const nextTask = await nextInitGenerator(host, {
...options,
skipFormat: true,

View File

@ -0,0 +1,10 @@
import { logger, Tree } from '@nx/devkit';
import { NormalizedSchema } from './normalize-options';
export function showPossibleWarnings(tree: Tree, options: NormalizedSchema) {
if (options.style === '@emotion/styled' && options.appDir) {
logger.warn(
`Emotion may not work with the experimental appDir layout. See: https://beta.nextjs.org/docs/styling/css-in-js`
);
}
}