Skip to content

Commit

Permalink
fix(nextjs): ensure next 14 is installed if react 18
Browse files Browse the repository at this point in the history
  • Loading branch information
Coly010 committed Jan 9, 2025
1 parent ee443c6 commit 735af1e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
10 changes: 8 additions & 2 deletions packages/next/src/generators/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import {
createProjectGraphAsync,
} from '@nx/devkit';
import { addPlugin } from '@nx/devkit/src/utils/add-plugin';
import { getReactDependenciesVersionsToInstall } from '@nx/react/src/utils/version-utils';
import {
getReactDependenciesVersionsToInstall,
isReact18,
} from '@nx/react/src/utils/version-utils';
import { addGitIgnoreEntry } from '../../utils/add-gitignore-entry';
import { nxVersion } from '../../utils/versions';
import { getNextDependenciesVersionsToInstall } from '../../utils/version-utils';
Expand All @@ -19,7 +22,10 @@ async function updateDependencies(host: Tree, schema: InitSchema) {

tasks.push(removeDependenciesFromPackageJson(host, ['@nx/next'], []));

const versions = await getNextDependenciesVersionsToInstall(host);
const versions = await getNextDependenciesVersionsToInstall(
host,
await isReact18(host)
);
const reactVersions = await getReactDependenciesVersionsToInstall(host);

tasks.push(
Expand Down
3 changes: 2 additions & 1 deletion packages/next/src/utils/version-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ type NextDependenciesVersions = {
};

export async function getNextDependenciesVersionsToInstall(
tree: Tree
tree: Tree,
isReact18 = false
): Promise<NextDependenciesVersions> {
if (await isNext14(tree)) {
return {
Expand Down

0 comments on commit 735af1e

Please sign in to comment.