@nx/next 21.3.4 → 21.3.6

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": "21.3.4",
3
+ "version": "21.3.6",
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": "21.3.4",
38
+ "@nx/devkit": "21.3.6",
39
39
  "@babel/plugin-proposal-decorators": "^7.22.7",
40
40
  "@svgr/webpack": "^8.1.0",
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": "21.3.4",
48
- "@nx/eslint": "21.3.4",
49
- "@nx/react": "21.3.4",
50
- "@nx/web": "21.3.4",
51
- "@nx/webpack": "21.3.4",
47
+ "@nx/js": "21.3.6",
48
+ "@nx/eslint": "21.3.6",
49
+ "@nx/react": "21.3.6",
50
+ "@nx/web": "21.3.6",
51
+ "@nx/webpack": "21.3.6",
52
52
  "@phenomnomnominal/tsquery": "~5.0.1"
53
53
  },
54
54
  "publishConfig": {
@@ -2,15 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createNodes = exports.createNodesV2 = exports.createDependencies = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const path_1 = require("path");
6
- const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
7
- const fs_1 = require("fs");
8
- const cache_directory_1 = require("nx/src/utils/cache-directory");
9
5
  const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
10
- const js_1 = require("@nx/js");
11
6
  const config_utils_1 = require("@nx/devkit/src/utils/config-utils");
12
- const devkit_internals_1 = require("nx/src/devkit-internals");
7
+ const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
8
+ const js_1 = require("@nx/js");
13
9
  const util_1 = require("@nx/js/src/plugins/typescript/util");
10
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
11
+ const fs_1 = require("fs");
12
+ const devkit_internals_1 = require("nx/src/devkit-internals");
13
+ const cache_directory_1 = require("nx/src/utils/cache-directory");
14
+ const path_1 = require("path");
14
15
  const pmc = (0, devkit_1.getPackageManagerCommand)();
15
16
  const nextConfigBlob = '**/next.config.{ts,js,cjs,mjs}';
16
17
  function readTargetsCache(cachePath) {
@@ -36,8 +37,9 @@ exports.createNodesV2 = [
36
37
  const optionsHash = (0, devkit_internals_1.hashObject)(options);
37
38
  const cachePath = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, `next-${optionsHash}.json`);
38
39
  const targetsCache = readTargetsCache(cachePath);
40
+ const isTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)();
39
41
  try {
40
- return await (0, devkit_1.createNodesFromFiles)((configFile, options, context) => createNodesInternal(configFile, options, context, targetsCache), configFiles, options, context);
42
+ return await (0, devkit_1.createNodesFromFiles)((configFile, options, context) => createNodesInternal(configFile, options, context, targetsCache, isTsSolutionSetup), configFiles, options, context);
41
43
  }
42
44
  finally {
43
45
  writeTargetsToCache(cachePath, targetsCache);
@@ -55,12 +57,13 @@ exports.createNodes = [
55
57
  const optionsHash = (0, devkit_internals_1.hashObject)(options);
56
58
  const cachePath = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, `next-${optionsHash}.json`);
57
59
  const targetsCache = readTargetsCache(cachePath);
58
- const result = await createNodesInternal(configFilePath, options, context, targetsCache);
60
+ const isTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)();
61
+ const result = await createNodesInternal(configFilePath, options, context, targetsCache, isTsSolutionSetup);
59
62
  writeTargetsToCache(cachePath, targetsCache);
60
63
  return result;
61
64
  },
62
65
  ];
63
- async function createNodesInternal(configFilePath, options, context, targetsCache) {
66
+ async function createNodesInternal(configFilePath, options, context, targetsCache, isTsSolutionSetup) {
64
67
  const projectRoot = (0, path_1.dirname)(configFilePath);
65
68
  // Do not create a project if package.json and project.json isn't there.
66
69
  const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
@@ -70,7 +73,7 @@ async function createNodesInternal(configFilePath, options, context, targetsCach
70
73
  }
71
74
  options = normalizeOptions(options);
72
75
  const hash = await (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, context, [(0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot))]);
73
- targetsCache[hash] ??= await buildNextTargets(configFilePath, projectRoot, options, context);
76
+ targetsCache[hash] ??= await buildNextTargets(configFilePath, projectRoot, options, context, isTsSolutionSetup);
74
77
  return {
75
78
  projects: {
76
79
  [projectRoot]: {
@@ -80,19 +83,19 @@ async function createNodesInternal(configFilePath, options, context, targetsCach
80
83
  },
81
84
  };
82
85
  }
83
- async function buildNextTargets(nextConfigPath, projectRoot, options, context) {
86
+ async function buildNextTargets(nextConfigPath, projectRoot, options, context, isTsSolutionSetup) {
84
87
  const nextConfig = await getNextConfig(nextConfigPath, context);
85
88
  const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
86
89
  const targets = {};
87
- targets[options.buildTargetName] = await getBuildTargetConfig(namedInputs, projectRoot, nextConfig);
88
- targets[options.devTargetName] = getDevTargetConfig(projectRoot);
90
+ targets[options.buildTargetName] = await getBuildTargetConfig(namedInputs, projectRoot, nextConfig, isTsSolutionSetup);
91
+ targets[options.devTargetName] = getDevTargetConfig(projectRoot, isTsSolutionSetup);
89
92
  const startTarget = getStartTargetConfig(options, projectRoot);
90
93
  targets[options.startTargetName] = startTarget;
91
94
  targets[options.serveStaticTargetName] = startTarget;
92
95
  (0, util_1.addBuildAndWatchDepsTargets)(context.workspaceRoot, projectRoot, targets, options, pmc);
93
96
  return targets;
94
97
  }
95
- async function getBuildTargetConfig(namedInputs, projectRoot, nextConfig) {
98
+ async function getBuildTargetConfig(namedInputs, projectRoot, nextConfig, isTsSolutionSetup) {
96
99
  const nextOutputPath = await getOutputs(projectRoot, nextConfig);
97
100
  // Set output path here so that `withNx` can pick it up.
98
101
  const targetConfig = {
@@ -108,9 +111,12 @@ async function getBuildTargetConfig(namedInputs, projectRoot, nextConfig) {
108
111
  // TODO(ndcunningham): Update this to be consider different versions of next.js which is running
109
112
  // This doesn't actually need to be tty, but next.js has a bug, https://github.com/vercel/next.js/issues/62906, where it exits 0 when SIGINT is sent.
110
113
  targetConfig.options.tty = false;
114
+ if (isTsSolutionSetup) {
115
+ targetConfig.syncGenerators = ['@nx/js:typescript-sync'];
116
+ }
111
117
  return targetConfig;
112
118
  }
113
- function getDevTargetConfig(projectRoot) {
119
+ function getDevTargetConfig(projectRoot, isTsSolutionSetup) {
114
120
  const targetConfig = {
115
121
  continuous: true,
116
122
  command: `next dev`,
@@ -118,6 +124,9 @@ function getDevTargetConfig(projectRoot) {
118
124
  cwd: projectRoot,
119
125
  },
120
126
  };
127
+ if (isTsSolutionSetup) {
128
+ targetConfig.syncGenerators = ['@nx/js:typescript-sync'];
129
+ }
121
130
  return targetConfig;
122
131
  }
123
132
  function getStartTargetConfig(options, projectRoot) {