@nx/next 21.2.1 → 21.2.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/package.json +7 -7
- package/plugins/component-testing.js +4 -3
- package/src/generators/application/application.js +2 -2
- package/src/generators/cypress-component-configuration/cypress-component-configuration.js +5 -3
- package/src/utils/jest-config-util.d.ts +7 -0
- package/src/utils/jest-config-util.js +55 -0
- package/src/generators/application/lib/update-jest-config.d.ts +0 -3
- package/src/generators/application/lib/update-jest-config.js +0 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/next",
|
|
3
|
-
"version": "21.2.
|
|
3
|
+
"version": "21.2.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": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"next": ">=14.0.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@nx/devkit": "21.2.
|
|
38
|
+
"@nx/devkit": "21.2.3",
|
|
39
39
|
"@babel/plugin-proposal-decorators": "^7.22.7",
|
|
40
40
|
"@svgr/webpack": "^8.1.0",
|
|
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": "21.2.
|
|
48
|
-
"@nx/eslint": "21.2.
|
|
49
|
-
"@nx/react": "21.2.
|
|
50
|
-
"@nx/web": "21.2.
|
|
51
|
-
"@nx/webpack": "21.2.
|
|
47
|
+
"@nx/js": "21.2.3",
|
|
48
|
+
"@nx/eslint": "21.2.3",
|
|
49
|
+
"@nx/react": "21.2.3",
|
|
50
|
+
"@nx/web": "21.2.3",
|
|
51
|
+
"@nx/webpack": "21.2.3",
|
|
52
52
|
"@phenomnomnominal/tsquery": "~5.0.1"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.nxComponentTestingPreset = nxComponentTestingPreset;
|
|
4
|
-
const ct_helpers_1 = require("@nx/cypress/src/utils/ct-helpers");
|
|
5
4
|
const cypress_preset_1 = require("@nx/cypress/plugins/cypress-preset");
|
|
5
|
+
const ct_helpers_1 = require("@nx/cypress/src/utils/ct-helpers");
|
|
6
6
|
const devkit_1 = require("@nx/devkit");
|
|
7
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
7
8
|
const react_1 = require("@nx/react");
|
|
8
9
|
const webpack_1 = require("@nx/webpack");
|
|
9
|
-
const path_1 = require("path");
|
|
10
10
|
const configuration_1 = require("nx/src/config/configuration");
|
|
11
|
+
const path_1 = require("path");
|
|
11
12
|
function nxComponentTestingPreset(pathToConfig, options) {
|
|
12
13
|
if (global.NX_GRAPH_CREATION) {
|
|
13
14
|
// this is only used by plugins, so we don't need the component testing
|
|
@@ -68,7 +69,7 @@ Able to find CT project, ${!!ctProjectConfig}.`);
|
|
|
68
69
|
const webpackOptions = {
|
|
69
70
|
root: ctExecutorContext.root,
|
|
70
71
|
projectRoot: ctProjectConfig.root,
|
|
71
|
-
sourceRoot: ctProjectConfig
|
|
72
|
+
sourceRoot: (0, ts_solution_setup_1.getProjectSourceRoot)(ctProjectConfig),
|
|
72
73
|
main: '',
|
|
73
74
|
useTsconfigPaths: undefined,
|
|
74
75
|
fileReplacements: buildFileReplacements,
|
|
@@ -13,7 +13,6 @@ const add_jest_1 = require("./lib/add-jest");
|
|
|
13
13
|
const add_project_1 = require("./lib/add-project");
|
|
14
14
|
const create_application_files_1 = require("./lib/create-application-files");
|
|
15
15
|
const set_defaults_1 = require("./lib/set-defaults");
|
|
16
|
-
const update_jest_config_1 = require("./lib/update-jest-config");
|
|
17
16
|
const init_1 = require("../init/init");
|
|
18
17
|
const styles_1 = require("../../utils/styles");
|
|
19
18
|
const add_linting_1 = require("./lib/add-linting");
|
|
@@ -25,6 +24,7 @@ const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-projec
|
|
|
25
24
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
26
25
|
const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields");
|
|
27
26
|
const add_swc_to_custom_server_1 = require("../../utils/add-swc-to-custom-server");
|
|
27
|
+
const jest_config_util_1 = require("../../utils/jest-config-util");
|
|
28
28
|
async function applicationGenerator(host, schema) {
|
|
29
29
|
return await applicationGeneratorInternal(host, {
|
|
30
30
|
addPlugin: false,
|
|
@@ -74,7 +74,7 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
74
74
|
swc: !host.exists((0, devkit_1.joinPathFragments)(options.appProjectRoot, '.babelrc')),
|
|
75
75
|
});
|
|
76
76
|
tasks.push(styledTask);
|
|
77
|
-
(0,
|
|
77
|
+
(0, jest_config_util_1.updateJestConfig)(host, { ...options, projectRoot: options.appProjectRoot });
|
|
78
78
|
(0, update_cypress_tsconfig_1.updateCypressTsConfig)(host, options);
|
|
79
79
|
(0, set_defaults_1.setDefaults)(host, options);
|
|
80
80
|
if (options.swc) {
|
|
@@ -3,10 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.cypressComponentConfiguration = cypressComponentConfiguration;
|
|
4
4
|
exports.cypressComponentConfigurationInternal = cypressComponentConfigurationInternal;
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
const
|
|
7
|
-
const versions_1 = require("../../utils/versions");
|
|
6
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
8
7
|
const react_1 = require("@nx/react");
|
|
8
|
+
const ct_utils_1 = require("@nx/react/src/utils/ct-utils");
|
|
9
9
|
const path_1 = require("path");
|
|
10
|
+
const versions_1 = require("../../utils/versions");
|
|
10
11
|
function cypressComponentConfiguration(tree, options) {
|
|
11
12
|
return cypressComponentConfigurationInternal(tree, {
|
|
12
13
|
addPlugin: false,
|
|
@@ -66,7 +67,8 @@ ${isUsingTailwind
|
|
|
66
67
|
`);
|
|
67
68
|
if (opts.generateTests) {
|
|
68
69
|
const filePaths = [];
|
|
69
|
-
(0,
|
|
70
|
+
const sourceRoot = (0, ts_solution_setup_1.getProjectSourceRoot)(projectConfig, tree);
|
|
71
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, sourceRoot, (filePath) => {
|
|
70
72
|
const fromProjectRootPath = (0, path_1.relative)(projectConfig.root, filePath);
|
|
71
73
|
// we don't generate tests for pages/server-side/appDir components
|
|
72
74
|
if (fromProjectRootPath.includes('pages') ||
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateJestConfig = updateJestConfig;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
function updateJestConfig(host, options) {
|
|
6
|
+
if (options.unitTestRunner !== 'jest') {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const configPath = `${options.projectRoot}/jest.config.${options.js ? 'js' : 'ts'}`;
|
|
10
|
+
if (!host.exists(configPath))
|
|
11
|
+
return;
|
|
12
|
+
const offset = (0, devkit_1.offsetFromRoot)(options.projectRoot);
|
|
13
|
+
// Easier to override the whole file rather than replace content since the structure has changed with `next/jest.js` being used.
|
|
14
|
+
const newContent = options.js
|
|
15
|
+
? `const nextJest = require('next/jest.js');
|
|
16
|
+
|
|
17
|
+
const createJestConfig = nextJest({
|
|
18
|
+
dir: './',
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const config = {
|
|
22
|
+
displayName: '${options.projectName}',
|
|
23
|
+
preset: '${offset}jest.preset.js',
|
|
24
|
+
transform: {
|
|
25
|
+
'^(?!.*\\\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest',
|
|
26
|
+
},
|
|
27
|
+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
|
|
28
|
+
coverageDirectory: '${offset}coverage/${options.projectRoot}',
|
|
29
|
+
testEnvironment: 'jsdom',
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
module.exports = createJestConfig(config);
|
|
33
|
+
`
|
|
34
|
+
: `import type { Config } from 'jest';
|
|
35
|
+
import nextJest from 'next/jest.js';
|
|
36
|
+
|
|
37
|
+
const createJestConfig = nextJest({
|
|
38
|
+
dir: './',
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const config: Config = {
|
|
42
|
+
displayName: '${options.projectName}',
|
|
43
|
+
preset: '${offset}jest.preset.js',
|
|
44
|
+
transform: {
|
|
45
|
+
'^(?!.*\\\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest',
|
|
46
|
+
},
|
|
47
|
+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
|
|
48
|
+
coverageDirectory: '${offset}coverage/${options.projectRoot}',
|
|
49
|
+
testEnvironment: 'jsdom',
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export default createJestConfig(config);
|
|
53
|
+
`;
|
|
54
|
+
host.write(configPath, newContent);
|
|
55
|
+
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateJestConfig = updateJestConfig;
|
|
4
|
-
function updateJestConfig(host, options) {
|
|
5
|
-
if (options.unitTestRunner !== 'jest') {
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
const configPath = `${options.appProjectRoot}/jest.config.${options.js ? 'js' : 'ts'}`;
|
|
9
|
-
const originalContent = host.read(configPath, 'utf-8');
|
|
10
|
-
const content = originalContent
|
|
11
|
-
.replace('transform: {', "transform: {\n '^(?!.*\\\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest',")
|
|
12
|
-
.replace(`'babel-jest'`, `['babel-jest', { presets: ['@nx/next/babel'] }]`);
|
|
13
|
-
host.write(configPath, content);
|
|
14
|
-
}
|