@nx/next 0.0.0-pr-28808-ca32248 → 0.0.0-pr-28808-bceb02f

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": "0.0.0-pr-28808-ca32248",
3
+ "version": "0.0.0-pr-28808-bceb02f",
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,7 +35,7 @@
35
35
  "next": ">=14.0.0"
36
36
  },
37
37
  "dependencies": {
38
- "@nx/devkit": "0.0.0-pr-28808-ca32248",
38
+ "@nx/devkit": "0.0.0-pr-28808-bceb02f",
39
39
  "@babel/plugin-proposal-decorators": "^7.22.7",
40
40
  "@svgr/webpack": "^8.0.1",
41
41
  "copy-webpack-plugin": "^10.2.4",
@@ -44,11 +44,11 @@
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-28808-ca32248",
48
- "@nx/eslint": "0.0.0-pr-28808-ca32248",
49
- "@nx/react": "0.0.0-pr-28808-ca32248",
50
- "@nx/web": "0.0.0-pr-28808-ca32248",
51
- "@nx/webpack": "0.0.0-pr-28808-ca32248",
47
+ "@nx/js": "0.0.0-pr-28808-bceb02f",
48
+ "@nx/eslint": "0.0.0-pr-28808-bceb02f",
49
+ "@nx/react": "0.0.0-pr-28808-bceb02f",
50
+ "@nx/web": "0.0.0-pr-28808-bceb02f",
51
+ "@nx/webpack": "0.0.0-pr-28808-bceb02f",
52
52
  "@phenomnomnominal/tsquery": "~5.0.1"
53
53
  },
54
54
  "publishConfig": {
@@ -37,6 +37,7 @@ async function applicationGeneratorInternal(host, schema) {
37
37
  skipPackageJson: options.skipPackageJson,
38
38
  skipFormat: true,
39
39
  addTsPlugin: schema.useTsSolution,
40
+ formatter: schema.formatter,
40
41
  });
41
42
  tasks.push(jsInitTask);
42
43
  const nextTask = await (0, init_1.nextInitGenerator)(host, {
@@ -8,6 +8,8 @@ const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
8
8
  const versions_1 = require("../../../utils/versions");
9
9
  const flat_config_1 = require("@nx/eslint/src/utils/flat-config");
10
10
  async function addLinting(host, options) {
11
+ if (options.linter !== 'eslint')
12
+ return () => { };
11
13
  const tasks = [];
12
14
  tasks.push(await (0, eslint_1.lintProjectGenerator)(host, {
13
15
  linter: options.linter,
@@ -21,4 +21,5 @@ export interface Schema {
21
21
  rootProject?: boolean;
22
22
  addPlugin?: boolean;
23
23
  useTsSolution?: boolean;
24
+ formatter?: 'prettier' | 'none';
24
25
  }
@@ -69,8 +69,8 @@
69
69
  "linter": {
70
70
  "description": "The tool to use for running lint checks.",
71
71
  "type": "string",
72
- "enum": ["eslint"],
73
- "default": "none",
72
+ "enum": ["eslint", "none"],
73
+ "default": "eslint",
74
74
  "x-prompt": "Which linter would you like to use?",
75
75
  "x-priority": "important"
76
76
  },
@@ -84,7 +84,7 @@
84
84
  "type": "string",
85
85
  "enum": ["jest", "none"],
86
86
  "description": "Test runner to use for unit tests.",
87
- "default": "none",
87
+ "default": "jest",
88
88
  "x-priority": "important"
89
89
  },
90
90
  "e2eTestRunner": {
@@ -92,7 +92,7 @@
92
92
  "enum": ["playwright", "cypress", "none"],
93
93
  "description": "Test runner to use for end to end (E2E) tests.",
94
94
  "x-prompt": "Which E2E test runner would you like to use?",
95
- "default": "none"
95
+ "default": "playwright"
96
96
  },
97
97
  "tags": {
98
98
  "type": "string",
@@ -1,3 +1,3 @@
1
- import type { Tree } from '@nx/devkit';
1
+ import { Tree } from '@nx/devkit';
2
2
  import { CustomServerSchema } from './schema';
3
3
  export declare function customServerGenerator(host: Tree, options: CustomServerSchema): Promise<() => void>;
@@ -2,18 +2,20 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.customServerGenerator = customServerGenerator;
4
4
  const devkit_1 = require("@nx/devkit");
5
+ const devkit_2 = require("@nx/devkit");
5
6
  const path_1 = require("path");
6
7
  const add_swc_to_custom_server_1 = require("../../utils/add-swc-to-custom-server");
8
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
7
9
  async function customServerGenerator(host, options) {
8
- const project = (0, devkit_1.readProjectConfiguration)(host, options.project);
9
- const nxJson = (0, devkit_1.readNxJson)(host);
10
+ const project = (0, devkit_2.readProjectConfiguration)(host, options.project);
11
+ const nxJson = (0, devkit_2.readNxJson)(host);
10
12
  const hasPlugin = nxJson.plugins?.some((p) => typeof p === 'string'
11
13
  ? p === '@nx/next/plugin'
12
14
  : p.plugin === '@nx/next/plugin');
13
15
  if (project.targets?.build?.executor !== '@nx/next:build' &&
14
16
  project.targets?.build?.executor !== '@nrwl/next:build' &&
15
17
  !hasPlugin) {
16
- devkit_1.logger.error(`Project ${options.project} is not a Next.js project. Did you generate it with "nx g @nx/next:app"?`);
18
+ devkit_2.logger.error(`Project ${options.project} is not a Next.js project. Did you generate it with "nx g @nx/next:app"?`);
17
19
  return;
18
20
  }
19
21
  // In Nx 18 next artifacts are inside the project root .next/ & dist/ (for custom server)
@@ -26,23 +28,28 @@ async function customServerGenerator(host, options) {
26
28
  !project.targets?.build?.configurations?.development ||
27
29
  !project.targets?.build?.configurations?.production) &&
28
30
  !hasPlugin) {
29
- devkit_1.logger.error(`Project ${options.project} has invalid config. Did you generate it with "nx g @nx/next:app"?`);
31
+ devkit_2.logger.error(`Project ${options.project} has invalid config. Did you generate it with "nx g @nx/next:app"?`);
30
32
  return;
31
33
  }
32
34
  if (project.targets?.['build-custom-server'] ||
33
35
  project.targets?.['serve-custom-server']) {
34
- devkit_1.logger.warn(`Project ${options.project} has custom server targets already: build-custom-server, serve-custom-server. Remove these targets from project and try again.`);
36
+ devkit_2.logger.warn(`Project ${options.project} has custom server targets already: build-custom-server, serve-custom-server. Remove these targets from project and try again.`);
35
37
  return;
36
38
  }
37
39
  // In Nx 18 next artifacts are inside the project root .next/ & dist/ (for custom server)
38
40
  // So we need ensure the mapping is correct from dist to the project root
39
- const projectPathFromDist = `../../${(0, devkit_1.offsetFromRoot)(project.root)}${project.root}`;
40
- (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, 'files'), project.root, {
41
+ const projectPathFromDist = `../../${(0, devkit_2.offsetFromRoot)(project.root)}${project.root}`;
42
+ const offset = (0, devkit_2.offsetFromRoot)(project.root);
43
+ const isTsSolution = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
44
+ (0, devkit_2.generateFiles)(host, (0, path_1.join)(__dirname, 'files'), project.root, {
41
45
  ...options,
42
46
  hasPlugin,
43
47
  projectPathFromDist,
44
- offsetFromRoot: (0, devkit_1.offsetFromRoot)(project.root),
48
+ offsetFromRoot: offset,
45
49
  projectRoot: project.root,
50
+ baseTsConfigPath: isTsSolution
51
+ ? (0, devkit_1.joinPathFragments)(offset, 'tsconfig.base.json')
52
+ : './tsconfig.json',
46
53
  tmpl: '',
47
54
  });
48
55
  if (!hasPlugin) {
@@ -86,8 +93,8 @@ async function customServerGenerator(host, options) {
86
93
  },
87
94
  },
88
95
  };
89
- (0, devkit_1.updateProjectConfiguration)(host, options.project, project);
90
- (0, devkit_1.updateJson)(host, 'nx.json', (json) => {
96
+ (0, devkit_2.updateProjectConfiguration)(host, options.project, project);
97
+ (0, devkit_2.updateJson)(host, 'nx.json', (json) => {
91
98
  if (!json.tasksRunnerOptions?.default?.options?.cacheableOperations?.includes('build-custom-server') &&
92
99
  json.tasksRunnerOptions?.default?.options?.cacheableOperations) {
93
100
  json.tasksRunnerOptions.default.options.cacheableOperations.push('build-custom-server');
@@ -1,7 +1,8 @@
1
1
  {
2
- "extends": "./tsconfig.json",
2
+ "extends": "<%= baseTsConfigPath %>",
3
3
  "compilerOptions": {
4
- "module": "commonjs",
4
+ "module": "nodenext",
5
+ "moduleResolution": "nodenext",
5
6
  "noEmit": false,
6
7
  "incremental": true,
7
8
  <% if(hasPlugin && compiler === 'tsc') { %>
@@ -65,8 +65,8 @@
65
65
  "linter": {
66
66
  "description": "The tool to use for running lint checks.",
67
67
  "type": "string",
68
- "enum": ["eslint"],
69
- "default": "none",
68
+ "enum": ["eslint", "none"],
69
+ "default": "eslint",
70
70
  "x-prompt": "Which linter would you like to use?",
71
71
  "x-priority": "important"
72
72
  },
@@ -74,7 +74,7 @@
74
74
  "type": "string",
75
75
  "enum": ["vitest", "jest", "none"],
76
76
  "description": "Test runner to use for unit tests.",
77
- "default": "none",
77
+ "default": "vitest",
78
78
  "x-priority": "important"
79
79
  },
80
80
  "tags": {