@nx/next 23.1.1 → 23.1.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/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/generators/application/application.js +6 -7
- package/dist/src/generators/custom-server/custom-server.js +14 -15
- package/dist/src/generators/library/library.js +21 -4
- package/dist/src/generators/library/schema.d.ts +2 -0
- package/dist/src/generators/library/schema.json +19 -6
- 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/compose-plugins.js +13 -2
- 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/generators.json +1 -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;
|
|
@@ -7,7 +7,6 @@ const devkit_1 = require("@nx/devkit");
|
|
|
7
7
|
const assert_supported_next_version_1 = require("../../utils/assert-supported-next-version");
|
|
8
8
|
const js_1 = require("@nx/js");
|
|
9
9
|
const internal_2 = require("@nx/react/internal");
|
|
10
|
-
const internal_3 = require("@nx/react/internal");
|
|
11
10
|
const normalize_options_1 = require("./lib/normalize-options");
|
|
12
11
|
const add_e2e_1 = require("./lib/add-e2e");
|
|
13
12
|
const add_jest_1 = require("./lib/add-jest");
|
|
@@ -20,7 +19,7 @@ const add_linting_1 = require("./lib/add-linting");
|
|
|
20
19
|
const custom_server_1 = require("../custom-server/custom-server");
|
|
21
20
|
const update_cypress_tsconfig_1 = require("./lib/update-cypress-tsconfig");
|
|
22
21
|
const versions_1 = require("../../utils/versions");
|
|
23
|
-
const
|
|
22
|
+
const internal_3 = require("@nx/js/internal");
|
|
24
23
|
const add_swc_to_custom_server_1 = require("../../utils/add-swc-to-custom-server");
|
|
25
24
|
const jest_config_util_1 = require("../../utils/jest-config-util");
|
|
26
25
|
async function applicationGenerator(host, schema) {
|
|
@@ -33,7 +32,7 @@ async function applicationGenerator(host, schema) {
|
|
|
33
32
|
async function applicationGeneratorInternal(host, schema) {
|
|
34
33
|
(0, assert_supported_next_version_1.assertSupportedNextVersion)(host);
|
|
35
34
|
const tasks = [];
|
|
36
|
-
const addTsPlugin = (0,
|
|
35
|
+
const addTsPlugin = (0, internal_3.shouldConfigureTsSolutionSetup)(host, schema.addPlugin, schema.useTsSolution);
|
|
37
36
|
const jsInitTask = await (0, js_1.initGenerator)(host, {
|
|
38
37
|
js: schema.js,
|
|
39
38
|
skipPackageJson: schema.skipPackageJson,
|
|
@@ -54,7 +53,7 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
54
53
|
// If we are using the new TS solution
|
|
55
54
|
// We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
|
|
56
55
|
if (options.isTsSolutionSetup) {
|
|
57
|
-
await (0,
|
|
56
|
+
await (0, internal_3.addProjectToTsSolutionWorkspace)(host, options.appProjectRoot);
|
|
58
57
|
}
|
|
59
58
|
const lintTask = await (0, add_linting_1.addLinting)(host, options);
|
|
60
59
|
tasks.push(lintTask);
|
|
@@ -81,7 +80,7 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
81
80
|
});
|
|
82
81
|
}
|
|
83
82
|
if (!options.skipPackageJson) {
|
|
84
|
-
const reactVersions = await (0,
|
|
83
|
+
const reactVersions = await (0, internal_2.getReactDependenciesVersionsToInstall)(host);
|
|
85
84
|
const devDependencies = {
|
|
86
85
|
'@types/react': reactVersions['@types/react'],
|
|
87
86
|
'@types/react-dom': reactVersions['@types/react-dom'],
|
|
@@ -92,14 +91,14 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
92
91
|
}
|
|
93
92
|
tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, { tslib: versions_1.tsLibVersion }, devDependencies, undefined, true));
|
|
94
93
|
}
|
|
95
|
-
(0,
|
|
94
|
+
(0, internal_3.updateTsconfigFiles)(host, options.appProjectRoot, 'tsconfig.json', {
|
|
96
95
|
jsx: 'preserve',
|
|
97
96
|
module: 'esnext',
|
|
98
97
|
moduleResolution: 'bundler',
|
|
99
98
|
}, options.linter === 'eslint'
|
|
100
99
|
? ['.next', 'eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
|
|
101
100
|
: ['.next'], options.src ? 'src' : '.');
|
|
102
|
-
(0,
|
|
101
|
+
(0, internal_3.sortPackageJsonFields)(host, options.appProjectRoot);
|
|
103
102
|
if (!options.skipFormat) {
|
|
104
103
|
await (0, devkit_1.formatFiles)(host);
|
|
105
104
|
}
|
|
@@ -3,21 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.customServerGenerator = customServerGenerator;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const internal_1 = require("@nx/devkit/internal");
|
|
6
|
-
const devkit_2 = require("@nx/devkit");
|
|
7
6
|
const path_1 = require("path");
|
|
8
7
|
const add_swc_to_custom_server_1 = require("../../utils/add-swc-to-custom-server");
|
|
9
8
|
const internal_2 = require("@nx/js/internal");
|
|
10
9
|
const assert_supported_next_version_1 = require("../../utils/assert-supported-next-version");
|
|
11
10
|
async function customServerGenerator(host, options) {
|
|
12
11
|
(0, assert_supported_next_version_1.assertSupportedNextVersion)(host);
|
|
13
|
-
const project = (0,
|
|
12
|
+
const project = (0, devkit_1.readProjectConfiguration)(host, options.project);
|
|
14
13
|
const swcServerName = '.server.swcrc';
|
|
15
|
-
const nxJson = (0,
|
|
14
|
+
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
16
15
|
const hasPlugin = nxJson.plugins?.some((p) => typeof p === 'string'
|
|
17
16
|
? p === '@nx/next/plugin'
|
|
18
17
|
: p.plugin === '@nx/next/plugin');
|
|
19
18
|
if (project.targets?.build?.executor !== '@nx/next:build' && !hasPlugin) {
|
|
20
|
-
|
|
19
|
+
devkit_1.logger.error(`Project ${options.project} is not a Next.js project. Did you generate it with "nx g @nx/next:app"?`);
|
|
21
20
|
return;
|
|
22
21
|
}
|
|
23
22
|
// In Nx 18 next artifacts are inside the project root .next/ & dist/ (for custom server)
|
|
@@ -28,22 +27,22 @@ async function customServerGenerator(host, options) {
|
|
|
28
27
|
!project.targets?.build?.configurations?.development ||
|
|
29
28
|
!project.targets?.build?.configurations?.production) &&
|
|
30
29
|
!hasPlugin) {
|
|
31
|
-
|
|
30
|
+
devkit_1.logger.error(`Project ${options.project} has invalid config. Did you generate it with "nx g @nx/next:app"?`);
|
|
32
31
|
return;
|
|
33
32
|
}
|
|
34
33
|
if (project.targets?.['build-custom-server'] ||
|
|
35
34
|
project.targets?.['serve-custom-server']) {
|
|
36
|
-
|
|
35
|
+
devkit_1.logger.warn(`Project ${options.project} has custom server targets already: build-custom-server, serve-custom-server. Remove these targets from project and try again.`);
|
|
37
36
|
return;
|
|
38
37
|
}
|
|
39
38
|
// In Nx 18 next artifacts are inside the project root .next/ & dist/ (for custom server)
|
|
40
39
|
// So we need ensure the mapping is correct from dist to the project root
|
|
41
40
|
const projectPathFromDist = hasPlugin
|
|
42
|
-
? `../../${(0,
|
|
43
|
-
: `${(0,
|
|
44
|
-
const offset = (0,
|
|
41
|
+
? `../../${(0, devkit_1.offsetFromRoot)(project.root)}${project.root}`
|
|
42
|
+
: `${(0, devkit_1.offsetFromRoot)(`dist/${project.root}`)}${project.root}`;
|
|
43
|
+
const offset = (0, devkit_1.offsetFromRoot)(project.root);
|
|
45
44
|
const isTsSolution = (0, internal_2.isUsingTsSolutionSetup)(host);
|
|
46
|
-
(0,
|
|
45
|
+
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, 'files'), project.root, {
|
|
47
46
|
...options,
|
|
48
47
|
hasPlugin,
|
|
49
48
|
projectPathFromDist,
|
|
@@ -98,23 +97,23 @@ async function customServerGenerator(host, options) {
|
|
|
98
97
|
},
|
|
99
98
|
},
|
|
100
99
|
};
|
|
101
|
-
(0,
|
|
102
|
-
(0,
|
|
100
|
+
(0, devkit_1.updateProjectConfiguration)(host, options.project, project);
|
|
101
|
+
(0, devkit_1.updateJson)(host, 'nx.json', (json) => {
|
|
103
102
|
if (!json.tasksRunnerOptions?.default?.options?.cacheableOperations?.includes('build-custom-server') &&
|
|
104
103
|
json.tasksRunnerOptions?.default?.options?.cacheableOperations) {
|
|
105
104
|
json.tasksRunnerOptions.default.options.cacheableOperations.push('build-custom-server');
|
|
106
105
|
}
|
|
107
106
|
return json;
|
|
108
107
|
});
|
|
109
|
-
const updatedNxJson = (0,
|
|
108
|
+
const updatedNxJson = (0, devkit_1.readNxJson)(host) ?? {};
|
|
110
109
|
(0, internal_1.upsertTargetDefault)(host, updatedNxJson, {
|
|
111
110
|
target: 'build-custom-server',
|
|
112
111
|
cache: true,
|
|
113
112
|
});
|
|
114
|
-
(0,
|
|
113
|
+
(0, devkit_1.updateNxJson)(host, updatedNxJson);
|
|
115
114
|
if (options.compiler === 'swc') {
|
|
116
115
|
// Update app swc to exlude server files
|
|
117
|
-
(0,
|
|
116
|
+
(0, devkit_1.updateJson)(host, (0, path_1.join)(project.root, '.swcrc'), (json) => {
|
|
118
117
|
json.exclude = [...(json.exclude ?? []), 'server/**'];
|
|
119
118
|
return json;
|
|
120
119
|
});
|
|
@@ -43,10 +43,6 @@ async function libraryGeneratorInternal(host, rawOptions) {
|
|
|
43
43
|
tasks.push(libTask);
|
|
44
44
|
if (!options.skipPackageJson) {
|
|
45
45
|
const devDependencies = {};
|
|
46
|
-
if (options.linter === 'eslint') {
|
|
47
|
-
devDependencies['eslint-config-next'] = versions_1.eslintConfigNextVersion;
|
|
48
|
-
devDependencies['@next/eslint-plugin-next'] = versions_1.eslintConfigNextVersion;
|
|
49
|
-
}
|
|
50
46
|
if (options.unitTestRunner && options.unitTestRunner !== 'none') {
|
|
51
47
|
devDependencies['@testing-library/react'] = internal_1.testingLibraryReactVersion;
|
|
52
48
|
devDependencies['@testing-library/dom'] = internal_1.testingLibraryDomVersion;
|
|
@@ -71,6 +67,27 @@ export async function HelloServer() {
|
|
|
71
67
|
if (!options.skipTsConfig && !isTsSolutionSetup) {
|
|
72
68
|
(0, js_1.addTsConfigPath)(host, `${options.importPath}/server`, [serverEntryPath]);
|
|
73
69
|
}
|
|
70
|
+
const isBuildable = (options.bundler && options.bundler !== 'none') ||
|
|
71
|
+
options.buildable ||
|
|
72
|
+
options.publishable;
|
|
73
|
+
if (isTsSolutionSetup && !isBuildable) {
|
|
74
|
+
// Non-buildable libs resolve `.` straight to source, so `./server` does the same.
|
|
75
|
+
const packageJsonPath = (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json');
|
|
76
|
+
if (host.exists(packageJsonPath)) {
|
|
77
|
+
(0, devkit_1.updateJson)(host, packageJsonPath, (json) => {
|
|
78
|
+
json.exports ??= {};
|
|
79
|
+
const serverSource = `./src/server.${options.js ? 'js' : 'ts'}`;
|
|
80
|
+
json.exports['./server'] = options.js
|
|
81
|
+
? serverSource
|
|
82
|
+
: {
|
|
83
|
+
types: serverSource,
|
|
84
|
+
import: serverSource,
|
|
85
|
+
default: serverSource,
|
|
86
|
+
};
|
|
87
|
+
return json;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
74
91
|
// Configure Vite and package.json for server entry point when using Vite bundler
|
|
75
92
|
if (options.bundler === 'vite') {
|
|
76
93
|
// Update vite.config.mts to support multiple entry points
|
|
@@ -11,12 +11,14 @@ export interface Schema {
|
|
|
11
11
|
routing?: boolean;
|
|
12
12
|
appProject?: string;
|
|
13
13
|
unitTestRunner: 'jest' | 'vitest' | 'none';
|
|
14
|
+
inSourceTests?: boolean;
|
|
14
15
|
linter: Linter | LinterType;
|
|
15
16
|
component?: boolean;
|
|
16
17
|
publishable?: boolean;
|
|
17
18
|
/** @deprecated Use bundler instead. */
|
|
18
19
|
buildable?: boolean;
|
|
19
20
|
bundler?: 'none' | 'vite' | 'rollup';
|
|
21
|
+
compiler?: 'babel' | 'swc';
|
|
20
22
|
importPath?: string;
|
|
21
23
|
js?: boolean;
|
|
22
24
|
globalCss?: boolean;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json-schema.org/schema",
|
|
3
3
|
"cli": "nx",
|
|
4
|
-
"$id": "
|
|
5
|
-
"title": "Create a
|
|
6
|
-
"description": "Create a
|
|
4
|
+
"$id": "NxNextLibrary",
|
|
5
|
+
"title": "Create a Next.js Library for Nx",
|
|
6
|
+
"description": "Create a Next.js library for an Nx workspace. Same output as `@nx/react:library`, plus a `server` entry point for React Server Components and the Next.js type declarations.",
|
|
7
7
|
"type": "object",
|
|
8
8
|
"properties": {
|
|
9
9
|
"directory": {
|
|
@@ -71,6 +71,11 @@
|
|
|
71
71
|
"x-prompt": "What unit test runner should be used?",
|
|
72
72
|
"x-priority": "important"
|
|
73
73
|
},
|
|
74
|
+
"inSourceTests": {
|
|
75
|
+
"type": "boolean",
|
|
76
|
+
"default": false,
|
|
77
|
+
"description": "When using Vitest, separate spec files will not be generated and instead will be included within the source files."
|
|
78
|
+
},
|
|
74
79
|
"tags": {
|
|
75
80
|
"type": "string",
|
|
76
81
|
"description": "Add tags to the library (used for linting).",
|
|
@@ -79,12 +84,14 @@
|
|
|
79
84
|
"skipFormat": {
|
|
80
85
|
"description": "Skip formatting files.",
|
|
81
86
|
"type": "boolean",
|
|
82
|
-
"default": false
|
|
87
|
+
"default": false,
|
|
88
|
+
"x-priority": "internal"
|
|
83
89
|
},
|
|
84
90
|
"skipTsConfig": {
|
|
85
91
|
"type": "boolean",
|
|
86
92
|
"default": false,
|
|
87
|
-
"description": "Do not update tsconfig.json for development experience."
|
|
93
|
+
"description": "Do not update `tsconfig.json` for development experience.",
|
|
94
|
+
"x-priority": "internal"
|
|
88
95
|
},
|
|
89
96
|
"routing": {
|
|
90
97
|
"type": "boolean",
|
|
@@ -121,7 +128,7 @@
|
|
|
121
128
|
},
|
|
122
129
|
"globalCss": {
|
|
123
130
|
"type": "boolean",
|
|
124
|
-
"description": "When true
|
|
131
|
+
"description": "When `true`, the stylesheet is generated using global CSS instead of CSS modules (e.g. file is `*.css` rather than `*.module.css`).",
|
|
125
132
|
"default": false
|
|
126
133
|
},
|
|
127
134
|
"strict": {
|
|
@@ -140,6 +147,12 @@
|
|
|
140
147
|
"default": false,
|
|
141
148
|
"x-deprecated": "Use `enableTypedLinting` instead. This option will be removed in Nx v24."
|
|
142
149
|
},
|
|
150
|
+
"compiler": {
|
|
151
|
+
"type": "string",
|
|
152
|
+
"enum": ["babel", "swc"],
|
|
153
|
+
"default": "babel",
|
|
154
|
+
"description": "Which compiler to use."
|
|
155
|
+
},
|
|
143
156
|
"skipPackageJson": {
|
|
144
157
|
"type": "boolean",
|
|
145
158
|
"default": false,
|
|
@@ -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;
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.composePlugins = composePlugins;
|
|
4
|
-
const deprecation_1 = require("./deprecation");
|
|
5
4
|
function composePlugins(...plugins) {
|
|
6
5
|
return function (baseConfig) {
|
|
7
6
|
return async function combined(phase, context) {
|
|
8
|
-
|
|
7
|
+
const { PHASE_PRODUCTION_SERVER, } = require('next/constants');
|
|
8
|
+
// Copied verbatim into the build output (see create-next-config-file.ts),
|
|
9
|
+
// so this must load without @nx/next or @nx/devkit installed. Warn only on
|
|
10
|
+
// the active Nx-task path, resolved from the workspace like with-nx.ts.
|
|
11
|
+
if (phase !== PHASE_PRODUCTION_SERVER &&
|
|
12
|
+
!global.NX_GRAPH_CREATION &&
|
|
13
|
+
process.env.NX_TASK_TARGET_TARGET) {
|
|
14
|
+
const { workspaceRoot } = require('@nx/devkit');
|
|
15
|
+
const { warnComposePluginsDeprecation } = require(require.resolve('@nx/next/src/utils/deprecation', {
|
|
16
|
+
paths: [workspaceRoot],
|
|
17
|
+
}));
|
|
18
|
+
warnComposePluginsDeprecation(phase);
|
|
19
|
+
}
|
|
9
20
|
let config = baseConfig;
|
|
10
21
|
for (const plugin of plugins) {
|
|
11
22
|
const fn = await plugin;
|
|
@@ -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/generators.json
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"schema": "./dist/src/generators/library/schema.json",
|
|
32
32
|
"aliases": ["lib"],
|
|
33
33
|
"x-type": "library",
|
|
34
|
-
"description": "Create a library."
|
|
34
|
+
"description": "Create a Next.js library."
|
|
35
35
|
},
|
|
36
36
|
"custom-server": {
|
|
37
37
|
"factory": "./dist/src/generators/custom-server/custom-server#customServerGenerator",
|
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.1.
|
|
3
|
+
"version": "23.1.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": {
|
|
@@ -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.1.3"
|
|
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.1.
|
|
82
|
-
"@nx/js": "23.1.
|
|
83
|
-
"@nx/eslint": "23.1.
|
|
84
|
-
"@nx/react": "23.1.
|
|
85
|
-
"@nx/web": "23.1.
|
|
86
|
-
"@nx/webpack": "23.1.1"
|
|
86
|
+
"@nx/devkit": "23.1.3",
|
|
87
|
+
"@nx/js": "23.1.3",
|
|
88
|
+
"@nx/eslint": "23.1.3",
|
|
89
|
+
"@nx/react": "23.1.3",
|
|
90
|
+
"@nx/web": "23.1.3"
|
|
87
91
|
},
|
|
88
92
|
"devDependencies": {
|
|
89
|
-
"@nx/cypress": "23.1.
|
|
90
|
-
"@nx/playwright": "23.1.
|
|
91
|
-
"nx": "23.1.
|
|
93
|
+
"@nx/cypress": "23.1.3",
|
|
94
|
+
"@nx/playwright": "23.1.3",
|
|
95
|
+
"@nx/webpack": "23.1.3",
|
|
96
|
+
"nx": "23.1.3"
|
|
92
97
|
},
|
|
93
98
|
"publishConfig": {
|
|
94
99
|
"access": "public"
|