@nx/next 17.3.0-beta.2 → 17.3.0-beta.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/next",
3
- "version": "17.3.0-beta.2",
3
+ "version": "17.3.0-beta.4",
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, Cypress, and Jest. No need to configure anything: watch mode, source maps, and typings just work.",
6
6
  "repository": {
@@ -34,7 +34,7 @@
34
34
  "next": ">=13.0.0"
35
35
  },
36
36
  "dependencies": {
37
- "@nx/devkit": "17.3.0-beta.2",
37
+ "@nx/devkit": "17.3.0-beta.4",
38
38
  "@babel/plugin-proposal-decorators": "^7.22.7",
39
39
  "@svgr/webpack": "^8.0.1",
40
40
  "chalk": "^4.1.0",
@@ -45,12 +45,12 @@
45
45
  "url-loader": "^4.1.1",
46
46
  "tslib": "^2.3.0",
47
47
  "webpack-merge": "^5.8.0",
48
- "@nx/js": "17.3.0-beta.2",
49
- "@nx/eslint": "17.3.0-beta.2",
50
- "@nx/react": "17.3.0-beta.2",
51
- "@nx/web": "17.3.0-beta.2",
52
- "@nx/workspace": "17.3.0-beta.2",
53
- "@nrwl/next": "17.3.0-beta.2"
48
+ "@nx/js": "17.3.0-beta.4",
49
+ "@nx/eslint": "17.3.0-beta.4",
50
+ "@nx/react": "17.3.0-beta.4",
51
+ "@nx/web": "17.3.0-beta.4",
52
+ "@nx/workspace": "17.3.0-beta.4",
53
+ "@nrwl/next": "17.3.0-beta.4"
54
54
  },
55
55
  "publishConfig": {
56
56
  "access": "public"
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.applicationGeneratorInternal = exports.applicationGenerator = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
+ const js_1 = require("@nx/js");
6
+ const versions_1 = require("@nx/react/src/utils/versions");
5
7
  const normalize_options_1 = require("./lib/normalize-options");
6
8
  const add_e2e_1 = require("./lib/add-e2e");
7
9
  const add_jest_1 = require("./lib/add-jest");
@@ -15,6 +17,7 @@ const add_linting_1 = require("./lib/add-linting");
15
17
  const custom_server_1 = require("../custom-server/custom-server");
16
18
  const update_cypress_tsconfig_1 = require("./lib/update-cypress-tsconfig");
17
19
  const show_possible_warnings_1 = require("./lib/show-possible-warnings");
20
+ const versions_2 = require("../../utils/versions");
18
21
  async function applicationGenerator(host, schema) {
19
22
  return await applicationGeneratorInternal(host, {
20
23
  projectNameAndRootFormat: 'derived',
@@ -26,6 +29,12 @@ async function applicationGeneratorInternal(host, schema) {
26
29
  const tasks = [];
27
30
  const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
28
31
  (0, show_possible_warnings_1.showPossibleWarnings)(host, options);
32
+ const jsInitTask = await (0, js_1.initGenerator)(host, {
33
+ js: options.js,
34
+ skipPackageJson: options.skipPackageJson,
35
+ skipFormat: true,
36
+ });
37
+ tasks.push(jsInitTask);
29
38
  const nextTask = await (0, init_1.nextInitGenerator)(host, {
30
39
  ...options,
31
40
  skipFormat: true,
@@ -53,6 +62,16 @@ async function applicationGeneratorInternal(host, schema) {
53
62
  compiler: options.swc ? 'swc' : 'tsc',
54
63
  });
55
64
  }
65
+ if (!options.skipPackageJson) {
66
+ const devDependencies = {
67
+ '@types/react': versions_1.typesReactVersion,
68
+ '@types/react-dom': versions_1.typesReactDomVersion,
69
+ };
70
+ if (schema.unitTestRunner && schema.unitTestRunner !== 'none') {
71
+ devDependencies['@testing-library/react'] = versions_1.testingLibraryReactVersion;
72
+ }
73
+ tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, { tslib: versions_2.tsLibVersion }, devDependencies));
74
+ }
56
75
  if (!options.skipFormat) {
57
76
  await (0, devkit_1.formatFiles)(host);
58
77
  }
@@ -5,8 +5,10 @@ const eslint_1 = require("@nx/eslint");
5
5
  const devkit_1 = require("@nx/devkit");
6
6
  const lint_1 = require("@nx/react/src/utils/lint");
7
7
  const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
8
+ const versions_1 = require("../../../utils/versions");
8
9
  async function addLinting(host, options) {
9
- const lintTask = await (0, eslint_1.lintProjectGenerator)(host, {
10
+ const tasks = [];
11
+ tasks.push(await (0, eslint_1.lintProjectGenerator)(host, {
10
12
  linter: options.linter,
11
13
  project: options.projectName,
12
14
  tsConfigPaths: [
@@ -16,7 +18,7 @@ async function addLinting(host, options) {
16
18
  skipFormat: true,
17
19
  rootProject: options.rootProject,
18
20
  setParserOptionsProject: options.setParserOptionsProject,
19
- });
21
+ }));
20
22
  if (options.linter === eslint_1.Linter.EsLint && (0, eslint_file_1.isEslintConfigSupported)(host)) {
21
23
  (0, eslint_file_1.addExtendsToLintConfig)(host, options.appProjectRoot, [
22
24
  'plugin:@nx/react-typescript',
@@ -48,7 +50,12 @@ async function addLinting(host, options) {
48
50
  }
49
51
  (0, eslint_file_1.addIgnoresToLintConfig)(host, options.appProjectRoot, ['.next/**/*']);
50
52
  }
51
- const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, lint_1.extraEslintDependencies.dependencies, lint_1.extraEslintDependencies.devDependencies);
52
- return (0, devkit_1.runTasksInSerial)(lintTask, installTask);
53
+ if (!options.skipPackageJson) {
54
+ tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, lint_1.extraEslintDependencies.dependencies, {
55
+ ...lint_1.extraEslintDependencies.devDependencies,
56
+ 'eslint-config-next': versions_1.eslintConfigNextVersion,
57
+ }));
58
+ }
59
+ return (0, devkit_1.runTasksInSerial)(...tasks);
53
60
  }
54
61
  exports.addLinting = addLinting;
@@ -64,7 +64,6 @@ function createApplicationFiles(host, options) {
64
64
  ...new Set([
65
65
  ...(updatedJson.exclude || []),
66
66
  ...(appJSON.exclude || []),
67
- '**e2e/**/*',
68
67
  `dist/${options.projectName}/**/*`,
69
68
  ]),
70
69
  ],
@@ -15,11 +15,9 @@ async function cypressComponentConfiguration(tree, options) {
15
15
  jsx: true,
16
16
  }));
17
17
  const { webpackInitGenerator } = (0, devkit_1.ensurePackage)('@nx/webpack', versions_1.nxVersion);
18
- tasks.push(await webpackInitGenerator(tree, {
19
- compiler: 'swc',
20
- uiFramework: 'react',
21
- skipFormat: true,
22
- }));
18
+ tasks.push(await webpackInitGenerator(tree, { skipFormat: true }));
19
+ const { ensureDependencies } = await Promise.resolve().then(() => require('@nx/webpack/src/utils/ensure-dependencies'));
20
+ tasks.push(ensureDependencies(tree, { compiler: 'swc', uiFramework: 'react' }));
23
21
  const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
24
22
  projectConfig.targets['component-test'].options = {
25
23
  ...projectConfig.targets['component-test'].options,
@@ -1,4 +1,4 @@
1
- import { GeneratorCallback, Tree } from '@nx/devkit';
2
- import { InitSchema } from './schema';
1
+ import { type GeneratorCallback, type Tree } from '@nx/devkit';
2
+ import type { InitSchema } from './schema';
3
3
  export declare function nextInitGenerator(host: Tree, schema: InitSchema): Promise<GeneratorCallback>;
4
4
  export default nextInitGenerator;
@@ -3,62 +3,31 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.nextInitGenerator = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const versions_1 = require("@nx/react/src/utils/versions");
6
- const init_1 = require("@nx/react/src/generators/init/init");
7
- const js_1 = require("@nx/js");
8
- const versions_2 = require("../../utils/versions");
9
6
  const add_gitignore_entry_1 = require("../../utils/add-gitignore-entry");
7
+ const versions_2 = require("../../utils/versions");
10
8
  const add_plugin_1 = require("./lib/add-plugin");
11
- function updateDependencies(host) {
12
- return (0, devkit_1.addDependenciesToPackageJson)(host, {
9
+ function updateDependencies(host, schema) {
10
+ const tasks = [];
11
+ tasks.push((0, devkit_1.removeDependenciesFromPackageJson)(host, ['@nx/next'], []));
12
+ tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, {
13
13
  next: versions_2.nextVersion,
14
14
  react: versions_1.reactVersion,
15
15
  'react-dom': versions_1.reactDomVersion,
16
- tslib: versions_2.tsLibVersion,
17
16
  }, {
18
17
  '@nx/next': versions_2.nxVersion,
19
- 'eslint-config-next': versions_2.eslintConfigNextVersion,
20
- });
18
+ }));
19
+ return (0, devkit_1.runTasksInSerial)(...tasks);
21
20
  }
22
21
  async function nextInitGenerator(host, schema) {
23
- const tasks = [];
24
- tasks.push(await (0, js_1.initGenerator)(host, {
25
- ...schema,
26
- skipFormat: true,
27
- }));
28
- if (!schema.unitTestRunner || schema.unitTestRunner === 'jest') {
29
- const { jestInitGenerator } = (0, devkit_1.ensurePackage)('@nx/jest', versions_2.nxVersion);
30
- const jestTask = await jestInitGenerator(host, schema);
31
- tasks.push(jestTask);
32
- }
33
- if (schema.e2eTestRunner === 'cypress') {
34
- const { cypressInitGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_2.nxVersion);
35
- const cypressTask = await cypressInitGenerator(host, {});
36
- tasks.push(cypressTask);
37
- }
38
- else if (schema.e2eTestRunner === 'playwright') {
39
- const { initGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', versions_2.nxVersion);
40
- const playwrightTask = await initGenerator(host, {
41
- skipFormat: true,
42
- skipPackageJson: schema.skipPackageJson,
43
- });
44
- tasks.push(playwrightTask);
45
- }
46
- // @ts-ignore
47
- // TODO(jack): remove once the React Playwright PR lands first
48
- const reactTask = await (0, init_1.default)(host, {
49
- ...schema,
50
- skipFormat: true,
51
- });
52
- tasks.push(reactTask);
53
- if (!schema.skipPackageJson) {
54
- const installTask = updateDependencies(host);
55
- tasks.push(installTask);
56
- }
57
- (0, add_gitignore_entry_1.addGitIgnoreEntry)(host);
58
22
  if (process.env.NX_PCV3 === 'true') {
59
23
  (0, add_plugin_1.addPlugin)(host);
60
24
  }
61
- return (0, devkit_1.runTasksInSerial)(...tasks);
25
+ (0, add_gitignore_entry_1.addGitIgnoreEntry)(host);
26
+ let installTask = () => { };
27
+ if (!schema.skipPackageJson) {
28
+ installTask = updateDependencies(host, schema);
29
+ }
30
+ return installTask;
62
31
  }
63
32
  exports.nextInitGenerator = nextInitGenerator;
64
33
  exports.default = nextInitGenerator;
@@ -1,8 +1,4 @@
1
1
  export interface InitSchema {
2
- unitTestRunner?: 'jest' | 'none';
3
- e2eTestRunner?: 'cypress' | 'playwright' | 'none';
4
2
  skipFormat?: boolean;
5
- js?: boolean;
6
3
  skipPackageJson?: boolean;
7
- rootProject?: boolean;
8
4
  }
@@ -6,40 +6,16 @@
6
6
  "description": "Init Next Plugin.",
7
7
  "type": "object",
8
8
  "properties": {
9
- "unitTestRunner": {
10
- "description": "Adds the specified unit test runner.",
11
- "type": "string",
12
- "enum": ["jest", "none"],
13
- "default": "jest"
14
- },
15
- "e2eTestRunner": {
16
- "description": "Adds the specified e2e test runner.",
17
- "type": "string",
18
- "enum": ["cypress", "none"],
19
- "default": "cypress"
20
- },
21
9
  "skipFormat": {
22
10
  "description": "Skip formatting files.",
23
11
  "type": "boolean",
24
12
  "default": false
25
13
  },
26
- "js": {
27
- "type": "boolean",
28
- "default": false,
29
- "description": "Use JavaScript instead of TypeScript"
30
- },
31
14
  "skipPackageJson": {
32
15
  "type": "boolean",
33
16
  "default": false,
34
17
  "description": "Do not add dependencies to `package.json`.",
35
18
  "x-priority": "internal"
36
- },
37
- "rootProject": {
38
- "description": "Create an application at the root of the workspace.",
39
- "type": "boolean",
40
- "default": false,
41
- "hidden": true,
42
- "x-priority": "internal"
43
19
  }
44
20
  },
45
21
  "required": []
@@ -4,8 +4,10 @@ exports.libraryGeneratorInternal = exports.libraryGenerator = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const library_1 = require("@nx/react/src/generators/library/library");
6
6
  const js_1 = require("@nx/js");
7
+ const versions_1 = require("@nx/react/src/utils/versions");
7
8
  const init_1 = require("../init/init");
8
9
  const normalize_options_1 = require("./lib/normalize-options");
10
+ const versions_2 = require("../../utils/versions");
9
11
  async function libraryGenerator(host, rawOptions) {
10
12
  return await libraryGeneratorInternal(host, {
11
13
  projectNameAndRootFormat: 'derived',
@@ -16,9 +18,14 @@ exports.libraryGenerator = libraryGenerator;
16
18
  async function libraryGeneratorInternal(host, rawOptions) {
17
19
  const options = await (0, normalize_options_1.normalizeOptions)(host, rawOptions);
18
20
  const tasks = [];
21
+ const jsInitTask = await (0, js_1.initGenerator)(host, {
22
+ js: options.js,
23
+ skipPackageJson: options.skipPackageJson,
24
+ skipFormat: true,
25
+ });
26
+ tasks.push(jsInitTask);
19
27
  const initTask = await (0, init_1.nextInitGenerator)(host, {
20
28
  ...options,
21
- e2eTestRunner: 'none',
22
29
  skipFormat: true,
23
30
  });
24
31
  tasks.push(initTask);
@@ -28,6 +35,16 @@ async function libraryGeneratorInternal(host, rawOptions) {
28
35
  skipFormat: true,
29
36
  });
30
37
  tasks.push(libTask);
38
+ if (!options.skipPackageJson) {
39
+ const devDependencies = {};
40
+ if (options.linter === 'eslint') {
41
+ devDependencies['eslint-config-next'] = versions_2.eslintConfigNextVersion;
42
+ }
43
+ if (options.unitTestRunner && options.unitTestRunner !== 'none') {
44
+ devDependencies['@testing-library/react'] = versions_1.testingLibraryReactVersion;
45
+ }
46
+ tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, { tslib: versions_2.tsLibVersion }, devDependencies));
47
+ }
31
48
  const indexPath = (0, devkit_1.joinPathFragments)(options.projectRoot, 'src', `index.${options.js ? 'js' : 'ts'}`);
32
49
  const indexContent = host.read(indexPath, 'utf-8');
33
50
  host.write(indexPath, `// Use this file to export React client components (e.g. those with 'use client' directive) or other non-server utilities\n${indexContent}`);