@nx/next 20.0.7 → 20.1.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 +7 -7
- package/plugin.d.ts +1 -1
- package/plugin.js +2 -1
- package/src/executors/build/lib/create-next-config-file.js +6 -1
- package/src/generators/application/files/app/page.tsx__tmpl__ +12 -15
- package/src/generators/application/files/common/specs/__fileName__.spec.tsx__tmpl__ +5 -5
- package/src/generators/application/files/pages/__fileName__.tsx__tmpl__ +10 -13
- package/src/generators/convert-to-inferred/convert-to-inferred.js +1 -1
- package/src/generators/init/init.js +2 -2
- package/src/plugins/plugin.d.ts +9 -1
- package/src/plugins/plugin.js +55 -26
- package/src/utils/versions.d.ts +2 -2
- package/src/utils/versions.js +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/next",
|
|
3
|
-
"version": "20.0.
|
|
3
|
+
"version": "20.1.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, Playwright, Cypress, and Jest. No need to configure anything: watch mode, source maps, and typings just work.",
|
|
6
6
|
"repository": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"next": ">=14.0.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@nx/devkit": "20.0.
|
|
38
|
+
"@nx/devkit": "20.1.0-beta.0",
|
|
39
39
|
"@babel/plugin-proposal-decorators": "^7.22.7",
|
|
40
40
|
"@svgr/webpack": "^8.0.1",
|
|
41
41
|
"copy-webpack-plugin": "^10.2.4",
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
"semver": "^7.5.3",
|
|
45
45
|
"tslib": "^2.3.0",
|
|
46
46
|
"webpack-merge": "^5.8.0",
|
|
47
|
-
"@nx/js": "20.0.
|
|
48
|
-
"@nx/eslint": "20.0.
|
|
49
|
-
"@nx/react": "20.0.
|
|
50
|
-
"@nx/web": "20.0.
|
|
51
|
-
"@nx/webpack": "20.0.
|
|
47
|
+
"@nx/js": "20.1.0-beta.0",
|
|
48
|
+
"@nx/eslint": "20.1.0-beta.0",
|
|
49
|
+
"@nx/react": "20.1.0-beta.0",
|
|
50
|
+
"@nx/web": "20.1.0-beta.0",
|
|
51
|
+
"@nx/webpack": "20.1.0-beta.0",
|
|
52
52
|
"@phenomnomnominal/tsquery": "~5.0.1"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|
package/plugin.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { createNodes, NextPluginOptions } from './src/plugins/plugin';
|
|
1
|
+
export { createNodes, createNodesV2, NextPluginOptions, } from './src/plugins/plugin';
|
package/plugin.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createNodes = void 0;
|
|
3
|
+
exports.createNodesV2 = exports.createNodes = void 0;
|
|
4
4
|
var plugin_1 = require("./src/plugins/plugin");
|
|
5
5
|
Object.defineProperty(exports, "createNodes", { enumerable: true, get: function () { return plugin_1.createNodes; } });
|
|
6
|
+
Object.defineProperty(exports, "createNodesV2", { enumerable: true, get: function () { return plugin_1.createNodesV2; } });
|
|
@@ -94,7 +94,12 @@ function findNextConfigPath(dirname, userDefinedConfigPath) {
|
|
|
94
94
|
return file;
|
|
95
95
|
throw new Error(`Cannot find the Next.js config file: ${userDefinedConfigPath}. Is the path correct in project.json?`);
|
|
96
96
|
}
|
|
97
|
-
const candidates = [
|
|
97
|
+
const candidates = [
|
|
98
|
+
'next.config.js',
|
|
99
|
+
'next.config.cjs',
|
|
100
|
+
'next.config.mjs',
|
|
101
|
+
'next.config.ts',
|
|
102
|
+
];
|
|
98
103
|
for (const candidate of candidates) {
|
|
99
104
|
if ((0, node_fs_1.existsSync)((0, path_1.join)(dirname, candidate)))
|
|
100
105
|
return candidate;
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
<% if (style !== 'none') { %>
|
|
2
|
-
<% if (styledModule && (styledModule === 'styled-jsx' || styledModule === 'styled-components')) {%>
|
|
3
|
-
|
|
4
|
-
<% }%>
|
|
5
|
-
<% if (styledModule && styledModule !== 'styled-jsx') {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
%>
|
|
10
|
-
<%- (style !== 'styled-jsx' && style !== 'tailwind') ? `import styles from './page.module.${style}';` : '' %>
|
|
11
|
-
<% }
|
|
12
|
-
%>
|
|
1
|
+
<%_ if (style !== 'none') { _%>
|
|
2
|
+
<%_ if (styledModule && (styledModule === 'styled-jsx' || styledModule === 'styled-components')) { _%>
|
|
3
|
+
'use client';
|
|
4
|
+
<%_ } _%>
|
|
5
|
+
<%_ if (styledModule && styledModule !== 'styled-jsx') { var wrapper = 'StyledPage'; _%>
|
|
6
|
+
import styled from '<%= styledModule %>';
|
|
7
|
+
<%_ } else { var wrapper = 'div'; _%>
|
|
8
|
+
<%- (style !== 'styled-jsx' && style !== 'tailwind') ? `import styles from './page.module.${style}';` : '' %>
|
|
9
|
+
<%_ } _%>
|
|
13
10
|
|
|
14
|
-
<% if (styledModule && styledModule !== 'styled-jsx') { %>
|
|
15
|
-
|
|
16
|
-
<% }%>
|
|
11
|
+
<%_ if (styledModule && styledModule !== 'styled-jsx') { _%>
|
|
12
|
+
const StyledPage = styled.div`<%- pageStyleContent %>`;
|
|
13
|
+
<%_ } _%>
|
|
17
14
|
<% } %>
|
|
18
15
|
export default function Index() {
|
|
19
16
|
/*
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render } from '@testing-library/react';
|
|
3
|
-
<% if (src && !appDir) { %>
|
|
3
|
+
<%_ if (src && !appDir) { _%>
|
|
4
4
|
import Index from '../src/pages/index';
|
|
5
|
-
<% } else if (!appDir) { %>
|
|
5
|
+
<%_ } else if (!appDir) { _%>
|
|
6
6
|
import Index from '../pages/index';
|
|
7
|
-
<% } else if (appDir && src) {%>
|
|
7
|
+
<%_ } else if (appDir && src) { _%>
|
|
8
8
|
import Page from '../src/app/page';
|
|
9
|
-
<% } else { %>
|
|
9
|
+
<%_ } else { _%>
|
|
10
10
|
import Page from '../app/page';
|
|
11
|
-
<% } %>
|
|
11
|
+
<%_ } _%>
|
|
12
12
|
|
|
13
13
|
describe(<%- appDir ? `'Page'` : `'Index'` %>, () => {
|
|
14
14
|
it('should render successfully', () => {
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
<% if (style !== 'none') { %>
|
|
2
|
-
<% if (styledModule && styledModule !== 'styled-jsx') {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
%>
|
|
7
|
-
<%- (style !== 'styled-jsx' && style !== 'tailwind') ? `import styles from './${fileName}.module.${style}';` : '' %>
|
|
8
|
-
<% }
|
|
9
|
-
%>
|
|
1
|
+
<%_ if (style !== 'none') { _%>
|
|
2
|
+
<%_ if (styledModule && styledModule !== 'styled-jsx') { var wrapper = 'StyledPage'; _%>
|
|
3
|
+
import styled from '<%= styledModule %>';
|
|
4
|
+
<% } else { var wrapper = 'div';%>
|
|
5
|
+
<%- (style !== 'styled-jsx' && style !== 'tailwind') ? `import styles from './${fileName}.module.${style}';` : '' %>
|
|
6
|
+
<%_ } _%>
|
|
10
7
|
|
|
11
|
-
<% if (styledModule && styledModule !== 'styled-jsx') { %>
|
|
12
|
-
|
|
13
|
-
<% }%>
|
|
14
|
-
<% } %>
|
|
8
|
+
<%_ if (styledModule && styledModule !== 'styled-jsx') { _%>
|
|
9
|
+
const StyledPage = styled.div`<%- pageStyleContent %>`;
|
|
10
|
+
<%_ } _%>
|
|
11
|
+
<%_ } _%>
|
|
15
12
|
|
|
16
13
|
export function Index() {
|
|
17
14
|
/*
|
|
@@ -10,7 +10,7 @@ const serve_post_target_tranformer_1 = require("./lib/serve-post-target-tranform
|
|
|
10
10
|
async function convertToInferred(tree, options) {
|
|
11
11
|
const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
|
|
12
12
|
const migrationLogs = new aggregate_log_util_1.AggregatedLog();
|
|
13
|
-
const migratedProjects = await (0, executor_to_plugin_migrator_1.
|
|
13
|
+
const migratedProjects = await (0, executor_to_plugin_migrator_1.migrateProjectExecutorsToPlugin)(tree, projectGraph, '@nx/next/plugin', plugin_1.createNodesV2, {
|
|
14
14
|
buildTargetName: 'build',
|
|
15
15
|
devTargetName: 'dev',
|
|
16
16
|
startTargetName: 'start',
|
|
@@ -30,8 +30,8 @@ async function nextInitGeneratorInternal(host, schema) {
|
|
|
30
30
|
nxJson.useInferencePlugins !== false;
|
|
31
31
|
schema.addPlugin ??= addPluginDefault;
|
|
32
32
|
if (schema.addPlugin) {
|
|
33
|
-
const {
|
|
34
|
-
await (0, add_plugin_1.
|
|
33
|
+
const { createNodesV2 } = await Promise.resolve().then(() => require('../../plugins/plugin'));
|
|
34
|
+
await (0, add_plugin_1.addPlugin)(host, await (0, devkit_1.createProjectGraphAsync)(), '@nx/next/plugin', createNodesV2, {
|
|
35
35
|
startTargetName: ['start', 'next:start', 'next-start'],
|
|
36
36
|
buildTargetName: ['build', 'next:build', 'next-build'],
|
|
37
37
|
devTargetName: ['dev', 'next:dev', 'next-dev'],
|
package/src/plugins/plugin.d.ts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import { CreateDependencies, CreateNodes } from '@nx/devkit';
|
|
1
|
+
import { CreateDependencies, CreateNodes, CreateNodesV2 } from '@nx/devkit';
|
|
2
2
|
export interface NextPluginOptions {
|
|
3
3
|
buildTargetName?: string;
|
|
4
4
|
devTargetName?: string;
|
|
5
5
|
startTargetName?: string;
|
|
6
6
|
serveStaticTargetName?: string;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated The 'createDependencies' function is now a no-op. This functionality is included in 'createNodesV2'.
|
|
10
|
+
*/
|
|
8
11
|
export declare const createDependencies: CreateDependencies;
|
|
12
|
+
export declare const createNodesV2: CreateNodesV2<NextPluginOptions>;
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated This is replaced with {@link createNodesV2}. Update your plugin to export its own `createNodesV2` function that wraps this one instead.
|
|
15
|
+
* This function will change to the v2 function in Nx 21.
|
|
16
|
+
*/
|
|
9
17
|
export declare const createNodes: CreateNodes<NextPluginOptions>;
|
package/src/plugins/plugin.js
CHANGED
|
@@ -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.createNodes = exports.createNodesV2 = 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");
|
|
@@ -9,46 +9,75 @@ 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
11
|
const config_utils_1 = require("@nx/devkit/src/utils/config-utils");
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
function readTargetsCache() {
|
|
12
|
+
const devkit_internals_1 = require("nx/src/devkit-internals");
|
|
13
|
+
const nextConfigBlob = '**/next.config.{ts,js,cjs,mjs}';
|
|
14
|
+
function readTargetsCache(cachePath) {
|
|
15
15
|
return (0, fs_1.existsSync)(cachePath) ? (0, devkit_1.readJsonFile)(cachePath) : {};
|
|
16
16
|
}
|
|
17
|
-
function writeTargetsToCache() {
|
|
18
|
-
const oldCache = readTargetsCache();
|
|
17
|
+
function writeTargetsToCache(cachePath, targetsCache) {
|
|
18
|
+
const oldCache = readTargetsCache(cachePath);
|
|
19
19
|
(0, devkit_1.writeJsonFile)(cachePath, {
|
|
20
20
|
...oldCache,
|
|
21
21
|
...targetsCache,
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated The 'createDependencies' function is now a no-op. This functionality is included in 'createNodesV2'.
|
|
26
|
+
*/
|
|
24
27
|
const createDependencies = () => {
|
|
25
|
-
writeTargetsToCache();
|
|
26
28
|
return [];
|
|
27
29
|
};
|
|
28
30
|
exports.createDependencies = createDependencies;
|
|
31
|
+
exports.createNodesV2 = [
|
|
32
|
+
nextConfigBlob,
|
|
33
|
+
async (configFiles, options, context) => {
|
|
34
|
+
const optionsHash = (0, devkit_internals_1.hashObject)(options);
|
|
35
|
+
const cachePath = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, `next-${optionsHash}.json`);
|
|
36
|
+
const targetsCache = readTargetsCache(cachePath);
|
|
37
|
+
try {
|
|
38
|
+
return await (0, devkit_1.createNodesFromFiles)((configFile, options, context) => createNodesInternal(configFile, options, context, targetsCache), configFiles, options, context);
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
writeTargetsToCache(cachePath, targetsCache);
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
/**
|
|
46
|
+
* @deprecated This is replaced with {@link createNodesV2}. Update your plugin to export its own `createNodesV2` function that wraps this one instead.
|
|
47
|
+
* This function will change to the v2 function in Nx 21.
|
|
48
|
+
*/
|
|
29
49
|
exports.createNodes = [
|
|
30
|
-
|
|
50
|
+
nextConfigBlob,
|
|
31
51
|
async (configFilePath, options, context) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
options = normalizeOptions(options);
|
|
40
|
-
const hash = await (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, context, [(0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot))]);
|
|
41
|
-
targetsCache[hash] ??= await buildNextTargets(configFilePath, projectRoot, options, context);
|
|
42
|
-
return {
|
|
43
|
-
projects: {
|
|
44
|
-
[projectRoot]: {
|
|
45
|
-
root: projectRoot,
|
|
46
|
-
targets: targetsCache[hash],
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
};
|
|
52
|
+
devkit_1.logger.warn('`createNodes` is deprecated. Update your plugin to utilize createNodesV2 instead. In Nx 21, this will change to the createNodesV2 API.');
|
|
53
|
+
const optionsHash = (0, devkit_internals_1.hashObject)(options);
|
|
54
|
+
const cachePath = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, `next-${optionsHash}.json`);
|
|
55
|
+
const targetsCache = readTargetsCache(cachePath);
|
|
56
|
+
const result = await createNodesInternal(configFilePath, options, context, targetsCache);
|
|
57
|
+
writeTargetsToCache(cachePath, targetsCache);
|
|
58
|
+
return result;
|
|
50
59
|
},
|
|
51
60
|
];
|
|
61
|
+
async function createNodesInternal(configFilePath, options, context, targetsCache) {
|
|
62
|
+
const projectRoot = (0, path_1.dirname)(configFilePath);
|
|
63
|
+
// Do not create a project if package.json and project.json isn't there.
|
|
64
|
+
const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
|
|
65
|
+
if (!siblingFiles.includes('package.json') &&
|
|
66
|
+
!siblingFiles.includes('project.json')) {
|
|
67
|
+
return {};
|
|
68
|
+
}
|
|
69
|
+
options = normalizeOptions(options);
|
|
70
|
+
const hash = await (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, context, [(0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot))]);
|
|
71
|
+
targetsCache[hash] ??= await buildNextTargets(configFilePath, projectRoot, options, context);
|
|
72
|
+
return {
|
|
73
|
+
projects: {
|
|
74
|
+
[projectRoot]: {
|
|
75
|
+
root: projectRoot,
|
|
76
|
+
targets: targetsCache[hash],
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
52
81
|
async function buildNextTargets(nextConfigPath, projectRoot, options, context) {
|
|
53
82
|
const nextConfig = await getNextConfig(nextConfigPath, context);
|
|
54
83
|
const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
|
package/src/utils/versions.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const nxVersion: any;
|
|
2
|
-
export declare const nextVersion = "14.2.
|
|
3
|
-
export declare const eslintConfigNextVersion = "14.2.
|
|
2
|
+
export declare const nextVersion = "14.2.16";
|
|
3
|
+
export declare const eslintConfigNextVersion = "14.2.16";
|
|
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";
|
package/src/utils/versions.js
CHANGED
|
@@ -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 = '14.2.
|
|
6
|
-
exports.eslintConfigNextVersion = '14.2.
|
|
5
|
+
exports.nextVersion = '14.2.16';
|
|
6
|
+
exports.eslintConfigNextVersion = '14.2.16';
|
|
7
7
|
exports.sassVersion = '1.62.1';
|
|
8
8
|
exports.lessLoader = '11.1.0';
|
|
9
9
|
exports.emotionServerVersion = '11.11.0';
|