@nx/next 0.0.0-pr-29314-e664f92 → 0.0.0-pr-29286-735af1e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2017-2024 Narwhal Technologies Inc.
3
+ Copyright (c) 2017-2025 Narwhal Technologies Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/next",
3
- "version": "0.0.0-pr-29314-e664f92",
3
+ "version": "0.0.0-pr-29286-735af1e",
4
4
  "private": false,
5
5
  "description": "The Next.js plugin for Nx contains executors and generators for managing Next.js applications and libraries within an Nx workspace. It provides:\n\n\n- Scaffolding for creating, building, serving, linting, and testing Next.js applications.\n\n- Integration with building, serving, and exporting a Next.js application.\n\n- Integration with React libraries within the workspace. \n\nWhen using Next.js in Nx, you get the out-of-the-box support for TypeScript, Playwright, Cypress, and Jest. No need to configure anything: watch mode, source maps, and typings just work.",
6
6
  "repository": {
@@ -35,20 +35,20 @@
35
35
  "next": ">=14.0.0"
36
36
  },
37
37
  "dependencies": {
38
- "@nx/devkit": "0.0.0-pr-29314-e664f92",
38
+ "@nx/devkit": "0.0.0-pr-29286-735af1e",
39
39
  "@babel/plugin-proposal-decorators": "^7.22.7",
40
- "@svgr/webpack": "^8.0.1",
40
+ "@svgr/webpack": "^8.1.0",
41
41
  "copy-webpack-plugin": "^10.2.4",
42
42
  "file-loader": "^6.2.0",
43
43
  "ignore": "^5.0.4",
44
44
  "semver": "^7.5.3",
45
45
  "tslib": "^2.3.0",
46
46
  "webpack-merge": "^5.8.0",
47
- "@nx/js": "0.0.0-pr-29314-e664f92",
48
- "@nx/eslint": "0.0.0-pr-29314-e664f92",
49
- "@nx/react": "0.0.0-pr-29314-e664f92",
50
- "@nx/web": "0.0.0-pr-29314-e664f92",
51
- "@nx/webpack": "0.0.0-pr-29314-e664f92",
47
+ "@nx/js": "0.0.0-pr-29286-735af1e",
48
+ "@nx/eslint": "0.0.0-pr-29286-735af1e",
49
+ "@nx/react": "0.0.0-pr-29286-735af1e",
50
+ "@nx/web": "0.0.0-pr-29286-735af1e",
51
+ "@nx/webpack": "0.0.0-pr-29286-735af1e",
52
52
  "@phenomnomnominal/tsquery": "~5.0.1"
53
53
  },
54
54
  "publishConfig": {
@@ -6,6 +6,7 @@ const devkit_1 = require("@nx/devkit");
6
6
  const js_1 = require("@nx/js");
7
7
  const react_1 = require("@nx/react");
8
8
  const versions_1 = require("@nx/react/src/utils/versions");
9
+ const version_utils_1 = require("@nx/react/src/utils/version-utils");
9
10
  const normalize_options_1 = require("./lib/normalize-options");
10
11
  const add_e2e_1 = require("./lib/add-e2e");
11
12
  const add_jest_1 = require("./lib/add-jest");
@@ -74,9 +75,10 @@ async function applicationGeneratorInternal(host, schema) {
74
75
  });
75
76
  }
76
77
  if (!options.skipPackageJson) {
78
+ const reactVersions = await (0, version_utils_1.getReactDependenciesVersionsToInstall)(host);
77
79
  const devDependencies = {
78
- '@types/react': versions_1.typesReactVersion,
79
- '@types/react-dom': versions_1.typesReactDomVersion,
80
+ '@types/react': reactVersions['@types/react'],
81
+ '@types/react-dom': reactVersions['@types/react-dom'],
80
82
  };
81
83
  if (options.unitTestRunner && options.unitTestRunner !== 'none') {
82
84
  devDependencies['@testing-library/react'] = versions_1.testingLibraryReactVersion;
@@ -90,6 +92,11 @@ async function applicationGeneratorInternal(host, schema) {
90
92
  }, options.linter === 'eslint'
91
93
  ? ['.next', 'eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
92
94
  : ['.next'], options.src ? 'src' : '.');
95
+ // If we are using the new TS solution
96
+ // We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
97
+ if (options.useTsSolution) {
98
+ (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.appProjectRoot);
99
+ }
93
100
  if (!options.skipFormat) {
94
101
  await (0, devkit_1.formatFiles)(host);
95
102
  }
@@ -2,4 +2,4 @@
2
2
  /// <reference types="next/image-types/global" />
3
3
 
4
4
  // NOTE: This file should not be edited
5
- // see https://nextjs.org/docs/<%- appDirType %>/building-your-application/configuring/typescript for more information.
5
+ // see https://nextjs.org/docs/<%- appDirType %>/api-reference/config/typescript for more information.
@@ -5,6 +5,7 @@
5
5
  <% if (style === '@emotion/styled') { %>"jsxImportSource": "@emotion/react",<% } %>
6
6
  "strict": true,
7
7
  "noEmit": true,
8
+ "emitDeclarationOnly": false,
8
9
  "esModuleInterop": true,
9
10
  "module": "esnext",
10
11
  "moduleResolution": "bundler",
@@ -144,11 +144,11 @@ async function getNextE2EWebServerInfo(tree, projectName, configFilePath, isPlug
144
144
  return (0, e2e_web_server_info_utils_1.getE2EWebServerInfo)(tree, projectName, {
145
145
  plugin: '@nx/next/plugin',
146
146
  serveTargetName: 'devTargetName',
147
- serveStaticTargetName: 'serveStaticTargetName',
147
+ serveStaticTargetName: 'startTargetName',
148
148
  configFilePath,
149
149
  }, {
150
150
  defaultServeTargetName: defaultServeTarget,
151
- defaultServeStaticTargetName: 'serve-static',
151
+ defaultServeStaticTargetName: 'start',
152
152
  defaultE2EWebServerAddress: `http://127.0.0.1:${e2ePort}`,
153
153
  defaultE2ECiBaseUrl: `http://localhost:${e2ePort}`,
154
154
  defaultE2EPort: e2ePort,
@@ -41,6 +41,10 @@
41
41
  "value": "less",
42
42
  "label": "LESS [ https://lesscss.org ]"
43
43
  },
44
+ {
45
+ "value": "tailwind",
46
+ "label": "tailwind [ https://tailwindcss.com/ ]"
47
+ },
44
48
  {
45
49
  "value": "styled-components",
46
50
  "label": "styled-components [ https://styled-components.com ]"
@@ -4,18 +4,21 @@ exports.nextInitGenerator = nextInitGenerator;
4
4
  exports.nextInitGeneratorInternal = nextInitGeneratorInternal;
5
5
  const devkit_1 = require("@nx/devkit");
6
6
  const add_plugin_1 = require("@nx/devkit/src/utils/add-plugin");
7
- const versions_1 = require("@nx/react/src/utils/versions");
7
+ const version_utils_1 = require("@nx/react/src/utils/version-utils");
8
8
  const add_gitignore_entry_1 = require("../../utils/add-gitignore-entry");
9
- const versions_2 = require("../../utils/versions");
10
- function updateDependencies(host, schema) {
9
+ const versions_1 = require("../../utils/versions");
10
+ const version_utils_2 = require("../../utils/version-utils");
11
+ async function updateDependencies(host, schema) {
11
12
  const tasks = [];
12
13
  tasks.push((0, devkit_1.removeDependenciesFromPackageJson)(host, ['@nx/next'], []));
14
+ const versions = await (0, version_utils_2.getNextDependenciesVersionsToInstall)(host, await (0, version_utils_1.isReact18)(host));
15
+ const reactVersions = await (0, version_utils_1.getReactDependenciesVersionsToInstall)(host);
13
16
  tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, {
14
- next: versions_2.nextVersion,
15
- react: versions_1.reactVersion,
16
- 'react-dom': versions_1.reactDomVersion,
17
+ next: versions.next,
18
+ react: reactVersions.react,
19
+ 'react-dom': reactVersions['react-dom'],
17
20
  }, {
18
- '@nx/next': versions_2.nxVersion,
21
+ '@nx/next': versions_1.nxVersion,
19
22
  }, undefined, schema.keepExistingVersions));
20
23
  return (0, devkit_1.runTasksInSerial)(...tasks);
21
24
  }
@@ -43,7 +46,7 @@ async function nextInitGeneratorInternal(host, schema) {
43
46
  (0, add_gitignore_entry_1.addGitIgnoreEntry)(host);
44
47
  let installTask = () => { };
45
48
  if (!schema.skipPackageJson) {
46
- installTask = updateDependencies(host, schema);
49
+ installTask = await updateDependencies(host, schema);
47
50
  }
48
51
  return installTask;
49
52
  }
@@ -3,5 +3,6 @@ import { Schema } from '../schema';
3
3
  export interface NormalizedSchema extends Schema {
4
4
  importPath: string;
5
5
  projectRoot: string;
6
+ isUsingTsSolutionConfig: boolean;
6
7
  }
7
8
  export declare function normalizeOptions(host: Tree, options: Schema): Promise<NormalizedSchema>;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeOptions = normalizeOptions;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
6
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
6
7
  async function normalizeOptions(host, options) {
7
8
  await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'library');
8
9
  const { projectRoot, importPath } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
@@ -19,5 +20,6 @@ async function normalizeOptions(host, options) {
19
20
  ...options,
20
21
  importPath,
21
22
  projectRoot,
23
+ isUsingTsSolutionConfig: (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host),
22
24
  };
23
25
  }
@@ -60,7 +60,10 @@ async function libraryGeneratorInternal(host, rawOptions) {
60
60
  return <h1>Hello Server</h1>
61
61
  }
62
62
  `);
63
- (0, js_1.addTsConfigPath)(host, `${options.importPath}/server`, [serverEntryPath]);
63
+ const isTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
64
+ if (!options.skipTsConfig && !isTsSolutionSetup) {
65
+ (0, js_1.addTsConfigPath)(host, `${options.importPath}/server`, [serverEntryPath]);
66
+ }
64
67
  (0, devkit_1.updateJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.json'), (json) => {
65
68
  if (options.style === '@emotion/styled') {
66
69
  json.compilerOptions.jsxImportSource = '@emotion/react';
@@ -90,6 +93,9 @@ async function libraryGeneratorInternal(host, rawOptions) {
90
93
  }, options.linter === 'eslint'
91
94
  ? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
92
95
  : undefined);
96
+ if (options.isUsingTsSolutionConfig) {
97
+ (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.projectRoot);
98
+ }
93
99
  if (!options.skipFormat) {
94
100
  await (0, devkit_1.formatFiles)(host);
95
101
  }
@@ -43,6 +43,10 @@
43
43
  "value": "less",
44
44
  "label": "LESS [ https://lesscss.org ]"
45
45
  },
46
+ {
47
+ "value": "tailwind",
48
+ "label": "tailwind [ https://tailwindcss.com/ ]"
49
+ },
46
50
  {
47
51
  "value": "styled-components",
48
52
  "label": "styled-components [ https://styled-components.com ]"
@@ -3,6 +3,9 @@ export interface NextPluginOptions {
3
3
  buildTargetName?: string;
4
4
  devTargetName?: string;
5
5
  startTargetName?: string;
6
+ /**
7
+ * @deprecated Use `startTargetName` instead.
8
+ */
6
9
  serveStaticTargetName?: string;
7
10
  }
8
11
  /**
@@ -84,8 +84,9 @@ async function buildNextTargets(nextConfigPath, projectRoot, options, context) {
84
84
  const targets = {};
85
85
  targets[options.buildTargetName] = await getBuildTargetConfig(namedInputs, projectRoot, nextConfig);
86
86
  targets[options.devTargetName] = getDevTargetConfig(projectRoot);
87
- targets[options.startTargetName] = getStartTargetConfig(options, projectRoot);
88
- targets[options.serveStaticTargetName] = getStaticServeTargetConfig(options);
87
+ const startTarget = getStartTargetConfig(options, projectRoot);
88
+ targets[options.startTargetName] = startTarget;
89
+ targets[options.serveStaticTargetName] = startTarget;
89
90
  return targets;
90
91
  }
91
92
  async function getBuildTargetConfig(namedInputs, projectRoot, nextConfig) {
@@ -0,0 +1,9 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ type NextDependenciesVersions = {
3
+ next: string;
4
+ };
5
+ export declare function getNextDependenciesVersionsToInstall(tree: Tree, isReact18?: boolean): Promise<NextDependenciesVersions>;
6
+ export declare function isNext14(tree: Tree): Promise<boolean>;
7
+ export declare function getInstalledNextVersion(tree: Tree): string;
8
+ export declare function getInstalledNextVersionFromGraph(): Promise<string>;
9
+ export {};
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getNextDependenciesVersionsToInstall = getNextDependenciesVersionsToInstall;
4
+ exports.isNext14 = isNext14;
5
+ exports.getInstalledNextVersion = getInstalledNextVersion;
6
+ exports.getInstalledNextVersionFromGraph = getInstalledNextVersionFromGraph;
7
+ const devkit_1 = require("@nx/devkit");
8
+ const semver_1 = require("semver");
9
+ const versions_1 = require("./versions");
10
+ async function getNextDependenciesVersionsToInstall(tree, isReact18 = false) {
11
+ if (await isNext14(tree)) {
12
+ return {
13
+ next: versions_1.next14Version,
14
+ };
15
+ }
16
+ else {
17
+ return {
18
+ next: versions_1.nextVersion,
19
+ };
20
+ }
21
+ }
22
+ async function isNext14(tree) {
23
+ let installedNextVersion = await getInstalledNextVersionFromGraph();
24
+ if (!installedNextVersion) {
25
+ installedNextVersion = getInstalledNextVersion(tree);
26
+ }
27
+ return (0, semver_1.major)(installedNextVersion) === 14;
28
+ }
29
+ function getInstalledNextVersion(tree) {
30
+ const pkgJson = (0, devkit_1.readJson)(tree, 'package.json');
31
+ const installedNextVersion = pkgJson.dependencies && pkgJson.dependencies['next'];
32
+ if (!installedNextVersion ||
33
+ installedNextVersion === 'latest' ||
34
+ installedNextVersion === 'next') {
35
+ return (0, semver_1.clean)(versions_1.nextVersion) ?? (0, semver_1.coerce)(versions_1.nextVersion).version;
36
+ }
37
+ return (0, semver_1.clean)(installedNextVersion) ?? (0, semver_1.coerce)(installedNextVersion).version;
38
+ }
39
+ async function getInstalledNextVersionFromGraph() {
40
+ const graph = await (0, devkit_1.createProjectGraphAsync)();
41
+ const nextDep = graph.externalNodes?.['npm:next'];
42
+ if (!nextDep) {
43
+ return undefined;
44
+ }
45
+ return (0, semver_1.clean)(nextDep.data.version) ?? (0, semver_1.coerce)(nextDep.data.version).version;
46
+ }
@@ -1,5 +1,6 @@
1
1
  export declare const nxVersion: any;
2
- export declare const nextVersion = "14.2.16";
2
+ export declare const nextVersion = "~15.1.4";
3
+ export declare const next14Version = "~14.2.16";
3
4
  export declare const eslintConfigNextVersion = "14.2.16";
4
5
  export declare const sassVersion = "1.62.1";
5
6
  export declare const lessLoader = "11.1.0";
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tsLibVersion = exports.babelPluginStyledComponentsVersion = exports.emotionServerVersion = exports.lessLoader = exports.sassVersion = exports.eslintConfigNextVersion = exports.nextVersion = exports.nxVersion = void 0;
3
+ exports.tsLibVersion = exports.babelPluginStyledComponentsVersion = exports.emotionServerVersion = exports.lessLoader = exports.sassVersion = exports.eslintConfigNextVersion = exports.next14Version = exports.nextVersion = exports.nxVersion = void 0;
4
4
  exports.nxVersion = require('../../package.json').version;
5
- exports.nextVersion = '14.2.16';
5
+ exports.nextVersion = '~15.1.4';
6
+ exports.next14Version = '~14.2.16';
6
7
  exports.eslintConfigNextVersion = '14.2.16';
7
8
  exports.sassVersion = '1.62.1';
8
9
  exports.lessLoader = '11.1.0';