@nx/next 19.0.0-beta.0 → 19.0.0-beta.10

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/migrations.json CHANGED
@@ -1,11 +1,5 @@
1
1
  {
2
2
  "generators": {
3
- "add-style-packages": {
4
- "cli": "nx",
5
- "version": "15.8.8-beta.0",
6
- "description": "Add less and stylus packages if used.",
7
- "factory": "./src/migrations/update-15-8-8/add-style-packages"
8
- },
9
3
  "update-16-0-0-add-nx-packages": {
10
4
  "cli": "nx",
11
5
  "version": "16.0.0-beta.1",
@@ -32,40 +26,6 @@
32
26
  }
33
27
  },
34
28
  "packageJsonUpdates": {
35
- "15.0.4": {
36
- "version": "15.0.4-beta.0",
37
- "packages": {
38
- "next": {
39
- "version": "13.0.0",
40
- "alwaysAddToPackageJson": false
41
- },
42
- "eslint-config-next": {
43
- "version": "13.0.0",
44
- "alwaysAddToPackageJson": false
45
- },
46
- "less-loader": {
47
- "version": "11.1.0",
48
- "alwaysAddToPackageJson": false
49
- },
50
- "stylus-loader": {
51
- "version": "7.1.0",
52
- "alwaysAddToPackageJson": false
53
- }
54
- }
55
- },
56
- "15.4.5": {
57
- "version": "15.4.5-beta.0",
58
- "packages": {
59
- "next": {
60
- "version": "13.1.1",
61
- "alwaysAddToPackageJson": false
62
- },
63
- "eslint-config-next": {
64
- "version": "13.1.1",
65
- "alwaysAddToPackageJson": false
66
- }
67
- }
68
- },
69
29
  "16.0.0": {
70
30
  "version": "16.0.0-beta.0",
71
31
  "packages": {
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@nx/next",
3
- "version": "19.0.0-beta.0",
3
+ "version": "19.0.0-beta.10",
4
4
  "private": false,
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.",
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": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/nrwl/nx.git",
@@ -34,7 +34,7 @@
34
34
  "next": ">=14.0.0"
35
35
  },
36
36
  "dependencies": {
37
- "@nx/devkit": "19.0.0-beta.0",
37
+ "@nx/devkit": "19.0.0-beta.10",
38
38
  "@babel/plugin-proposal-decorators": "^7.22.7",
39
39
  "@svgr/webpack": "^8.0.1",
40
40
  "chalk": "^4.1.0",
@@ -45,13 +45,13 @@
45
45
  "semver": "^7.5.3",
46
46
  "tslib": "^2.3.0",
47
47
  "webpack-merge": "^5.8.0",
48
- "@nx/js": "19.0.0-beta.0",
49
- "@nx/eslint": "19.0.0-beta.0",
50
- "@nx/react": "19.0.0-beta.0",
51
- "@nx/web": "19.0.0-beta.0",
52
- "@nx/webpack": "19.0.0-beta.0",
53
- "@nx/workspace": "19.0.0-beta.0",
54
- "@nrwl/next": "19.0.0-beta.0"
48
+ "@nx/js": "19.0.0-beta.10",
49
+ "@nx/eslint": "19.0.0-beta.10",
50
+ "@nx/react": "19.0.0-beta.10",
51
+ "@nx/web": "19.0.0-beta.10",
52
+ "@nx/webpack": "19.0.0-beta.10",
53
+ "@nx/workspace": "19.0.0-beta.10",
54
+ "@nrwl/next": "19.0.0-beta.10"
55
55
  },
56
56
  "publishConfig": {
57
57
  "access": "public"
@@ -216,11 +216,7 @@ function getNextConfig(nextConfig = {}, context = getWithNxContext()) {
216
216
  delete nextGlobalCssLoader.issuer.and;
217
217
  }
218
218
  /**
219
- * 5. Add env variables prefixed with NX_
220
- */
221
- addNxEnvVariables(config);
222
- /**
223
- * 6. Add SVGR support if option is on.
219
+ * 5. Add SVGR support if option is on.
224
220
  */
225
221
  // Default SVGR support to be on for projects.
226
222
  if (nx?.svgr !== false) {
@@ -279,33 +275,6 @@ function getNextConfig(nextConfig = {}, context = getWithNxContext()) {
279
275
  };
280
276
  }
281
277
  exports.getNextConfig = getNextConfig;
282
- // Prevent sensitive keys from being bundled when source code uses entire `process.env` object rather than individual keys (e.g. `process.env.NX_FOO`).
283
- // TODO(v19): BREAKING: Only support NEXT_PUBLIC_ env vars and ignore NX_ vars since this is a standard Next.js feature.
284
- const excludedKeys = ['NX_CLOUD_ACCESS_TOKEN', 'NX_CLOUD_ENCRYPTION_KEY'];
285
- function getNxEnvironmentVariables() {
286
- return Object.keys(process.env)
287
- .filter((env) => !excludedKeys.includes(env) && /^NX_/i.test(env))
288
- .reduce((env, key) => {
289
- env[key] = process.env[key];
290
- return env;
291
- }, {});
292
- }
293
- /**
294
- * TODO(v19)
295
- * @deprecated Use Next.js 9.4+ built-in support for environment variables. Reference https://nextjs.org/docs/pages/api-reference/next-config-js/env
296
- */
297
- function addNxEnvVariables(config) {
298
- const maybeDefinePlugin = config.plugins?.find((plugin) => {
299
- return plugin.definitions?.['process.env.NODE_ENV'];
300
- });
301
- if (maybeDefinePlugin) {
302
- const env = getNxEnvironmentVariables();
303
- Object.entries(env)
304
- .map(([name, value]) => [`process.env.${name}`, `"${value}"`])
305
- .filter(([name]) => !maybeDefinePlugin.definitions[name])
306
- .forEach(([name, value]) => (maybeDefinePlugin.definitions[name] = value));
307
- }
308
- }
309
278
  function getAliasForProject(node, paths) {
310
279
  // Match workspace libs to their alias in tsconfig paths.
311
280
  for (const [alias, lookup] of Object.entries(paths ?? {})) {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.withStylus = void 0;
4
- // TODO(v19): Remove file, it is here until users migrate over to SASS manually.
4
+ // TODO(v20): Remove file, it is here until users migrate over to SASS manually.
5
5
  function withStylus(configOrFn) {
6
6
  return async (phase) => {
7
7
  throw new Error(`Stylus support has been removed and you should use the built-in SASS support. Remove the "withStylus" plugin from your Next.js config, and rename your files from .styl to .scss.`);
@@ -5,7 +5,7 @@ const devkit_1 = require("@nx/devkit");
5
5
  const ts = require("typescript");
6
6
  const fs_extra_1 = require("fs-extra");
7
7
  const path_1 = require("path");
8
- const typescript_1 = require("nx/src/utils/typescript");
8
+ const js_1 = require("@nx/js");
9
9
  function createNextConfigFile(options, context) {
10
10
  // Don't overwrite the next.config.js file if output path is the same as the source path.
11
11
  if (options.outputPath.replace(/\/$/, '') ===
@@ -57,7 +57,7 @@ function readSource(getFile) {
57
57
  // Exported for testing
58
58
  function getWithNxContent({ file, content } = readSource(() => (0, path_1.join)(__dirname, '../../../../plugins/with-nx.js'))) {
59
59
  const withNxSource = ts.createSourceFile(file, content, ts.ScriptTarget.Latest, true);
60
- const getWithNxContextDeclaration = (0, typescript_1.findNodes)(withNxSource, ts.SyntaxKind.FunctionDeclaration)?.find((node) => node.name?.text === 'getWithNxContext');
60
+ const getWithNxContextDeclaration = (0, js_1.findNodes)(withNxSource, ts.SyntaxKind.FunctionDeclaration)?.find((node) => node.name?.text === 'getWithNxContext');
61
61
  if (getWithNxContextDeclaration) {
62
62
  content = (0, devkit_1.applyChangesToString)(content, [
63
63
  {
@@ -122,7 +122,7 @@ exports.getRelativeFilesToCopy = getRelativeFilesToCopy;
122
122
  // Exported for testing
123
123
  function getRelativeImports({ file, content, }) {
124
124
  const source = ts.createSourceFile(file, content, ts.ScriptTarget.Latest, true);
125
- const callExpressionsOrImportDeclarations = (0, typescript_1.findNodes)(source, [
125
+ const callExpressionsOrImportDeclarations = (0, js_1.findNodes)(source, [
126
126
  ts.SyntaxKind.CallExpression,
127
127
  ts.SyntaxKind.ImportDeclaration,
128
128
  ]);
@@ -19,7 +19,8 @@ exports.default = serveExecutor;
19
19
  async function* runCustomServer(root, options, context) {
20
20
  process.env.NX_NEXT_DIR ??= root;
21
21
  process.env.NX_NEXT_PUBLIC_DIR = (0, path_1.join)(root, 'public');
22
- const baseUrl = `http://${options.hostname || 'localhost'}:${options.port}`;
22
+ const httpProtocol = options.customServerHttps ? 'https' : 'http';
23
+ const baseUrl = `${httpProtocol}://${options.hostname || 'localhost'}:${options.port}`;
23
24
  const customServerBuild = await (0, devkit_1.runExecutor)((0, devkit_1.parseTargetString)(options.customServerTarget, context), {
24
25
  watch: options.dev ? true : false,
25
26
  }, context);
@@ -56,6 +56,10 @@
56
56
  "experimentalHttps": {
57
57
  "type": "boolean",
58
58
  "description": "Enable HTTPS support for the Next.js development server."
59
+ },
60
+ "customServerHttps:": {
61
+ "type": "boolean",
62
+ "description": "Enable HTTPS support for the custom server."
59
63
  }
60
64
  },
61
65
  "required": ["buildTarget"],
@@ -52,6 +52,7 @@ async function addE2e(host, options) {
52
52
  root: options.e2eProjectRoot,
53
53
  sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
54
54
  targets: {},
55
+ tags: [],
55
56
  implicitDependencies: [options.projectName],
56
57
  });
57
58
  return configurationGenerator(host, {
@@ -66,7 +66,7 @@ async function normalizeOptions(host, options) {
66
66
  e2eWebServerAddress,
67
67
  e2eWebServerTarget,
68
68
  e2ePort,
69
- e2eTestRunner: options.e2eTestRunner || 'cypress',
69
+ e2eTestRunner: options.e2eTestRunner || 'playwright',
70
70
  fileName,
71
71
  linter: options.linter || eslint_1.Linter.EsLint,
72
72
  name,
@@ -89,10 +89,10 @@
89
89
  },
90
90
  "e2eTestRunner": {
91
91
  "type": "string",
92
- "enum": ["cypress", "playwright", "none"],
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": "cypress"
95
+ "default": "playwright"
96
96
  },
97
97
  "tags": {
98
98
  "type": "string",
@@ -5,7 +5,7 @@ const devkit_1 = require("@nx/devkit");
5
5
  const react_1 = require("@nx/react");
6
6
  const styles_1 = require("../../utils/styles");
7
7
  const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
8
- // TODO(v19): Remove this logic once we no longer derive directory.
8
+ // TODO(v20): Remove this logic once we no longer derive directory.
9
9
  function maybeGetDerivedDirectory(host, options) {
10
10
  if (!options.project)
11
11
  return options.directory;
@@ -46,7 +46,7 @@ async function normalizeOptions(host, options) {
46
46
  let routerDirectory;
47
47
  if (options.project) {
48
48
  // Legacy behavior, detect app vs page router from specified project.
49
- // TODO(v19): remove this logic
49
+ // TODO(v20): remove this logic
50
50
  const project = (0, devkit_1.readProjectConfiguration)(host, options.project);
51
51
  // app/ is a reserved folder in nextjs so it is safe to check it's existence
52
52
  isAppRouter =
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { CreateDependencies, CreateNodes } from '@nx/devkit';
3
2
  export interface NextPluginOptions {
4
3
  buildTargetName?: string;
@@ -8,4 +7,3 @@ export interface NextPluginOptions {
8
7
  }
9
8
  export declare const createDependencies: CreateDependencies;
10
9
  export declare const createNodes: CreateNodes<NextPluginOptions>;
11
- export declare function loadEsmModule<T>(modulePath: string | URL): Promise<T>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadEsmModule = exports.createNodes = exports.createDependencies = void 0;
3
+ exports.createNodes = exports.createDependencies = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const path_1 = require("path");
6
6
  const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
@@ -8,6 +8,7 @@ const fs_1 = require("fs");
8
8
  const cache_directory_1 = require("nx/src/utils/cache-directory");
9
9
  const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
10
10
  const js_1 = require("@nx/js");
11
+ const config_utils_1 = require("@nx/devkit/src/utils/config-utils");
11
12
  const cachePath = (0, path_1.join)(cache_directory_1.projectGraphCacheDirectory, 'next.hash');
12
13
  const targetsCache = (0, fs_1.existsSync)(cachePath) ? readTargetsCache() : {};
13
14
  const calculatedTargets = {};
@@ -72,6 +73,9 @@ async function getBuildTargetConfig(namedInputs, projectRoot, nextConfig) {
72
73
  inputs: getInputs(namedInputs),
73
74
  outputs: [nextOutputPath, `${nextOutputPath}/!(cache)`],
74
75
  };
76
+ // TODO(ndcunningham): Update this to be consider different versions of next.js which is running
77
+ // 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.
78
+ targetConfig.options.tty = false;
75
79
  return targetConfig;
76
80
  }
77
81
  function getDevTargetConfig(projectRoot) {
@@ -127,16 +131,9 @@ async function getOutputs(projectRoot, nextConfig) {
127
131
  return `{workspaceRoot}/${projectRoot}/${dir}`;
128
132
  }
129
133
  }
130
- async function getNextConfig(configFilePath, context) {
134
+ function getNextConfig(configFilePath, context) {
131
135
  const resolvedPath = (0, path_1.join)(context.workspaceRoot, configFilePath);
132
- let module;
133
- if ((0, path_1.extname)(configFilePath) === '.mjs') {
134
- module = await loadEsmModule(resolvedPath);
135
- }
136
- else {
137
- module = load(resolvedPath);
138
- }
139
- return module.default ?? module;
136
+ return (0, config_utils_1.loadConfigFile)(resolvedPath);
140
137
  }
141
138
  function normalizeOptions(options) {
142
139
  options ??= {};
@@ -156,29 +153,3 @@ function getInputs(namedInputs) {
156
153
  },
157
154
  ];
158
155
  }
159
- const packageInstallationDirectories = ['node_modules', '.yarn'];
160
- /**
161
- * Load the module after ensuring that the require cache is cleared.
162
- */
163
- function load(path) {
164
- // Clear cache if the path is in the cache
165
- if (require.cache[path]) {
166
- for (const key of Object.keys(require.cache)) {
167
- if (!packageInstallationDirectories.some((dir) => key.includes(dir))) {
168
- delete require.cache[key];
169
- }
170
- }
171
- }
172
- // Then require
173
- return require(path);
174
- }
175
- /**
176
- * Lazily compiled dynamic import loader function.
177
- */
178
- let dynamicLoad;
179
- function loadEsmModule(modulePath) {
180
- const modulePathWithCacheBust = `${modulePath}?version=${Date.now()}`;
181
- dynamicLoad ??= new Function('modulePath', `return import(modulePath);`);
182
- return dynamicLoad(modulePathWithCacheBust);
183
- }
184
- exports.loadEsmModule = loadEsmModule;
@@ -5,7 +5,10 @@ function createCliOptions(obj) {
5
5
  return Object.entries(obj).reduce((arr, [key, value]) => {
6
6
  if (value !== undefined) {
7
7
  const kebabCase = key.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase());
8
- arr.push(`--${kebabCase}=${value}`);
8
+ if (value === true || typeof value !== 'boolean') {
9
+ // Boolean flags don't need a value (e.g. --debug)
10
+ arr.push(`--${kebabCase}` + (typeof value !== 'boolean' ? `=${value}` : ''));
11
+ }
9
12
  }
10
13
  return arr;
11
14
  }, []);
@@ -45,6 +45,7 @@ export interface NextServeBuilderOptions {
45
45
  keepAliveTimeout?: number;
46
46
  turbo?: boolean;
47
47
  experimentalHttps?: boolean;
48
+ customServerHttps?: boolean;
48
49
  }
49
50
  export interface NextExportBuilderOptions {
50
51
  buildTarget: string;
@@ -1,3 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export declare function update(tree: Tree): Promise<import("@nx/devkit").GeneratorCallback>;
3
- export default update;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.update = void 0;
4
- const devkit_1 = require("@nx/devkit");
5
- async function update(tree) {
6
- const projects = (0, devkit_1.getProjects)(tree);
7
- const missingDeps = {};
8
- for (const [, config] of projects) {
9
- if (config.targets?.build?.executor === '@nrwl/next:build' &&
10
- tree.exists((0, devkit_1.joinPathFragments)(config.root, 'next.config.js'))) {
11
- const nextConfigContent = tree.read((0, devkit_1.joinPathFragments)(config.root, 'next.config.js'), 'utf-8');
12
- if (nextConfigContent.includes('@nrwl/next/plugins/with-less')) {
13
- missingDeps['less'] = '3.12.2';
14
- }
15
- if (nextConfigContent.includes('@nrwl/next/plugins/with-stylus')) {
16
- missingDeps['stylus'] = '^0.55.0';
17
- }
18
- }
19
- }
20
- return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, missingDeps);
21
- }
22
- exports.update = update;
23
- exports.default = update;