@nx/next 18.2.2 → 18.3.0-beta.0
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": "18.
|
|
3
|
+
"version": "18.3.0-beta.0",
|
|
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,24 +34,25 @@
|
|
|
34
34
|
"next": ">=14.0.0"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@nx/devkit": "18.
|
|
37
|
+
"@nx/devkit": "18.3.0-beta.0",
|
|
38
38
|
"@babel/plugin-proposal-decorators": "^7.22.7",
|
|
39
39
|
"@svgr/webpack": "^8.0.1",
|
|
40
40
|
"chalk": "^4.1.0",
|
|
41
41
|
"copy-webpack-plugin": "^10.2.4",
|
|
42
|
+
"file-loader": "^6.2.0",
|
|
42
43
|
"fs-extra": "^11.1.0",
|
|
43
44
|
"ignore": "^5.0.4",
|
|
44
45
|
"semver": "^7.5.3",
|
|
45
46
|
"url-loader": "^4.1.1",
|
|
46
47
|
"tslib": "^2.3.0",
|
|
47
48
|
"webpack-merge": "^5.8.0",
|
|
48
|
-
"@nx/js": "18.
|
|
49
|
-
"@nx/eslint": "18.
|
|
50
|
-
"@nx/react": "18.
|
|
51
|
-
"@nx/web": "18.
|
|
52
|
-
"@nx/webpack": "18.
|
|
53
|
-
"@nx/workspace": "18.
|
|
54
|
-
"@nrwl/next": "18.
|
|
49
|
+
"@nx/js": "18.3.0-beta.0",
|
|
50
|
+
"@nx/eslint": "18.3.0-beta.0",
|
|
51
|
+
"@nx/react": "18.3.0-beta.0",
|
|
52
|
+
"@nx/web": "18.3.0-beta.0",
|
|
53
|
+
"@nx/webpack": "18.3.0-beta.0",
|
|
54
|
+
"@nx/workspace": "18.3.0-beta.0",
|
|
55
|
+
"@nrwl/next": "18.3.0-beta.0"
|
|
55
56
|
},
|
|
56
57
|
"publishConfig": {
|
|
57
58
|
"access": "public"
|
package/plugins/with-nx.js
CHANGED
|
@@ -224,19 +224,54 @@ function getNextConfig(nextConfig = {}, context = getWithNxContext()) {
|
|
|
224
224
|
*/
|
|
225
225
|
// Default SVGR support to be on for projects.
|
|
226
226
|
if (nx?.svgr !== false) {
|
|
227
|
-
|
|
228
|
-
//
|
|
229
|
-
{
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
},
|
|
234
|
-
//
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
227
|
+
// TODO(v20): Remove file-loader and use `?react` querystring to differentiate between asset and SVGR.
|
|
228
|
+
// It should be:
|
|
229
|
+
// use: [{
|
|
230
|
+
// test: /\.svg$/i,
|
|
231
|
+
// type: 'asset',
|
|
232
|
+
// resourceQuery: /react/, // *.svg?react
|
|
233
|
+
// },
|
|
234
|
+
// {
|
|
235
|
+
// test: /\.svg$/i,
|
|
236
|
+
// issuer: /\.[jt]sx?$/,
|
|
237
|
+
// resourceQuery: { not: [/react/] }, // exclude react component if *.svg?react
|
|
238
|
+
// use: ['@svgr/webpack'],
|
|
239
|
+
// }],
|
|
240
|
+
// See:
|
|
241
|
+
// - SVGR: https://react-svgr.com/docs/webpack/#use-svgr-and-asset-svg-in-the-same-project
|
|
242
|
+
// - Vite: https://www.npmjs.com/package/vite-plugin-svgr
|
|
243
|
+
// - Rsbuild: https://github.com/web-infra-dev/rsbuild/pull/1783
|
|
244
|
+
// Note: We also need a migration for any projects that are using SVGR to convert
|
|
245
|
+
// `import { ReactComponent as X } from './x.svg` to
|
|
246
|
+
// `import X from './x.svg?react';
|
|
247
|
+
config.module.rules.push({
|
|
248
|
+
test: /\.svg$/,
|
|
249
|
+
issuer: { not: /\.(css|scss|sass)$/ },
|
|
250
|
+
resourceQuery: {
|
|
251
|
+
not: [
|
|
252
|
+
/__next_metadata__/,
|
|
253
|
+
/__next_metadata_route__/,
|
|
254
|
+
/__next_metadata_image_meta__/,
|
|
255
|
+
],
|
|
256
|
+
},
|
|
257
|
+
use: [
|
|
258
|
+
{
|
|
259
|
+
loader: require.resolve('@svgr/webpack'),
|
|
260
|
+
options: {
|
|
261
|
+
svgo: false,
|
|
262
|
+
titleProp: true,
|
|
263
|
+
ref: true,
|
|
264
|
+
},
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
loader: require.resolve('file-loader'),
|
|
268
|
+
options: {
|
|
269
|
+
// Next.js hard-codes assets to load from "static/media".
|
|
270
|
+
// See: https://github.com/vercel/next.js/blob/53d017d/packages/next/src/build/webpack-config.ts#L1993
|
|
271
|
+
name: 'static/media/[name].[hash].[ext]',
|
|
272
|
+
},
|
|
273
|
+
},
|
|
274
|
+
],
|
|
240
275
|
});
|
|
241
276
|
}
|
|
242
277
|
return userWebpack(config, options);
|
|
@@ -33,12 +33,12 @@ async function addE2e(host, options) {
|
|
|
33
33
|
project: options.e2eProjectName,
|
|
34
34
|
directory: 'src',
|
|
35
35
|
skipFormat: true,
|
|
36
|
-
devServerTarget: `${options.projectName}:${
|
|
37
|
-
baseUrl:
|
|
36
|
+
devServerTarget: `${options.projectName}:${options.e2eWebServerTarget}`,
|
|
37
|
+
baseUrl: options.e2eWebServerAddress,
|
|
38
38
|
jsx: true,
|
|
39
39
|
webServerCommands: hasPlugin
|
|
40
40
|
? {
|
|
41
|
-
default: `nx run ${options.projectName}
|
|
41
|
+
default: `nx run ${options.projectName}:${options.e2eWebServerTarget}`,
|
|
42
42
|
}
|
|
43
43
|
: undefined,
|
|
44
44
|
ciWebServerCommand: hasPlugin
|
|
@@ -63,8 +63,8 @@ async function addE2e(host, options) {
|
|
|
63
63
|
js: false,
|
|
64
64
|
linter: options.linter,
|
|
65
65
|
setParserOptionsProject: options.setParserOptionsProject,
|
|
66
|
-
webServerAddress: `http://127.0.0.1:${
|
|
67
|
-
webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx ${
|
|
66
|
+
webServerAddress: `http://127.0.0.1:${options.e2ePort}`,
|
|
67
|
+
webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx ${options.e2eWebServerTarget} ${options.projectName}`,
|
|
68
68
|
addPlugin: options.addPlugin,
|
|
69
69
|
});
|
|
70
70
|
}
|
|
@@ -6,6 +6,9 @@ export interface NormalizedSchema extends Schema {
|
|
|
6
6
|
outputPath: string;
|
|
7
7
|
e2eProjectName: string;
|
|
8
8
|
e2eProjectRoot: string;
|
|
9
|
+
e2eWebServerAddress: string;
|
|
10
|
+
e2eWebServerTarget: string;
|
|
11
|
+
e2ePort: number;
|
|
9
12
|
parsedTags: string[];
|
|
10
13
|
fileName: string;
|
|
11
14
|
styledModule: null | string;
|
|
@@ -20,8 +20,30 @@ async function normalizeOptions(host, options) {
|
|
|
20
20
|
const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
21
21
|
nxJson.useInferencePlugins !== false;
|
|
22
22
|
options.addPlugin ??= addPlugin;
|
|
23
|
+
let e2eWebServerTarget = options.addPlugin ? 'start' : 'serve';
|
|
24
|
+
if (options.addPlugin) {
|
|
25
|
+
if (nxJson.plugins) {
|
|
26
|
+
for (const plugin of nxJson.plugins) {
|
|
27
|
+
if (typeof plugin === 'object' &&
|
|
28
|
+
plugin.plugin === '@nx/next/plugin' &&
|
|
29
|
+
plugin.options.startTargetName) {
|
|
30
|
+
e2eWebServerTarget = plugin.options
|
|
31
|
+
.startTargetName;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
let e2ePort = options.addPlugin ? 3000 : 4200;
|
|
37
|
+
if (nxJson.targetDefaults?.[e2eWebServerTarget] &&
|
|
38
|
+
(nxJson.targetDefaults?.[e2eWebServerTarget].options?.port ||
|
|
39
|
+
nxJson.targetDefaults?.[e2eWebServerTarget].options?.env?.PORT)) {
|
|
40
|
+
e2ePort =
|
|
41
|
+
nxJson.targetDefaults?.[e2eWebServerTarget].options?.port ||
|
|
42
|
+
nxJson.targetDefaults?.[e2eWebServerTarget].options?.env?.PORT;
|
|
43
|
+
}
|
|
23
44
|
const e2eProjectName = options.rootProject ? 'e2e' : `${appProjectName}-e2e`;
|
|
24
45
|
const e2eProjectRoot = options.rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
|
|
46
|
+
const e2eWebServerAddress = `http://localhost:${e2ePort}`;
|
|
25
47
|
const name = (0, devkit_1.names)(options.name).fileName;
|
|
26
48
|
const outputPath = (0, devkit_1.joinPathFragments)('dist', appProjectRoot, ...(options.rootProject ? [name] : []));
|
|
27
49
|
const parsedTags = options.tags
|
|
@@ -41,6 +63,9 @@ async function normalizeOptions(host, options) {
|
|
|
41
63
|
appProjectRoot,
|
|
42
64
|
e2eProjectName,
|
|
43
65
|
e2eProjectRoot,
|
|
66
|
+
e2eWebServerAddress,
|
|
67
|
+
e2eWebServerTarget,
|
|
68
|
+
e2ePort,
|
|
44
69
|
e2eTestRunner: options.e2eTestRunner || 'cypress',
|
|
45
70
|
fileName,
|
|
46
71
|
linter: options.linter || eslint_1.Linter.EsLint,
|