@nx/next 19.8.2 → 19.8.3

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": "19.8.2",
3
+ "version": "19.8.3",
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,25 +35,23 @@
35
35
  "next": ">=14.0.0"
36
36
  },
37
37
  "dependencies": {
38
- "@nx/devkit": "19.8.2",
38
+ "@nx/devkit": "19.8.3",
39
39
  "@babel/plugin-proposal-decorators": "^7.22.7",
40
40
  "@svgr/webpack": "^8.0.1",
41
41
  "copy-webpack-plugin": "^10.2.4",
42
42
  "file-loader": "^6.2.0",
43
- "fs-extra": "^11.1.0",
44
43
  "ignore": "^5.0.4",
45
44
  "picocolors": "^1.1.0",
46
45
  "semver": "^7.5.3",
47
46
  "tslib": "^2.3.0",
48
47
  "webpack-merge": "^5.8.0",
49
- "@nx/js": "19.8.2",
50
- "@nx/eslint": "19.8.2",
51
- "@nx/react": "19.8.2",
52
- "@nx/web": "19.8.2",
53
- "@nx/webpack": "19.8.2",
54
- "@nx/workspace": "19.8.2",
48
+ "@nx/js": "19.8.3",
49
+ "@nx/eslint": "19.8.3",
50
+ "@nx/react": "19.8.3",
51
+ "@nx/web": "19.8.3",
52
+ "@nx/webpack": "19.8.3",
55
53
  "@phenomnomnominal/tsquery": "~5.0.1",
56
- "@nrwl/next": "19.8.2"
54
+ "@nrwl/next": "19.8.3"
57
55
  },
58
56
  "publishConfig": {
59
57
  "access": "public"
@@ -4,9 +4,9 @@ exports.default = buildExecutor;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const js_1 = require("@nx/js");
6
6
  const path_1 = require("path");
7
- const fs_extra_1 = require("fs-extra");
7
+ const node_fs_1 = require("node:fs");
8
+ const promises_1 = require("node:fs/promises");
8
9
  const semver_1 = require("semver");
9
- const fileutils_1 = require("@nx/workspace/src/utilities/fileutils");
10
10
  const semver_2 = require("@nx/devkit/src/utils/semver");
11
11
  const update_package_json_1 = require("./lib/update-package-json");
12
12
  const create_next_config_file_1 = require("./lib/create-next-config-file");
@@ -22,7 +22,7 @@ async function buildExecutor(options, context) {
22
22
  (0, check_project_1.checkPublicDirectory)(projectRoot);
23
23
  // Set `__NEXT_REACT_ROOT` based on installed ReactDOM version
24
24
  const packageJsonPath = (0, path_1.join)(projectRoot, 'package.json');
25
- const packageJson = (0, fs_extra_1.existsSync)(packageJsonPath)
25
+ const packageJson = (0, node_fs_1.existsSync)(packageJsonPath)
26
26
  ? (0, devkit_1.readJsonFile)(packageJsonPath)
27
27
  : undefined;
28
28
  const rootPackageJson = (0, devkit_1.readJsonFile)((0, path_1.join)(context.root, 'package.json'));
@@ -51,9 +51,7 @@ async function buildExecutor(options, context) {
51
51
  childProcess.kill();
52
52
  }
53
53
  }
54
- if (!(0, fileutils_1.directoryExists)(options.outputPath)) {
55
- (0, fs_extra_1.mkdir)(options.outputPath);
56
- }
54
+ await (0, promises_1.mkdir)(options.outputPath, { recursive: true });
57
55
  const builtPackageJson = (0, js_1.createPackageJson)(context.projectName, context.projectGraph, {
58
56
  target: context.targetName,
59
57
  root: context.root,
@@ -70,7 +68,7 @@ async function buildExecutor(options, context) {
70
68
  if (options.generateLockfile) {
71
69
  const packageManager = (0, devkit_1.detectPackageManager)(context.root);
72
70
  const lockFile = (0, js_1.createLockFile)(builtPackageJson, context.projectGraph, packageManager);
73
- (0, fs_extra_1.writeFileSync)(`${options.outputPath}/${(0, js_1.getLockFileName)(packageManager)}`, lockFile, {
71
+ (0, node_fs_1.writeFileSync)(`${options.outputPath}/${(0, js_1.getLockFileName)(packageManager)}`, lockFile, {
74
72
  encoding: 'utf-8',
75
73
  });
76
74
  }
@@ -78,8 +76,9 @@ async function buildExecutor(options, context) {
78
76
  // This is the default behavior when running `nx build <app>`.
79
77
  if (options.outputPath.replace(/\/$/, '') !== projectRoot) {
80
78
  (0, create_next_config_file_1.createNextConfigFile)(options, context);
81
- (0, fs_extra_1.copySync)((0, path_1.join)(projectRoot, 'public'), (0, path_1.join)(options.outputPath, 'public'), {
79
+ (0, node_fs_1.cpSync)((0, path_1.join)(projectRoot, 'public'), (0, path_1.join)(options.outputPath, 'public'), {
82
80
  dereference: true,
81
+ recursive: true,
83
82
  });
84
83
  }
85
84
  return { success: true };
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.checkPublicDirectory = checkPublicDirectory;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const fs_extra_1 = require("fs-extra");
5
+ const node_fs_1 = require("node:fs");
6
6
  const path_1 = require("path");
7
7
  function checkPublicDirectory(root) {
8
- if ((0, fs_extra_1.readdirSync)((0, path_1.join)(root, 'public')).length === 0) {
8
+ if ((0, node_fs_1.readdirSync)((0, path_1.join)(root, 'public')).length === 0) {
9
9
  devkit_1.logger.warn('public directory cannot be empty. This may result in errors during the deployment. Consider adding a public/.gitkeep file');
10
10
  }
11
11
  }
@@ -8,7 +8,7 @@ exports.getRelativeImports = getRelativeImports;
8
8
  exports.ensureFileExtensions = ensureFileExtensions;
9
9
  const devkit_1 = require("@nx/devkit");
10
10
  const ts = require("typescript");
11
- const fs_extra_1 = require("fs-extra");
11
+ const node_fs_1 = require("node:fs");
12
12
  const path_1 = require("path");
13
13
  const js_1 = require("@nx/js");
14
14
  function createNextConfigFile(options, context) {
@@ -22,21 +22,21 @@ function createNextConfigFile(options, context) {
22
22
  // If user passed a config then it is relative to the workspace root, need to normalize it to be relative to the project root.
23
23
  options.nextConfig ? (0, path_1.relative)(projectRoot, options.nextConfig) : undefined);
24
24
  const configAbsolutePath = (0, path_1.join)(projectRoot, configRelativeToProjectRoot);
25
- if (!(0, fs_extra_1.existsSync)(configAbsolutePath)) {
25
+ if (!(0, node_fs_1.existsSync)(configAbsolutePath)) {
26
26
  throw new Error('next.config.js not found');
27
27
  }
28
28
  // Copy config file and our `.nx-helpers` folder to remove dependency on @nrwl/next for production build.
29
29
  const helpersPath = (0, path_1.join)(options.outputPath, '.nx-helpers');
30
- (0, fs_extra_1.mkdirSync)(helpersPath, { recursive: true });
31
- (0, fs_extra_1.copyFileSync)((0, path_1.join)(__dirname, '../../../utils/compose-plugins.js'), (0, path_1.join)(helpersPath, 'compose-plugins.js'));
32
- (0, fs_extra_1.writeFileSync)((0, path_1.join)(helpersPath, 'with-nx.js'), getWithNxContent());
33
- (0, fs_extra_1.writeFileSync)((0, path_1.join)(helpersPath, 'compiled.js'), `
30
+ (0, node_fs_1.mkdirSync)(helpersPath, { recursive: true });
31
+ (0, node_fs_1.copyFileSync)((0, path_1.join)(__dirname, '../../../utils/compose-plugins.js'), (0, path_1.join)(helpersPath, 'compose-plugins.js'));
32
+ (0, node_fs_1.writeFileSync)((0, path_1.join)(helpersPath, 'with-nx.js'), getWithNxContent());
33
+ (0, node_fs_1.writeFileSync)((0, path_1.join)(helpersPath, 'compiled.js'), `
34
34
  const withNx = require('./with-nx');
35
35
  module.exports = withNx;
36
36
  module.exports.withNx = withNx;
37
37
  module.exports.composePlugins = require('./compose-plugins').composePlugins;
38
38
  `);
39
- (0, fs_extra_1.writeFileSync)((0, path_1.join)(options.outputPath, configRelativeToProjectRoot), (0, fs_extra_1.readFileSync)(configAbsolutePath)
39
+ (0, node_fs_1.writeFileSync)((0, path_1.join)(options.outputPath, configRelativeToProjectRoot), (0, node_fs_1.readFileSync)(configAbsolutePath)
40
40
  .toString()
41
41
  .replace(/["']@nx\/next["']/, `'./.nx-helpers/compiled.js'`)
42
42
  // TODO(v17): Remove this once users have all migrated to new @nx scope and import from '@nx/next' not the deep import paths.
@@ -45,17 +45,18 @@ function createNextConfigFile(options, context) {
45
45
  // Find all relative imports needed by next.config.js and copy them to the dist folder.
46
46
  const moduleFilesToCopy = getRelativeFilesToCopy(configRelativeToProjectRoot, projectRoot);
47
47
  for (const moduleFile of moduleFilesToCopy) {
48
- (0, fs_extra_1.ensureDirSync)((0, path_1.dirname)((0, path_1.join)(context.root, options.outputPath, moduleFile)));
48
+ const moduleFileDir = (0, path_1.dirname)((0, path_1.join)(context.root, options.outputPath, moduleFile));
49
+ (0, node_fs_1.mkdirSync)(moduleFileDir, { recursive: true });
49
50
  // We already generate a build version of package.json in the dist folder.
50
51
  if (moduleFile !== 'package.json') {
51
- (0, fs_extra_1.copyFileSync)((0, path_1.join)(context.root, projectRoot, moduleFile), (0, path_1.join)(context.root, options.outputPath, moduleFile));
52
+ (0, node_fs_1.copyFileSync)((0, path_1.join)(context.root, projectRoot, moduleFile), (0, path_1.join)(context.root, options.outputPath, moduleFile));
52
53
  }
53
54
  }
54
55
  }
55
56
  function readSource(getFile) {
56
57
  return {
57
58
  file: getFile(),
58
- content: (0, fs_extra_1.readFileSync)(getFile()).toString(),
59
+ content: (0, node_fs_1.readFileSync)(getFile()).toString(),
59
60
  };
60
61
  }
61
62
  // Exported for testing
@@ -89,13 +90,13 @@ function getWithNxContent({ file, content } = readSource(() => (0, path_1.join)(
89
90
  function findNextConfigPath(dirname, userDefinedConfigPath) {
90
91
  if (userDefinedConfigPath) {
91
92
  const file = userDefinedConfigPath;
92
- if ((0, fs_extra_1.existsSync)((0, path_1.join)(dirname, file)))
93
+ if ((0, node_fs_1.existsSync)((0, path_1.join)(dirname, file)))
93
94
  return file;
94
95
  throw new Error(`Cannot find the Next.js config file: ${userDefinedConfigPath}. Is the path correct in project.json?`);
95
96
  }
96
97
  const candidates = ['next.config.js', 'next.config.cjs', 'next.config.mjs'];
97
98
  for (const candidate of candidates) {
98
- if ((0, fs_extra_1.existsSync)((0, path_1.join)(dirname, candidate)))
99
+ if ((0, node_fs_1.existsSync)((0, path_1.join)(dirname, candidate)))
99
100
  return candidate;
100
101
  }
101
102
  throw new Error(`Cannot find any of the following files in your project: ${candidates.join(', ')}. Is this a Next.js project?`);
@@ -110,7 +111,7 @@ function getRelativeFilesToCopy(fileName, cwd) {
110
111
  return;
111
112
  seen.add(currFile);
112
113
  const absoluteFilePath = (0, path_1.join)(cwd, currFile);
113
- const content = (0, fs_extra_1.readFileSync)(absoluteFilePath).toString();
114
+ const content = (0, node_fs_1.readFileSync)(absoluteFilePath).toString();
114
115
  const files = getRelativeImports({ file: currFile, content });
115
116
  const modules = ensureFileExtensions(files, (0, path_1.dirname)(absoluteFilePath));
116
117
  const relativeDirPath = (0, path_1.dirname)(currFile);
@@ -153,7 +154,7 @@ function ensureFileExtensions(files, absoluteDir) {
153
154
  const providedExt = (0, path_1.extname)(file);
154
155
  if (providedExt && extensions.includes(providedExt))
155
156
  return file;
156
- const ext = extensions.find((ext) => (0, fs_extra_1.existsSync)((0, path_1.join)(absoluteDir, file + ext)));
157
+ const ext = extensions.find((ext) => (0, node_fs_1.existsSync)((0, path_1.join)(absoluteDir, file + ext)));
157
158
  if (ext) {
158
159
  return file + ext;
159
160
  }