@nx/next 21.2.0 → 21.2.2

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": "21.2.0",
3
+ "version": "21.2.2",
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.0",
38
+ "@nx/devkit": "21.2.2",
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.0",
48
- "@nx/eslint": "21.2.0",
49
- "@nx/react": "21.2.0",
50
- "@nx/web": "21.2.0",
51
- "@nx/webpack": "21.2.0",
47
+ "@nx/js": "21.2.2",
48
+ "@nx/eslint": "21.2.2",
49
+ "@nx/react": "21.2.2",
50
+ "@nx/web": "21.2.2",
51
+ "@nx/webpack": "21.2.2",
52
52
  "@phenomnomnominal/tsquery": "~5.0.1"
53
53
  },
54
54
  "publishConfig": {
@@ -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, update_jest_config_1.updateJestConfig)(host, options);
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) {
@@ -0,0 +1,7 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export declare function updateJestConfig(host: Tree, options: {
3
+ projectRoot: string;
4
+ projectName: string;
5
+ js?: boolean;
6
+ unitTestRunner?: string;
7
+ }): void;
@@ -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,3 +0,0 @@
1
- import { NormalizedSchema } from './normalize-options';
2
- import { Tree } from '@nx/devkit';
3
- export declare function updateJestConfig(host: Tree, options: NormalizedSchema): void;
@@ -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
- }