@nx/next 17.2.8 → 17.3.0-beta.2

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/README.md CHANGED
@@ -1,4 +1,9 @@
1
- <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Smart, Fast and Extensible Build System"></p>
1
+ <p style="text-align: center;">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-dark.svg">
4
+ <img alt="Nx - Smart Monorepos · Fast CI" src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-light.svg" width="100%">
5
+ </picture>
6
+ </p>
2
7
 
3
8
  <div style="text-align: center;">
4
9
 
@@ -15,9 +20,9 @@
15
20
 
16
21
  <hr>
17
22
 
18
- # Nx: Smart, Fast and Extensible Build System
23
+ # Nx: Smart Monorepos · Fast CI
19
24
 
20
- Nx is a next generation build system with first class monorepo support and powerful integrations.
25
+ Nx is a build system with built-in tooling and advanced CI capabilities. It helps you maintain and scale monorepos, both locally and on CI.
21
26
 
22
27
  This package is a [Next.js plugin for Nx](https://nx.dev/next/overview).
23
28
 
@@ -59,5 +64,5 @@ npx nx@latest init
59
64
  - [Blog Posts About Nx](https://blog.nrwl.io/nx/home)
60
65
 
61
66
  <p style="text-align: center;"><a href="https://nx.dev/#learning-materials" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-courses-and-videos.svg"
62
- width="100%" alt="Nx - Smart, Fast and Extensible Build System"></a></p>
67
+ width="100%" alt="Nx - Smart Monorepos · Fast CI"></a></p>
63
68
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/next",
3
- "version": "17.2.8",
3
+ "version": "17.3.0-beta.2",
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, Cypress, and Jest. No need to configure anything: watch mode, source maps, and typings just work.",
6
6
  "repository": {
@@ -34,7 +34,7 @@
34
34
  "next": ">=13.0.0"
35
35
  },
36
36
  "dependencies": {
37
- "@nx/devkit": "17.2.8",
37
+ "@nx/devkit": "17.3.0-beta.2",
38
38
  "@babel/plugin-proposal-decorators": "^7.22.7",
39
39
  "@svgr/webpack": "^8.0.1",
40
40
  "chalk": "^4.1.0",
@@ -45,12 +45,12 @@
45
45
  "url-loader": "^4.1.1",
46
46
  "tslib": "^2.3.0",
47
47
  "webpack-merge": "^5.8.0",
48
- "@nx/js": "17.2.8",
49
- "@nx/eslint": "17.2.8",
50
- "@nx/react": "17.2.8",
51
- "@nx/web": "17.2.8",
52
- "@nx/workspace": "17.2.8",
53
- "@nrwl/next": "17.2.8"
48
+ "@nx/js": "17.3.0-beta.2",
49
+ "@nx/eslint": "17.3.0-beta.2",
50
+ "@nx/react": "17.3.0-beta.2",
51
+ "@nx/web": "17.3.0-beta.2",
52
+ "@nx/workspace": "17.3.0-beta.2",
53
+ "@nrwl/next": "17.3.0-beta.2"
54
54
  },
55
55
  "publishConfig": {
56
56
  "access": "public"
@@ -10,7 +10,16 @@ function updatePackageJson(packageJson, context) {
10
10
  }
11
11
  packageJson.dependencies ??= {};
12
12
  // These are always required for a production Next.js app to run.
13
- const requiredPackages = ['react', 'react-dom', 'next', 'typescript'];
13
+ // sharp is for next/image https://nextjs.org/docs/messages/sharp-missing-in-production
14
+ // critters is required for experimental optimizing CSS
15
+ const requiredPackages = [
16
+ 'react',
17
+ 'react-dom',
18
+ 'next',
19
+ 'typescript',
20
+ 'sharp',
21
+ 'critters',
22
+ ];
14
23
  for (const pkg of requiredPackages) {
15
24
  const externalNode = context.projectGraph.externalNodes[`npm:${pkg}`];
16
25
  if (externalNode) {
@@ -2,11 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const devkit_1 = require("@nx/devkit");
4
4
  const export_1 = require("next/dist/export");
5
- const buildable_libs_utils_1 = require("@nx/js/src/utils/buildable-libs-utils");
6
5
  const nextTrace = require("next/dist/trace");
7
6
  const os_1 = require("os");
8
7
  const child_process_1 = require("child_process");
9
8
  const chalk = require("chalk");
9
+ const semver_1 = require("semver");
10
10
  // platform specific command name
11
11
  const pmCmd = (0, os_1.platform)() === 'win32' ? `npx.cmd` : 'npx';
12
12
  /**
@@ -22,11 +22,9 @@ const pmCmd = (0, os_1.platform)() === 'win32' ? `npx.cmd` : 'npx';
22
22
  * Read https://nextjs.org/docs/pages/building-your-application/deploying/static-exports
23
23
  **/
24
24
  async function exportExecutor(options, context) {
25
- let dependencies = [];
26
- if (!options.buildLibsFromSource) {
27
- const result = (0, buildable_libs_utils_1.calculateProjectBuildableDependencies)(context.taskGraph, context.projectGraph, context.root, context.projectName, 'build', // this should be generalized
28
- context.configurationName);
29
- dependencies = result.dependencies;
25
+ const nextJsVersion = require('next/package.json').version;
26
+ if ((0, semver_1.satisfies)(nextJsVersion, '>=14.0.0')) {
27
+ throw new Error('The export command has been removed in Next.js 14. Please update your Next config to use the output property. Read more: https://nextjs.org/docs/pages/building-your-application/deploying/static-exports');
30
28
  }
31
29
  // Returns { project: ProjectGraphNode; target: string; configuration?: string;}
32
30
  const buildTarget = (0, devkit_1.parseTargetString)(options.buildTarget, context);
@@ -52,6 +52,10 @@
52
52
  "turbo": {
53
53
  "type": "boolean",
54
54
  "description": "Activate the incremental bundler for Next.js, which is implemented in Rust. Please note, this feature is exclusively available in development mode."
55
+ },
56
+ "experimentalHttps": {
57
+ "type": "boolean",
58
+ "description": "Enable HTTPS support for the Next.js development server."
55
59
  }
56
60
  },
57
61
  "required": ["buildTarget"],
@@ -32,9 +32,10 @@ async function* serveExecutor(options, context) {
32
32
  const nextDir = (0, path_1.resolve)(context.root, buildOptions.outputPath);
33
33
  const mode = options.dev ? 'dev' : 'start';
34
34
  const turbo = options.turbo && options.dev ? '--turbo' : '';
35
+ const experimentalHttps = options.experimentalHttps && options.dev ? '--experimental-https' : '';
35
36
  const nextBin = require.resolve('next/dist/bin/next');
36
37
  yield* (0, async_iterable_1.createAsyncIterable)(async ({ done, next, error }) => {
37
- const server = (0, child_process_1.fork)(nextBin, [mode, ...args, turbo], {
38
+ const server = (0, child_process_1.fork)(nextBin, [mode, ...args, turbo, experimentalHttps], {
38
39
  cwd: options.dev ? projectRoot : nextDir,
39
40
  stdio: 'inherit',
40
41
  });
@@ -294,7 +294,7 @@ function createAppJsx(name) {
294
294
  <path strokeWidth="2" d="M23 6v14.1667C23 21.7307 21.7307 23 20.1667 23H6c0-3.128 2.53867-5.6667 5.6667-5.6667 3.128 0 5.6666-2.5386 5.6666-5.6666C17.3333 8.53867 19.872 6 23 6Z" />
295
295
  </svg>
296
296
  <h2>
297
- NxCloud
297
+ Nx Cloud
298
298
  <span>
299
299
  Enable faster CI & better DX
300
300
  </span>
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  import { CreateDependencies, CreateNodes } from '@nx/devkit';
2
3
  export interface NextPluginOptions {
3
4
  buildTargetName?: string;
@@ -6,3 +7,4 @@ export interface NextPluginOptions {
6
7
  }
7
8
  export declare const createDependencies: CreateDependencies;
8
9
  export declare const createNodes: CreateNodes<NextPluginOptions>;
10
+ 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.createNodes = exports.createDependencies = void 0;
3
+ exports.loadEsmModule = 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");
@@ -23,9 +23,8 @@ const createDependencies = () => {
23
23
  return [];
24
24
  };
25
25
  exports.createDependencies = createDependencies;
26
- // TODO(nicholas): Add support for .mjs files
27
26
  exports.createNodes = [
28
- '**/next.config.{js, cjs}',
27
+ '**/next.config.{js,cjs,mjs}',
29
28
  async (configFilePath, options, context) => {
30
29
  const projectRoot = (0, path_1.dirname)(configFilePath);
31
30
  // Do not create a project if package.json and project.json isn't there.
@@ -52,7 +51,7 @@ exports.createNodes = [
52
51
  },
53
52
  ];
54
53
  async function buildNextTargets(nextConfigPath, projectRoot, options, context) {
55
- const nextConfig = getNextConfig(nextConfigPath, context);
54
+ const nextConfig = await getNextConfig(nextConfigPath, context);
56
55
  const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
57
56
  const targets = {};
58
57
  targets[options.buildTargetName] = await getBuildTargetConfig(namedInputs, projectRoot, nextConfig);
@@ -114,9 +113,15 @@ async function getOutputs(projectRoot, nextConfig) {
114
113
  return `{workspaceRoot}/${projectRoot}/${dir}`;
115
114
  }
116
115
  }
117
- function getNextConfig(configFilePath, context) {
116
+ async function getNextConfig(configFilePath, context) {
118
117
  const resolvedPath = (0, path_1.join)(context.workspaceRoot, configFilePath);
119
- const module = load(resolvedPath);
118
+ let module;
119
+ if ((0, path_1.extname)(configFilePath) === '.mjs') {
120
+ module = await loadEsmModule(resolvedPath);
121
+ }
122
+ else {
123
+ module = load(resolvedPath);
124
+ }
120
125
  return module.default ?? module;
121
126
  }
122
127
  function normalizeOptions(options) {
@@ -136,16 +141,29 @@ function getInputs(namedInputs) {
136
141
  },
137
142
  ];
138
143
  }
144
+ const packageInstallationDirectories = ['node_modules', '.yarn'];
139
145
  /**
140
146
  * Load the module after ensuring that the require cache is cleared.
141
147
  */
142
148
  function load(path) {
143
149
  // Clear cache if the path is in the cache
144
150
  if (require.cache[path]) {
145
- for (const k of Object.keys(require.cache)) {
146
- delete require.cache[k];
151
+ for (const key of Object.keys(require.cache)) {
152
+ if (!packageInstallationDirectories.some((dir) => key.includes(dir))) {
153
+ delete require.cache[key];
154
+ }
147
155
  }
148
156
  }
149
157
  // Then require
150
158
  return require(path);
151
159
  }
160
+ /**
161
+ * Lazily compiled dynamic import loader function.
162
+ */
163
+ let dynamicLoad;
164
+ function loadEsmModule(modulePath) {
165
+ const modulePathWithCacheBust = `${modulePath}?version=${Date.now()}`;
166
+ dynamicLoad ??= new Function('modulePath', `return import(modulePath);`);
167
+ return dynamicLoad(modulePathWithCacheBust);
168
+ }
169
+ exports.loadEsmModule = loadEsmModule;
@@ -44,6 +44,7 @@ export interface NextServeBuilderOptions {
44
44
  buildLibsFromSource?: boolean;
45
45
  keepAliveTimeout?: number;
46
46
  turbo?: boolean;
47
+ experimentalHttps?: boolean;
47
48
  }
48
49
  export interface NextExportBuilderOptions {
49
50
  buildTarget: string;
@@ -1,6 +1,6 @@
1
1
  export declare const nxVersion: any;
2
- export declare const nextVersion = "13.4.4";
3
- export declare const eslintConfigNextVersion = "13.4.4";
2
+ export declare const nextVersion = "14.0.4";
3
+ export declare const eslintConfigNextVersion = "14.0.4";
4
4
  export declare const sassVersion = "1.62.1";
5
5
  export declare const lessLoader = "11.1.0";
6
6
  export declare const emotionServerVersion = "11.11.0";
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.tsLibVersion = exports.babelPluginStyledComponentsVersion = exports.emotionServerVersion = exports.lessLoader = exports.sassVersion = exports.eslintConfigNextVersion = exports.nextVersion = exports.nxVersion = void 0;
4
4
  exports.nxVersion = require('../../package.json').version;
5
- exports.nextVersion = '13.4.4';
6
- exports.eslintConfigNextVersion = '13.4.4';
5
+ exports.nextVersion = '14.0.4';
6
+ exports.eslintConfigNextVersion = '14.0.4';
7
7
  exports.sassVersion = '1.62.1';
8
8
  exports.lessLoader = '11.1.0';
9
9
  exports.emotionServerVersion = '11.11.0';