@nx/next 0.0.0-pr-31222-862e973 → 0.0.0-pr-31313-387cdca

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.
Files changed (83) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/executors.json +0 -6
  4. package/generators.json +2 -2
  5. package/migrations.json +24 -52
  6. package/package.json +11 -13
  7. package/plugin.d.ts +1 -1
  8. package/plugin.js +2 -1
  9. package/plugins/component-testing.js +4 -0
  10. package/plugins/with-nx.d.ts +4 -0
  11. package/plugins/with-nx.js +6 -21
  12. package/src/executors/build/lib/create-next-config-file.js +7 -2
  13. package/src/executors/server/schema.json +1 -0
  14. package/src/executors/server/server.impl.d.ts +1 -1
  15. package/src/executors/server/server.impl.js +1 -1
  16. package/src/generators/application/application.js +32 -6
  17. package/src/generators/application/files/app/page.tsx__tmpl__ +12 -15
  18. package/src/generators/application/files/common/next-env.d.ts__tmpl__ +1 -1
  19. package/src/generators/application/files/common/next.config.js__tmpl__ +9 -15
  20. package/src/generators/application/files/common/specs/__fileName__.spec.tsx__tmpl__ +5 -5
  21. package/src/generators/application/files/common/tsconfig.json__tmpl__ +12 -5
  22. package/src/generators/application/files/pages/__fileName__.tsx__tmpl__ +10 -13
  23. package/src/generators/application/lib/add-e2e.js +54 -53
  24. package/src/generators/application/lib/add-linting.js +4 -1
  25. package/src/generators/application/lib/add-project.js +29 -9
  26. package/src/generators/application/lib/create-application-files.js +6 -4
  27. package/src/generators/application/lib/normalize-options.d.ts +4 -1
  28. package/src/generators/application/lib/normalize-options.js +12 -9
  29. package/src/generators/application/schema.d.ts +6 -4
  30. package/src/generators/application/schema.json +23 -18
  31. package/src/generators/component/component.d.ts +3 -21
  32. package/src/generators/component/component.js +6 -37
  33. package/src/generators/component/schema.json +13 -45
  34. package/src/generators/convert-to-inferred/convert-to-inferred.js +1 -1
  35. package/src/generators/custom-server/custom-server.d.ts +1 -1
  36. package/src/generators/custom-server/custom-server.js +31 -17
  37. package/src/generators/custom-server/files/server/main.ts__tmpl__ +1 -1
  38. package/src/generators/custom-server/files/tsconfig.server.json__tmpl__ +3 -2
  39. package/src/generators/cypress-component-configuration/cypress-component-configuration.js +4 -1
  40. package/src/generators/init/init.js +23 -10
  41. package/src/generators/library/lib/normalize-options.d.ts +1 -0
  42. package/src/generators/library/lib/normalize-options.js +6 -4
  43. package/src/generators/library/library.js +20 -3
  44. package/src/generators/library/schema.d.ts +5 -5
  45. package/src/generators/library/schema.json +39 -26
  46. package/src/generators/page/page.d.ts +0 -1
  47. package/src/generators/page/page.js +33 -54
  48. package/src/generators/page/schema.d.ts +2 -11
  49. package/src/generators/page/schema.json +6 -28
  50. package/src/generators/setup-tailwind/files/postcss.config.js__tmpl__ +15 -0
  51. package/src/generators/setup-tailwind/files/tailwind.config.js__tmpl__ +23 -0
  52. package/src/generators/setup-tailwind/lib/add-tailwind-style-imports.d.ts +3 -0
  53. package/src/generators/setup-tailwind/lib/add-tailwind-style-imports.js +27 -0
  54. package/src/generators/setup-tailwind/lib/update-project.d.ts +3 -0
  55. package/src/generators/setup-tailwind/lib/update-project.js +11 -0
  56. package/src/generators/setup-tailwind/schema.d.ts +6 -0
  57. package/src/generators/setup-tailwind/schema.js +2 -0
  58. package/src/generators/setup-tailwind/schema.json +47 -0
  59. package/src/generators/setup-tailwind/setup-tailwind.d.ts +4 -0
  60. package/src/generators/setup-tailwind/setup-tailwind.js +34 -0
  61. package/src/plugins/plugin.d.ts +14 -1
  62. package/src/plugins/plugin.js +64 -42
  63. package/src/utils/add-swc-to-custom-server.d.ts +1 -1
  64. package/src/utils/add-swc-to-custom-server.js +8 -12
  65. package/src/utils/version-utils.d.ts +9 -0
  66. package/src/utils/version-utils.js +46 -0
  67. package/src/utils/versions.d.ts +3 -2
  68. package/src/utils/versions.js +4 -3
  69. package/tailwind.d.ts +7 -2
  70. package/tailwind.js +39 -4
  71. package/plugins/with-stylus.d.ts +0 -3
  72. package/plugins/with-stylus.js +0 -11
  73. package/src/executors/export/export.impl.d.ts +0 -17
  74. package/src/executors/export/export.impl.js +0 -58
  75. package/src/executors/export/schema.json +0 -30
  76. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +0 -2
  77. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +0 -9
  78. package/src/migrations/update-16-3-0/remove-root-build-option.d.ts +0 -2
  79. package/src/migrations/update-16-3-0/remove-root-build-option.js +0 -17
  80. package/src/migrations/update-16-4-0/update-nx-next-dependency.d.ts +0 -2
  81. package/src/migrations/update-16-4-0/update-nx-next-dependency.js +0 -17
  82. package/src/migrations/update-17-2-7/remove-eslint-rules-patch.d.ts +0 -2
  83. package/src/migrations/update-17-2-7/remove-eslint-rules-patch.js +0 -15
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/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  [![CircleCI](https://circleci.com/gh/nrwl/nx.svg?style=svg)](https://circleci.com/gh/nrwl/nx)
11
11
  [![License](https://img.shields.io/npm/l/@nx/workspace.svg?style=flat-square)]()
12
- [![NPM Version](https://badge.fury.io/js/%40nrwl%2Fworkspace.svg)](https://www.npmjs.com/@nx/workspace)
12
+ [![NPM Version](https://badge.fury.io/js/nx.svg)](https://www.npmjs.com/package/nx)
13
13
  [![Semantic Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)]()
14
14
  [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
15
15
  [![Join the chat at https://gitter.im/nrwl-nx/community](https://badges.gitter.im/nrwl-nx/community.svg)](https://gitter.im/nrwl-nx/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
package/executors.json CHANGED
@@ -9,12 +9,6 @@
9
9
  "implementation": "./src/executors/server/server.impl",
10
10
  "schema": "./src/executors/server/schema.json",
11
11
  "description": "Serve a Next.js application."
12
- },
13
- "export": {
14
- "implementation": "./src/executors/export/export.impl",
15
- "schema": "./src/executors/export/schema.json",
16
- "description": "Export a Next.js application. The exported application is located at `dist/$outputPath/exported`.",
17
- "x-deprecated": "Use static exports in next.config.js instead. See: https://nextjs.org/docs/pages/building-your-application/deploying/static-exports."
18
12
  }
19
13
  }
20
14
  }
package/generators.json CHANGED
@@ -17,12 +17,12 @@
17
17
  "description": "Create an application."
18
18
  },
19
19
  "page": {
20
- "factory": "./src/generators/page/page#pageGeneratorInternal",
20
+ "factory": "./src/generators/page/page",
21
21
  "schema": "./src/generators/page/schema.json",
22
22
  "description": "Create a page."
23
23
  },
24
24
  "component": {
25
- "factory": "./src/generators/component/component#componentGeneratorInternal",
25
+ "factory": "./src/generators/component/component",
26
26
  "schema": "./src/generators/component/schema.json",
27
27
  "description": "Create a component."
28
28
  },
package/migrations.json CHANGED
@@ -1,76 +1,48 @@
1
1
  {
2
- "generators": {
3
- "update-16-0-0-add-nx-packages": {
4
- "cli": "nx",
5
- "version": "16.0.0-beta.1",
6
- "description": "Replace @nrwl/next with @nx/next",
7
- "implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages"
8
- },
9
- "update-16-3-0-remove-root-build-option": {
10
- "cli": "nx",
11
- "version": "16.3.0-beta.9",
12
- "description": "Remove root build option from project configurations since it is not needed.",
13
- "implementation": "./src/migrations/update-16-3-0/remove-root-build-option"
14
- },
15
- "update-16-4-0-update-next-dependency": {
16
- "cli": "nx",
17
- "version": "16.4.0-beta.3",
18
- "description": "Update package.json moving @nx/next from dependency to devDependency",
19
- "implementation": "./src/migrations/update-16-4-0/update-nx-next-dependency"
20
- },
21
- "update-17-2-7": {
22
- "cli": "nx",
23
- "version": "17.2.7",
24
- "description": "Remove patched eslint rule for @next/next/no-html-link-for-pages",
25
- "implementation": "./src/migrations/update-17-2-7/remove-eslint-rules-patch"
26
- }
27
- },
2
+ "generators": {},
28
3
  "packageJsonUpdates": {
29
- "16.0.0": {
30
- "version": "16.0.0-beta.0",
4
+ "19.0.3": {
5
+ "version": "19.0.3-beta.0",
31
6
  "packages": {
32
7
  "next": {
33
- "version": "13.3.0",
8
+ "version": "14.2.3",
34
9
  "alwaysAddToPackageJson": false
35
- }
36
- }
37
- },
38
- "16.4.0-beta.4": {
39
- "version": "16.4.0-beta.4",
40
- "packages": {
41
- "stylus": {
42
- "version": "^0.59.0",
10
+ },
11
+ "eslint-config-next": {
12
+ "version": "14.2.3",
43
13
  "alwaysAddToPackageJson": false
44
14
  }
45
15
  }
46
16
  },
47
- "17.3.1-beta.0": {
48
- "version": "17.3.1-beta.0",
17
+ "20.7.1-beta.0": {
18
+ "version": "20.7.1-beta.0",
49
19
  "packages": {
50
- "next": {
51
- "version": "14.0.4",
20
+ "eslint-config-next": {
21
+ "version": "^15.2.4",
52
22
  "alwaysAddToPackageJson": false
53
23
  }
54
24
  }
55
25
  },
56
- "18.0.4": {
57
- "version": "18.0.4-beta.0",
26
+ "20.7.1-beta.0-next14": {
27
+ "version": "20.7.1-beta.0",
28
+ "requires": {
29
+ "next": "^14.0.0"
30
+ },
58
31
  "packages": {
59
- "@swc-node/register": {
60
- "version": "~1.8.0",
32
+ "next": {
33
+ "version": "~14.2.26",
61
34
  "alwaysAddToPackageJson": false
62
35
  }
63
36
  }
64
37
  },
65
- "19.0.3": {
66
- "version": "19.0.3-beta.0",
38
+ "20.7.1-beta.0-next15": {
39
+ "version": "20.7.1-beta.0",
40
+ "requires": {
41
+ "next": "^15.0.0"
42
+ },
67
43
  "packages": {
68
44
  "next": {
69
- "version": "14.2.3",
70
- "alwaysAddToPackageJson": false
71
- },
72
- "eslint-config-next": {
73
- "version": "14.2.3",
45
+ "version": "~15.2.4",
74
46
  "alwaysAddToPackageJson": false
75
47
  }
76
48
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/next",
3
- "version": "0.0.0-pr-31222-862e973",
3
+ "version": "0.0.0-pr-31313-387cdca",
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,27 +35,25 @@
35
35
  "next": ">=14.0.0"
36
36
  },
37
37
  "dependencies": {
38
- "@nx/devkit": "0.0.0-pr-31222-862e973",
38
+ "@nx/devkit": "0.0.0-pr-31313-387cdca",
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
- "picocolors": "^1.1.0",
45
44
  "semver": "^7.5.3",
46
45
  "tslib": "^2.3.0",
47
46
  "webpack-merge": "^5.8.0",
48
- "@nx/js": "0.0.0-pr-31222-862e973",
49
- "@nx/eslint": "0.0.0-pr-31222-862e973",
50
- "@nx/react": "0.0.0-pr-31222-862e973",
51
- "@nx/web": "0.0.0-pr-31222-862e973",
52
- "@nx/webpack": "0.0.0-pr-31222-862e973",
53
- "@phenomnomnominal/tsquery": "~5.0.1",
54
- "@nrwl/next": "0.0.0-pr-31222-862e973"
47
+ "@nx/js": "0.0.0-pr-31313-387cdca",
48
+ "@nx/eslint": "0.0.0-pr-31313-387cdca",
49
+ "@nx/react": "0.0.0-pr-31313-387cdca",
50
+ "@nx/web": "0.0.0-pr-31313-387cdca",
51
+ "@nx/webpack": "0.0.0-pr-31313-387cdca",
52
+ "@phenomnomnominal/tsquery": "~5.0.1"
55
53
  },
56
54
  "publishConfig": {
57
55
  "access": "public"
58
56
  },
59
- "type": "commonjs",
60
- "types": "./index.d.ts"
57
+ "types": "./index.d.ts",
58
+ "type": "commonjs"
61
59
  }
package/plugin.d.ts CHANGED
@@ -1 +1 @@
1
- export { createNodes, NextPluginOptions } from './src/plugins/plugin';
1
+ export { createNodes, createNodesV2, NextPluginOptions, } from './src/plugins/plugin';
package/plugin.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createNodes = void 0;
3
+ exports.createNodesV2 = exports.createNodes = void 0;
4
4
  var plugin_1 = require("./src/plugins/plugin");
5
5
  Object.defineProperty(exports, "createNodes", { enumerable: true, get: function () { return plugin_1.createNodes; } });
6
+ Object.defineProperty(exports, "createNodesV2", { enumerable: true, get: function () { return plugin_1.createNodesV2; } });
@@ -7,6 +7,7 @@ const devkit_1 = require("@nx/devkit");
7
7
  const react_1 = require("@nx/react");
8
8
  const webpack_1 = require("@nx/webpack");
9
9
  const path_1 = require("path");
10
+ const configuration_1 = require("nx/src/config/configuration");
10
11
  function nxComponentTestingPreset(pathToConfig, options) {
11
12
  if (global.NX_GRAPH_CREATION) {
12
13
  // this is only used by plugins, so we don't need the component testing
@@ -34,6 +35,8 @@ function nxComponentTestingPreset(pathToConfig, options) {
34
35
  const parsedBuildTarget = (0, devkit_1.parseTargetString)(buildTarget, {
35
36
  cwd: process.cwd(),
36
37
  root: devkit_1.workspaceRoot,
38
+ projectsConfigurations: (0, devkit_1.readProjectsConfigurationFromProjectGraph)(graph),
39
+ nxJsonConfiguration: (0, configuration_1.readNxJson)(devkit_1.workspaceRoot),
37
40
  isVerbose: false,
38
41
  projectName: ctProjectName,
39
42
  projectGraph: graph,
@@ -67,6 +70,7 @@ Able to find CT project, ${!!ctProjectConfig}.`);
67
70
  projectRoot: ctProjectConfig.root,
68
71
  sourceRoot: ctProjectConfig.sourceRoot,
69
72
  main: '',
73
+ useTsconfigPaths: undefined,
70
74
  fileReplacements: buildFileReplacements,
71
75
  assets: buildAssets,
72
76
  outputPath: buildOuputPath,
@@ -13,6 +13,10 @@ export interface SvgrOptions {
13
13
  }
14
14
  export interface WithNxOptions extends NextConfig {
15
15
  nx?: {
16
+ /**
17
+ * @deprecated Add SVGR support in your Webpack configuration without relying on Nx. See https://react-svgr.com/docs/webpack/
18
+ * TODO(v22): Remove this option and migrate userland webpack config to explicitly configure @svgr/webpack
19
+ * */
16
20
  svgr?: boolean | SvgrOptions;
17
21
  babelUpwardRootMode?: boolean;
18
22
  fileReplacements?: {
@@ -43,7 +43,7 @@ function getNxContext(graph, target) {
43
43
  return getNxContext(graph, parseTargetString(targetOptions.devServerTarget, partialExecutorContext));
44
44
  }
45
45
  else if (targetOptions.buildTarget) {
46
- // Executors such as @nx/next:server or @nx/next:export define the buildTarget option.
46
+ // Executors such as @nx/next:server define the buildTarget option.
47
47
  return getNxContext(graph, parseTargetString(targetOptions.buildTarget, partialExecutorContext));
48
48
  }
49
49
  // Default case, return info for current target.
@@ -231,32 +231,17 @@ function getNextConfig(nextConfig = {}, context = getWithNxContext()) {
231
231
  */
232
232
  // Default SVGR support to be on for projects.
233
233
  if (nx?.svgr !== false || typeof nx?.svgr === 'object') {
234
+ forNextVersion('>=15.0.0', () => {
235
+ // Since Next.js 15, turbopack could be enabled by default.
236
+ console.warn(`NX: Next.js SVGR support is deprecated. If used with turbopack, it may not work as expected and is not recommended. Please configure SVGR manually.`);
237
+ });
234
238
  const defaultSvgrOptions = {
235
239
  svgo: false,
236
240
  titleProp: true,
237
241
  ref: true,
238
242
  };
239
243
  const svgrOptions = typeof nx?.svgr === 'object' ? nx.svgr : defaultSvgrOptions;
240
- // TODO(v20): Remove file-loader and use `?react` querystring to differentiate between asset and SVGR.
241
- // It should be:
242
- // use: [{
243
- // test: /\.svg$/i,
244
- // type: 'asset',
245
- // resourceQuery: /react/, // *.svg?react
246
- // },
247
- // {
248
- // test: /\.svg$/i,
249
- // issuer: /\.[jt]sx?$/,
250
- // resourceQuery: { not: [/react/] }, // exclude react component if *.svg?react
251
- // use: ['@svgr/webpack'],
252
- // }],
253
- // See:
254
- // - SVGR: https://react-svgr.com/docs/webpack/#use-svgr-and-asset-svg-in-the-same-project
255
- // - Vite: https://www.npmjs.com/package/vite-plugin-svgr
256
- // - Rsbuild: https://github.com/web-infra-dev/rsbuild/pull/1783
257
- // Note: We also need a migration for any projects that are using SVGR to convert
258
- // `import { ReactComponent as X } from './x.svg` to
259
- // `import X from './x.svg?react';
244
+ // TODO(v22): Remove SVGR support
260
245
  config.module.rules.push({
261
246
  test: /\.svg$/,
262
247
  issuer: { not: /\.(css|scss|sass)$/ },
@@ -94,7 +94,12 @@ function findNextConfigPath(dirname, userDefinedConfigPath) {
94
94
  return file;
95
95
  throw new Error(`Cannot find the Next.js config file: ${userDefinedConfigPath}. Is the path correct in project.json?`);
96
96
  }
97
- const candidates = ['next.config.js', 'next.config.cjs', 'next.config.mjs'];
97
+ const candidates = [
98
+ 'next.config.js',
99
+ 'next.config.cjs',
100
+ 'next.config.mjs',
101
+ 'next.config.ts',
102
+ ];
98
103
  for (const candidate of candidates) {
99
104
  if ((0, node_fs_1.existsSync)((0, path_1.join)(dirname, candidate)))
100
105
  return candidate;
@@ -149,7 +154,7 @@ function stripOuterQuotes(str) {
149
154
  }
150
155
  // Exported for testing
151
156
  function ensureFileExtensions(files, absoluteDir) {
152
- const extensions = ['.js', '.cjs', '.mjs', '.json'];
157
+ const extensions = ['.js', '.cjs', '.mjs', '.json', '.ts'];
153
158
  return files.map((file) => {
154
159
  const providedExt = (0, path_1.extname)(file);
155
160
  if (providedExt && extensions.includes(providedExt))
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "version": 2,
3
+ "continuous": true,
3
4
  "outputCapture": "pipe",
4
5
  "cli": "nx",
5
6
  "title": "Next Serve",
@@ -3,4 +3,4 @@ import { NextServeBuilderOptions } from '../../utils/types';
3
3
  export default function serveExecutor(options: NextServeBuilderOptions, context: ExecutorContext): AsyncGenerator<{
4
4
  success: boolean;
5
5
  baseUrl: string;
6
- }, void, undefined>;
6
+ }, void, any>;
@@ -10,7 +10,7 @@ const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
10
10
  const wait_for_port_open_1 = require("@nx/web/src/utils/wait-for-port-open");
11
11
  async function* serveExecutor(options, context) {
12
12
  const buildOptions = (0, devkit_1.readTargetOptions)((0, devkit_1.parseTargetString)(options.buildTarget, context), context);
13
- const projectRoot = context.workspace.projects[context.projectName].root;
13
+ const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
14
14
  // This is required for the default custom server to work. See the @nx/next:app generator.
15
15
  const nextDir = !options.dev && (0, path_1.resolve)(context.root, buildOptions.outputPath);
16
16
  process.env.NX_NEXT_DIR ??= options.dev ? projectRoot : nextDir;
@@ -4,8 +4,9 @@ exports.applicationGenerator = applicationGenerator;
4
4
  exports.applicationGeneratorInternal = applicationGeneratorInternal;
5
5
  const devkit_1 = require("@nx/devkit");
6
6
  const js_1 = require("@nx/js");
7
- const react_1 = require("@nx/react");
7
+ const setup_tailwind_1 = require("../setup-tailwind/setup-tailwind");
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");
@@ -21,10 +22,13 @@ const update_cypress_tsconfig_1 = require("./lib/update-cypress-tsconfig");
21
22
  const show_possible_warnings_1 = require("./lib/show-possible-warnings");
22
23
  const versions_2 = require("../../utils/versions");
23
24
  const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
25
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
26
+ const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields");
27
+ const add_swc_to_custom_server_1 = require("../../utils/add-swc-to-custom-server");
24
28
  async function applicationGenerator(host, schema) {
25
29
  return await applicationGeneratorInternal(host, {
26
30
  addPlugin: false,
27
- projectNameAndRootFormat: 'derived',
31
+ useProjectJson: true,
28
32
  ...schema,
29
33
  });
30
34
  }
@@ -36,6 +40,9 @@ async function applicationGeneratorInternal(host, schema) {
36
40
  js: options.js,
37
41
  skipPackageJson: options.skipPackageJson,
38
42
  skipFormat: true,
43
+ addTsPlugin: options.isTsSolutionSetup,
44
+ formatter: options.formatter,
45
+ platform: 'web',
39
46
  });
40
47
  tasks.push(jsInitTask);
41
48
  const nextTask = await (0, init_1.nextInitGenerator)(host, {
@@ -45,6 +52,11 @@ async function applicationGeneratorInternal(host, schema) {
45
52
  tasks.push(nextTask);
46
53
  (0, create_application_files_1.createApplicationFiles)(host, options);
47
54
  (0, add_project_1.addProject)(host, options);
55
+ // If we are using the new TS solution
56
+ // We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
57
+ if (options.isTsSolutionSetup) {
58
+ await (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.appProjectRoot);
59
+ }
48
60
  const e2eTask = await (0, add_e2e_1.addE2e)(host, options);
49
61
  tasks.push(e2eTask);
50
62
  const jestTask = await (0, add_jest_1.addJest)(host, options);
@@ -52,7 +64,7 @@ async function applicationGeneratorInternal(host, schema) {
52
64
  const lintTask = await (0, add_linting_1.addLinting)(host, options);
53
65
  tasks.push(lintTask);
54
66
  if (options.style === 'tailwind') {
55
- const tailwindTask = await (0, react_1.setupTailwindGenerator)(host, {
67
+ const tailwindTask = await (0, setup_tailwind_1.setupTailwindGenerator)(host, {
56
68
  project: options.projectName,
57
69
  });
58
70
  tasks.push(tailwindTask);
@@ -65,6 +77,10 @@ async function applicationGeneratorInternal(host, schema) {
65
77
  (0, update_jest_config_1.updateJestConfig)(host, options);
66
78
  (0, update_cypress_tsconfig_1.updateCypressTsConfig)(host, options);
67
79
  (0, set_defaults_1.setDefaults)(host, options);
80
+ if (options.swc) {
81
+ const swcTask = (0, add_swc_to_custom_server_1.configureForSwc)(host, options.appProjectRoot);
82
+ tasks.push(swcTask);
83
+ }
68
84
  if (options.customServer) {
69
85
  await (0, custom_server_1.customServerGenerator)(host, {
70
86
  project: options.projectName,
@@ -72,15 +88,25 @@ async function applicationGeneratorInternal(host, schema) {
72
88
  });
73
89
  }
74
90
  if (!options.skipPackageJson) {
91
+ const reactVersions = await (0, version_utils_1.getReactDependenciesVersionsToInstall)(host);
75
92
  const devDependencies = {
76
- '@types/react': versions_1.typesReactVersion,
77
- '@types/react-dom': versions_1.typesReactDomVersion,
93
+ '@types/react': reactVersions['@types/react'],
94
+ '@types/react-dom': reactVersions['@types/react-dom'],
78
95
  };
79
- if (schema.unitTestRunner && schema.unitTestRunner !== 'none') {
96
+ if (options.unitTestRunner && options.unitTestRunner !== 'none') {
80
97
  devDependencies['@testing-library/react'] = versions_1.testingLibraryReactVersion;
98
+ devDependencies['@testing-library/dom'] = versions_1.testingLibraryDomVersion;
81
99
  }
82
100
  tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, { tslib: versions_2.tsLibVersion }, devDependencies));
83
101
  }
102
+ (0, ts_solution_setup_1.updateTsconfigFiles)(host, options.appProjectRoot, 'tsconfig.json', {
103
+ jsx: 'preserve',
104
+ module: 'esnext',
105
+ moduleResolution: 'bundler',
106
+ }, options.linter === 'eslint'
107
+ ? ['.next', 'eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
108
+ : ['.next'], options.src ? 'src' : '.');
109
+ (0, sort_fields_1.sortPackageJsonFields)(host, options.appProjectRoot);
84
110
  if (!options.skipFormat) {
85
111
  await (0, devkit_1.formatFiles)(host);
86
112
  }
@@ -1,19 +1,16 @@
1
- <% if (style !== 'none') { %>
2
- <% if (styledModule && (styledModule === 'styled-jsx' || styledModule === 'styled-components')) {%>
3
- 'use client';
4
- <% }%>
5
- <% if (styledModule && styledModule !== 'styled-jsx') {
6
- var wrapper = 'StyledPage';
7
- %>import styled from '<%= styledModule %>';<% } else {
8
- var wrapper = 'div';
9
- %>
10
- <%- (style !== 'styled-jsx' && style !== 'tailwind') ? `import styles from './page.module.${style}';` : '' %>
11
- <% }
12
- %>
1
+ <%_ if (style !== 'none') { _%>
2
+ <%_ if (styledModule && (styledModule === 'styled-jsx' || styledModule === 'styled-components')) { _%>
3
+ 'use client';
4
+ <%_ } _%>
5
+ <%_ if (styledModule && styledModule !== 'styled-jsx') { var wrapper = 'StyledPage'; _%>
6
+ import styled from '<%= styledModule %>';
7
+ <%_ } else { var wrapper = 'div'; _%>
8
+ <%- (style !== 'styled-jsx' && style !== 'tailwind') ? `import styles from './page.module.${style}';` : '' %>
9
+ <%_ } _%>
13
10
 
14
- <% if (styledModule && styledModule !== 'styled-jsx') { %>
15
- const StyledPage = styled.div`<%- pageStyleContent %>`;
16
- <% }%>
11
+ <%_ if (styledModule && styledModule !== 'styled-jsx') { _%>
12
+ const StyledPage = styled.div`<%- pageStyleContent %>`;
13
+ <%_ } _%>
17
14
  <% } %>
18
15
  export default function Index() {
19
16
  /*
@@ -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/basic-features/typescript for more information.
5
+ // see https://nextjs.org/docs/<%- appDirType %>/api-reference/config/typescript for more information.
@@ -12,11 +12,9 @@ const { withLess } = require('@nx/next/plugins/with-less');
12
12
  * @type {import('@nx/next/plugins/with-nx').WithNxOptions}
13
13
  **/
14
14
  const nextConfig = {
15
- nx: {
16
- // Set this to true if you would like to to use SVGR
17
- // See: https://github.com/gregberge/svgr
18
- svgr: false,
19
- },
15
+ // Use this to set Nx-specific options
16
+ // See: https://nx.dev/recipes/next/next-config-setup
17
+ nx: {},
20
18
  };
21
19
 
22
20
  const plugins = [
@@ -36,11 +34,9 @@ module.exports = composePlugins(...plugins)(nextConfig);
36
34
  * @type {import('@nx/next/plugins/with-nx').WithNxOptions}
37
35
  **/
38
36
  const nextConfig = {
39
- nx: {
40
- // Set this to true if you would like to to use SVGR
41
- // See: https://github.com/gregberge/svgr
42
- svgr: false,
43
- },
37
+ // Use this to set Nx-specific options
38
+ // See: https://nx.dev/recipes/next/next-config-setup
39
+ nx: {},
44
40
  <% if (style === 'styled-components') { %>
45
41
  compiler: {
46
42
  // For other options, see https://styled-components.com/docs/tooling#babel-plugin
@@ -66,11 +62,9 @@ module.exports = composePlugins(...plugins)(nextConfig);
66
62
  * @type {import('@nx/next/plugins/with-nx').WithNxOptions}
67
63
  **/
68
64
  const nextConfig = {
69
- nx: {
70
- // Set this to true if you would like to use SVGR
71
- // See: https://github.com/gregberge/svgr
72
- svgr: false,
73
- },
65
+ // Use this to set Nx-specific options
66
+ // See: https://nx.dev/recipes/next/next-config-setup
67
+ nx: {},
74
68
  };
75
69
 
76
70
  const plugins = [
@@ -1,14 +1,14 @@
1
1
  import React from 'react';
2
2
  import { render } from '@testing-library/react';
3
- <% if (src && !appDir) { %>
3
+ <%_ if (src && !appDir) { _%>
4
4
  import Index from '../src/pages/index';
5
- <% } else if (!appDir) { %>
5
+ <%_ } else if (!appDir) { _%>
6
6
  import Index from '../pages/index';
7
- <% } else if (appDir && src) {%>
7
+ <%_ } else if (appDir && src) { _%>
8
8
  import Page from '../src/app/page';
9
- <% } else { %>
9
+ <%_ } else { _%>
10
10
  import Page from '../app/page';
11
- <% } %>
11
+ <%_ } _%>
12
12
 
13
13
  describe(<%- appDir ? `'Page'` : `'Index'` %>, () => {
14
14
  it('should render successfully', () => {
@@ -3,16 +3,23 @@
3
3
  "compilerOptions": {
4
4
  "jsx": "preserve",
5
5
  <% if (style === '@emotion/styled') { %>"jsxImportSource": "@emotion/react",<% } %>
6
- "allowJs": true,
7
- "esModuleInterop": true,
8
- "allowSyntheticDefaultImports": true,
9
6
  "strict": true,
10
- "forceConsistentCasingInFileNames": true,
11
7
  "noEmit": true,
8
+ "emitDeclarationOnly": false,
9
+ "esModuleInterop": true,
10
+ "module": "esnext",
11
+ "moduleResolution": "bundler",
12
12
  "resolveJsonModule": true,
13
13
  "isolatedModules": true,
14
+ "lib": ["dom", "dom.iterable", "esnext"],
15
+ "allowJs": true,
16
+ "allowSyntheticDefaultImports": true,
17
+ "forceConsistentCasingInFileNames": true,
14
18
  "incremental": true,
15
- "plugins": [{ "name": "next" }]
19
+ "plugins": [{ "name": "next" }]<% if (isUsingTsSolutionSetup) { %>,
20
+ "paths": {
21
+ "@/*": [<% if (src) { %>"./src/*"<% } else { %>"./*"<% } %>]
22
+ }<% } %>
16
23
  },
17
24
  "include": [
18
25
  "<%= rootPath %>**/*.ts",
@@ -1,17 +1,14 @@
1
- <% if (style !== 'none') { %>
2
- <% if (styledModule && styledModule !== 'styled-jsx') {
3
- var wrapper = 'StyledPage';
4
- %>import styled from '<%= styledModule %>';<% } else {
5
- var wrapper = 'div';
6
- %>
7
- <%- (style !== 'styled-jsx' && style !== 'tailwind') ? `import styles from './${fileName}.module.${style}';` : '' %>
8
- <% }
9
- %>
1
+ <%_ if (style !== 'none') { _%>
2
+ <%_ if (styledModule && styledModule !== 'styled-jsx') { var wrapper = 'StyledPage'; _%>
3
+ import styled from '<%= styledModule %>';
4
+ <% } else { var wrapper = 'div';%>
5
+ <%- (style !== 'styled-jsx' && style !== 'tailwind') ? `import styles from './${fileName}.module.${style}';` : '' %>
6
+ <%_ } _%>
10
7
 
11
- <% if (styledModule && styledModule !== 'styled-jsx') { %>
12
- const StyledPage = styled.div`<%- pageStyleContent %>`;
13
- <% }%>
14
- <% } %>
8
+ <%_ if (styledModule && styledModule !== 'styled-jsx') { _%>
9
+ const StyledPage = styled.div`<%- pageStyleContent %>`;
10
+ <%_ } _%>
11
+ <%_ } _%>
15
12
 
16
13
  export function Index() {
17
14
  /*