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 10, 2025
1 parent 0c72061 commit d01acef
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/generated/packages/react/generators/application.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"bundler": {
"description": "The bundler to use.",
"type": "string",
"enum": ["vite", "webpack", "rspack", "rsbuild"],
"enum": ["vite", "rsbuild", "rspack", "webpack"],
"x-prompt": "Which bundler do you want to use to build the application?",
"default": "vite",
"x-priority": "important"
Expand Down
2 changes: 1 addition & 1 deletion docs/generated/packages/workspace/generators/preset.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"bundler": {
"description": "The bundler to use for building the application.",
"type": "string",
"enum": ["webpack", "vite", "rspack", "esbuild"],
"enum": ["vite", "rspack", "rsbuild", "esbuild", "webpack"],
"default": "vite"
},
"docker": {
Expand Down
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
2 changes: 1 addition & 1 deletion packages/react/src/generators/application/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"bundler": {
"description": "The bundler to use.",
"type": "string",
"enum": ["vite", "webpack", "rspack", "rsbuild"],
"enum": ["vite", "rsbuild", "rspack", "webpack"],
"x-prompt": "Which bundler do you want to use to build the application?",
"default": "vite",
"x-priority": "important"
Expand Down
2 changes: 1 addition & 1 deletion packages/workspace/src/generators/preset/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface Schema {
standaloneConfig?: boolean;
framework?: string;
packageManager?: PackageManager;
bundler?: 'vite' | 'webpack' | 'rspack' | 'esbuild';
bundler?: 'vite' | 'rsbuild' | 'webpack' | 'rspack' | 'esbuild';
docker?: boolean;
nextAppDir?: boolean;
nextSrcDir?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/workspace/src/generators/preset/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"bundler": {
"description": "The bundler to use for building the application.",
"type": "string",
"enum": ["webpack", "vite", "rspack", "esbuild"],
"enum": ["vite", "rspack", "rsbuild", "esbuild", "webpack"],
"default": "vite"
},
"docker": {
Expand Down

0 comments on commit d01acef

Please sign in to comment.