@nx/next 23.2.0-beta.3 → 23.2.0-beta.5
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/dist/plugins/component-testing.js +7 -6
- package/dist/plugins/with-nx.js +1 -1
- package/dist/src/executors/build/lib/update-package-json.d.ts +1 -1
- package/dist/src/migrations/update-23-2-0/add-svgr-webpack-if-used.d.ts +2 -0
- package/dist/src/migrations/update-23-2-0/add-svgr-webpack-if-used.js +33 -0
- package/dist/src/migrations/update-23-2-0/add-svgr-webpack-if-used.md +28 -0
- package/dist/src/plugins/plugin.js +2 -4
- package/dist/src/utils/add-gitignore-entry.d.ts +1 -1
- package/dist/src/utils/create-copy-plugin.js +11 -11
- package/dist/src/utils/versions.d.ts +1 -0
- package/dist/src/utils/versions.js +2 -1
- package/migrations.json +6 -0
- package/package.json +17 -12
|
@@ -7,16 +7,17 @@ const devkit_1 = require("@nx/devkit");
|
|
|
7
7
|
const internal_2 = require("@nx/js/internal");
|
|
8
8
|
const react_1 = require("@nx/react");
|
|
9
9
|
const internal_3 = require("@nx/react/internal");
|
|
10
|
-
const webpack_1 = require("@nx/webpack");
|
|
11
|
-
const internal_4 = require("@nx/webpack/internal");
|
|
12
|
-
const configuration_1 = require("nx/src/config/configuration");
|
|
13
10
|
const path_1 = require("path");
|
|
11
|
+
const internal_4 = require("@nx/devkit/internal");
|
|
14
12
|
function nxComponentTestingPreset(pathToConfig, options) {
|
|
15
13
|
if (global.NX_GRAPH_CREATION) {
|
|
16
14
|
// this is only used by plugins, so we don't need the component testing
|
|
17
15
|
// options, cast to any to avoid type errors
|
|
18
16
|
return (0, cypress_preset_1.nxBaseCypressPreset)(pathToConfig);
|
|
19
17
|
}
|
|
18
|
+
(0, internal_3.assertPackageIsInstalled)('@nx/webpack', '@nx/next/plugins/component-testing');
|
|
19
|
+
const { composePluginsSync, withNx, } = require('@nx/webpack');
|
|
20
|
+
const { suppressWebpackComposeHelperWarnings, } = require('@nx/webpack/internal');
|
|
20
21
|
const graph = (0, devkit_1.readCachedProjectGraph)();
|
|
21
22
|
const { targets: ctTargets, name: ctProjectName } = (0, internal_1.getProjectConfigByPath)(graph, pathToConfig);
|
|
22
23
|
const ctTargetName = options?.ctTargetName || 'component-test';
|
|
@@ -39,7 +40,7 @@ function nxComponentTestingPreset(pathToConfig, options) {
|
|
|
39
40
|
cwd: process.cwd(),
|
|
40
41
|
root: devkit_1.workspaceRoot,
|
|
41
42
|
projectsConfigurations: (0, devkit_1.readProjectsConfigurationFromProjectGraph)(graph),
|
|
42
|
-
nxJsonConfiguration: (0,
|
|
43
|
+
nxJsonConfiguration: (0, internal_4.readNxJsonFromDisk)(devkit_1.workspaceRoot),
|
|
43
44
|
isVerbose: false,
|
|
44
45
|
projectName: ctProjectName,
|
|
45
46
|
projectGraph: graph,
|
|
@@ -83,8 +84,8 @@ Able to find CT project, ${!!ctProjectConfig}.`);
|
|
|
83
84
|
};
|
|
84
85
|
// Nx composes these helpers internally for the Cypress CT preset; suppress
|
|
85
86
|
// their deprecation warning so it fires only for user-authored configs.
|
|
86
|
-
const webpackConfig =
|
|
87
|
-
const configure =
|
|
87
|
+
const webpackConfig = suppressWebpackComposeHelperWarnings(() => (0, internal_3.suppressReactComposeHelperWarnings)(() => {
|
|
88
|
+
const configure = composePluginsSync(withNx({
|
|
88
89
|
target: 'web',
|
|
89
90
|
styles: [],
|
|
90
91
|
scripts: [],
|
package/dist/plugins/with-nx.js
CHANGED
|
@@ -103,7 +103,7 @@ function withNx(_nextConfig = {}, context = getWithNxContext()) {
|
|
|
103
103
|
if (!graph.dependencies[project])
|
|
104
104
|
return;
|
|
105
105
|
const { readTsConfigPaths } = require('@nx/js');
|
|
106
|
-
const { findAllProjectNodeDependencies, } = require('nx/
|
|
106
|
+
const { findAllProjectNodeDependencies, } = require('@nx/devkit/internal');
|
|
107
107
|
const paths = readTsConfigPaths();
|
|
108
108
|
const deps = findAllProjectNodeDependencies(project);
|
|
109
109
|
nextConfig.transpilePackages ??= [];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ExecutorContext } from '@nx/devkit';
|
|
2
|
-
import type
|
|
2
|
+
import { type PackageJson } from '@nx/devkit/internal';
|
|
3
3
|
export declare function updatePackageJson(packageJson: PackageJson, context: ExecutorContext): void;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = addSvgrWebpackIfUsed;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const versions_1 = require("../../utils/versions");
|
|
6
|
+
// The Nx 22 `add-svgr-to-next-config` migration inlined a `withSvgr` helper
|
|
7
|
+
// that resolves `@svgr/webpack` into user next configs, but never added the
|
|
8
|
+
// package to the workspace - it only resolved transitively through `@nx/next`.
|
|
9
|
+
// Now that `@nx/next` no longer depends on it, backfill it where a next config
|
|
10
|
+
// actually references it.
|
|
11
|
+
const nextConfigFileNames = [
|
|
12
|
+
'next.config.js',
|
|
13
|
+
'next.config.cjs',
|
|
14
|
+
'next.config.mjs',
|
|
15
|
+
'next.config.ts',
|
|
16
|
+
];
|
|
17
|
+
async function addSvgrWebpackIfUsed(tree) {
|
|
18
|
+
let needsSvgr = false;
|
|
19
|
+
for (const [, project] of (0, devkit_1.getProjects)(tree)) {
|
|
20
|
+
for (const fileName of nextConfigFileNames) {
|
|
21
|
+
const path = (0, devkit_1.joinPathFragments)(project.root, fileName);
|
|
22
|
+
needsSvgr ||=
|
|
23
|
+
tree.exists(path) && tree.read(path, 'utf-8').includes('@svgr/webpack');
|
|
24
|
+
}
|
|
25
|
+
if (needsSvgr) {
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (!needsSvgr) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@svgr/webpack': versions_1.svgrWebpackVersion }, undefined, true);
|
|
33
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#### Add `@svgr/webpack` If Used
|
|
2
|
+
|
|
3
|
+
Adds `@svgr/webpack` to the workspace when a next config references it.
|
|
4
|
+
|
|
5
|
+
`@svgr/webpack` is no longer a dependency of `@nx/next`, so workspaces whose next configs resolve it - which is what the Nx 22 `add-svgr-to-next-config` migration inlined - must declare it themselves. This migration backfills it for those workspaces. Workspaces that already have `@svgr/webpack` are left untouched.
|
|
6
|
+
|
|
7
|
+
#### Examples
|
|
8
|
+
|
|
9
|
+
##### Before
|
|
10
|
+
|
|
11
|
+
```jsonc title="package.json"
|
|
12
|
+
{
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@nx/next": "23.1.0",
|
|
15
|
+
},
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
##### After
|
|
20
|
+
|
|
21
|
+
```jsonc title="package.json"
|
|
22
|
+
{
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@nx/next": "23.1.0",
|
|
25
|
+
"@svgr/webpack": "^8.0.1",
|
|
26
|
+
},
|
|
27
|
+
}
|
|
28
|
+
```
|
|
@@ -6,8 +6,6 @@ const devkit_1 = require("@nx/devkit");
|
|
|
6
6
|
const js_1 = require("@nx/js");
|
|
7
7
|
const internal_2 = require("@nx/js/internal");
|
|
8
8
|
const fs_1 = require("fs");
|
|
9
|
-
const devkit_internals_1 = require("nx/src/devkit-internals");
|
|
10
|
-
const cache_directory_1 = require("nx/src/utils/cache-directory");
|
|
11
9
|
const path_1 = require("path");
|
|
12
10
|
const nextConfigBlob = '**/next.config.{ts,js,cjs,mjs}';
|
|
13
11
|
/**
|
|
@@ -20,8 +18,8 @@ exports.createDependencies = createDependencies;
|
|
|
20
18
|
exports.createNodes = [
|
|
21
19
|
nextConfigBlob,
|
|
22
20
|
async (configFiles, options, context) => {
|
|
23
|
-
const optionsHash = (0,
|
|
24
|
-
const cachePath = (0, path_1.join)(
|
|
21
|
+
const optionsHash = (0, internal_1.hashObject)(options);
|
|
22
|
+
const cachePath = (0, path_1.join)(internal_1.workspaceDataDirectory, `next-${optionsHash}.json`);
|
|
25
23
|
const targetsCache = new internal_1.PluginCache(cachePath);
|
|
26
24
|
const isTsSolutionSetup = (0, internal_2.isUsingTsSolutionSetup)();
|
|
27
25
|
const packageManager = (0, devkit_1.detectPackageManager)(context.workspaceRoot);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Tree } from 'nx/
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
2
|
export declare function addGitIgnoreEntry(host: Tree): void;
|
|
@@ -2,24 +2,24 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createCopyPlugin = createCopyPlugin;
|
|
4
4
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
5
|
-
const path_1 = require("
|
|
6
|
-
const path_2 = require("path");
|
|
5
|
+
const path_1 = require("path");
|
|
7
6
|
const fs_1 = require("fs");
|
|
7
|
+
const devkit_1 = require("@nx/devkit");
|
|
8
8
|
function normalizeAssets(assets, root, sourceRoot) {
|
|
9
9
|
return assets.map((asset) => {
|
|
10
10
|
if (typeof asset === 'string') {
|
|
11
|
-
const assetPath = (0,
|
|
12
|
-
const resolvedAssetPath = (0,
|
|
13
|
-
const resolvedSourceRoot = (0,
|
|
11
|
+
const assetPath = (0, devkit_1.normalizePath)(asset);
|
|
12
|
+
const resolvedAssetPath = (0, path_1.resolve)(root, assetPath);
|
|
13
|
+
const resolvedSourceRoot = (0, path_1.resolve)(root, sourceRoot);
|
|
14
14
|
if (!resolvedAssetPath.startsWith(resolvedSourceRoot)) {
|
|
15
15
|
throw new Error(`The ${resolvedAssetPath} asset path must start with the project source root: ${sourceRoot}`);
|
|
16
16
|
}
|
|
17
17
|
const isDirectory = (0, fs_1.statSync)(resolvedAssetPath).isDirectory();
|
|
18
18
|
const input = isDirectory
|
|
19
19
|
? resolvedAssetPath
|
|
20
|
-
: (0,
|
|
21
|
-
const output = (0,
|
|
22
|
-
const glob = isDirectory ? '**/*' : (0,
|
|
20
|
+
: (0, path_1.dirname)(resolvedAssetPath);
|
|
21
|
+
const output = (0, path_1.relative)(resolvedSourceRoot, (0, path_1.resolve)(root, input));
|
|
22
|
+
const glob = isDirectory ? '**/*' : (0, path_1.basename)(resolvedAssetPath);
|
|
23
23
|
return {
|
|
24
24
|
input,
|
|
25
25
|
output,
|
|
@@ -30,8 +30,8 @@ function normalizeAssets(assets, root, sourceRoot) {
|
|
|
30
30
|
if (asset.output.startsWith('..')) {
|
|
31
31
|
throw new Error('An asset cannot be written to a location outside of the output path.');
|
|
32
32
|
}
|
|
33
|
-
const assetPath = (0,
|
|
34
|
-
const resolvedAssetPath = (0,
|
|
33
|
+
const assetPath = (0, devkit_1.normalizePath)(asset.input);
|
|
34
|
+
const resolvedAssetPath = (0, path_1.resolve)(root, assetPath);
|
|
35
35
|
return {
|
|
36
36
|
...asset,
|
|
37
37
|
input: resolvedAssetPath,
|
|
@@ -46,7 +46,7 @@ function createCopyPlugin(assets, root, sourceRoot) {
|
|
|
46
46
|
patterns: normalizeAssets(assets, root, sourceRoot).map((asset) => {
|
|
47
47
|
return {
|
|
48
48
|
context: asset.input,
|
|
49
|
-
to: (0,
|
|
49
|
+
to: (0, path_1.join)('../public', asset.output),
|
|
50
50
|
from: asset.glob,
|
|
51
51
|
globOptions: {
|
|
52
52
|
ignore: [
|
|
@@ -10,3 +10,4 @@ export declare const eslintConfigNext14Version = "^15.5.18";
|
|
|
10
10
|
export declare const eslintConfigNextVersion = "^16.1.6";
|
|
11
11
|
export declare const sassVersion = "1.97.2";
|
|
12
12
|
export declare const tsLibVersion = "^2.3.0";
|
|
13
|
+
export declare const svgrWebpackVersion = "^8.0.1";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.tsLibVersion = exports.sassVersion = exports.eslintConfigNextVersion = exports.eslintConfigNext14Version = exports.eslintConfigNext15Version = exports.eslintConfigNext16Version = exports.nextVersion = exports.next14Version = exports.next15Version = exports.next16Version = exports.minSupportedNextVersion = exports.nxVersion = void 0;
|
|
3
|
+
exports.svgrWebpackVersion = exports.tsLibVersion = exports.sassVersion = exports.eslintConfigNextVersion = exports.eslintConfigNext14Version = exports.eslintConfigNext15Version = exports.eslintConfigNext16Version = exports.nextVersion = exports.next14Version = exports.next15Version = exports.next16Version = exports.minSupportedNextVersion = exports.nxVersion = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
exports.nxVersion = require((0, path_1.join)('@nx/next', 'package.json')).version;
|
|
6
6
|
exports.minSupportedNextVersion = '14.0.0';
|
|
@@ -15,3 +15,4 @@ exports.eslintConfigNext14Version = '^15.5.18';
|
|
|
15
15
|
exports.eslintConfigNextVersion = exports.eslintConfigNext16Version;
|
|
16
16
|
exports.sassVersion = '1.97.2';
|
|
17
17
|
exports.tsLibVersion = '^2.3.0';
|
|
18
|
+
exports.svgrWebpackVersion = '^8.0.1';
|
package/migrations.json
CHANGED
|
@@ -29,6 +29,12 @@
|
|
|
29
29
|
"description": "Create AI instructions to help migrate workspaces from Next.js 14 to 15.",
|
|
30
30
|
"prompt": "./dist/src/migrations/update-23-1-0/ai-instructions-for-next-15.md",
|
|
31
31
|
"documentation": "./dist/src/migrations/update-23-1-0/upgrade-to-next-15.md"
|
|
32
|
+
},
|
|
33
|
+
"update-23-2-0-add-svgr-webpack-if-used": {
|
|
34
|
+
"version": "23.2.0-beta.4",
|
|
35
|
+
"description": "Add `@svgr/webpack` when a next config references it.",
|
|
36
|
+
"implementation": "./dist/src/migrations/update-23-2-0/add-svgr-webpack-if-used",
|
|
37
|
+
"documentation": "./dist/src/migrations/update-23-2-0/add-svgr-webpack-if-used.md"
|
|
32
38
|
}
|
|
33
39
|
},
|
|
34
40
|
"packageJsonUpdates": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/next",
|
|
3
|
-
"version": "23.2.0-beta.
|
|
3
|
+
"version": "23.2.0-beta.5",
|
|
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": {
|
|
@@ -67,28 +67,33 @@
|
|
|
67
67
|
"supportsOptionalMigrations": true
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
|
-
"next": ">=14.0.0 <17.0.0"
|
|
70
|
+
"next": ">=14.0.0 <17.0.0",
|
|
71
|
+
"@nx/webpack": "23.2.0-beta.5"
|
|
72
|
+
},
|
|
73
|
+
"peerDependenciesMeta": {
|
|
74
|
+
"@nx/webpack": {
|
|
75
|
+
"optional": true
|
|
76
|
+
}
|
|
71
77
|
},
|
|
72
78
|
"dependencies": {
|
|
73
79
|
"@babel/plugin-proposal-decorators": "^7.22.7",
|
|
74
|
-
"@svgr/webpack": "^8.0.1",
|
|
75
80
|
"copy-webpack-plugin": "^14.0.0",
|
|
76
81
|
"ignore": "^7.0.5",
|
|
77
82
|
"semver": "^7.6.3",
|
|
78
83
|
"tslib": "^2.3.0",
|
|
79
84
|
"webpack-merge": "^5.8.0",
|
|
80
85
|
"@phenomnomnominal/tsquery": "~6.2.0",
|
|
81
|
-
"@nx/devkit": "23.2.0-beta.
|
|
82
|
-
"@nx/js": "23.2.0-beta.
|
|
83
|
-
"@nx/eslint": "23.2.0-beta.
|
|
84
|
-
"@nx/react": "23.2.0-beta.
|
|
85
|
-
"@nx/web": "23.2.0-beta.
|
|
86
|
-
"@nx/webpack": "23.2.0-beta.3"
|
|
86
|
+
"@nx/devkit": "23.2.0-beta.5",
|
|
87
|
+
"@nx/js": "23.2.0-beta.5",
|
|
88
|
+
"@nx/eslint": "23.2.0-beta.5",
|
|
89
|
+
"@nx/react": "23.2.0-beta.5",
|
|
90
|
+
"@nx/web": "23.2.0-beta.5"
|
|
87
91
|
},
|
|
88
92
|
"devDependencies": {
|
|
89
|
-
"@nx/cypress": "23.2.0-beta.
|
|
90
|
-
"@nx/playwright": "23.2.0-beta.
|
|
91
|
-
"nx": "23.2.0-beta.
|
|
93
|
+
"@nx/cypress": "23.2.0-beta.5",
|
|
94
|
+
"@nx/playwright": "23.2.0-beta.5",
|
|
95
|
+
"@nx/webpack": "23.2.0-beta.5",
|
|
96
|
+
"nx": "23.2.0-beta.5"
|
|
92
97
|
},
|
|
93
98
|
"publishConfig": {
|
|
94
99
|
"access": "public"
|