@nx/next 22.7.0-pr.35019.f500fd7 → 22.7.0-rc.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": "22.7.0-pr.35019.f500fd7",
3
+ "version": "22.7.0-rc.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": {
@@ -18,7 +18,8 @@
18
18
  "Front-end"
19
19
  ],
20
20
  "main": "./index.js",
21
- "typings": "./index.d.ts",
21
+ "type": "commonjs",
22
+ "types": "./index.d.ts",
22
23
  "author": "Victor Savkin",
23
24
  "license": "MIT",
24
25
  "bugs": {
@@ -35,7 +36,7 @@
35
36
  "next": ">=14.0.0 <17.0.0"
36
37
  },
37
38
  "dependencies": {
38
- "@nx/devkit": "22.7.0-pr.35019.f500fd7",
39
+ "@nx/devkit": "22.7.0-rc.0",
39
40
  "@babel/plugin-proposal-decorators": "^7.22.7",
40
41
  "@svgr/webpack": "^8.1.0",
41
42
  "copy-webpack-plugin": "^14.0.0",
@@ -43,21 +44,19 @@
43
44
  "semver": "^7.6.3",
44
45
  "tslib": "^2.3.0",
45
46
  "webpack-merge": "^5.8.0",
46
- "@nx/js": "22.7.0-pr.35019.f500fd7",
47
- "@nx/eslint": "22.7.0-pr.35019.f500fd7",
48
- "@nx/react": "22.7.0-pr.35019.f500fd7",
49
- "@nx/web": "22.7.0-pr.35019.f500fd7",
50
- "@nx/webpack": "22.7.0-pr.35019.f500fd7",
47
+ "@nx/js": "22.7.0-rc.0",
48
+ "@nx/eslint": "22.7.0-rc.0",
49
+ "@nx/react": "22.7.0-rc.0",
50
+ "@nx/web": "22.7.0-rc.0",
51
+ "@nx/webpack": "22.7.0-rc.0",
51
52
  "@phenomnomnominal/tsquery": "~6.1.4"
52
53
  },
53
54
  "devDependencies": {
54
- "@nx/cypress": "22.7.0-pr.35019.f500fd7",
55
- "@nx/playwright": "22.7.0-pr.35019.f500fd7",
56
- "nx": "22.7.0-pr.35019.f500fd7"
55
+ "@nx/cypress": "22.7.0-rc.0",
56
+ "@nx/playwright": "22.7.0-rc.0",
57
+ "nx": "22.7.0-rc.0"
57
58
  },
58
59
  "publishConfig": {
59
60
  "access": "public"
60
- },
61
- "types": "./index.d.ts",
62
- "type": "commonjs"
61
+ }
63
62
  }
@@ -1 +1 @@
1
- {"version":3,"file":"update-package-json.d.ts","sourceRoot":"","sources":["../../../../../../../packages/next/src/executors/build/lib/update-package-json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE7D,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,eAAe,QA4BzB"}
1
+ {"version":3,"file":"update-package-json.d.ts","sourceRoot":"","sources":["../../../../../../../packages/next/src/executors/build/lib/update-package-json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE7D,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,eAAe,QA8BzB"}
@@ -12,6 +12,7 @@ function updatePackageJson(packageJson, context) {
12
12
  // These are always required for a production Next.js app to run.
13
13
  // sharp is for next/image https://nextjs.org/docs/messages/sharp-missing-in-production
14
14
  // critters is required for experimental optimizing CSS
15
+ // semver is required by .nx-helpers/with-nx.js at runtime
15
16
  const requiredPackages = [
16
17
  'react',
17
18
  'react-dom',
@@ -19,6 +20,7 @@ function updatePackageJson(packageJson, context) {
19
20
  'typescript',
20
21
  'sharp',
21
22
  'critters',
23
+ 'semver',
22
24
  ];
23
25
  for (const pkg of requiredPackages) {
24
26
  const externalNode = context.projectGraph.externalNodes[`npm:${pkg}`];
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/next/src/plugins/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAGlB,aAAa,EAOd,MAAM,YAAY,CAAC;AAYpB,MAAM,WAAW,iBAAiB;IAChC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAuBD;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,kBAEhC,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,aAAa,CAAC,iBAAiB,CA0BxD,CAAC;AAEF,eAAO,MAAM,aAAa,kCAAc,CAAC"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/next/src/plugins/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAGlB,aAAa,EAOd,MAAM,YAAY,CAAC;AAYpB,MAAM,WAAW,iBAAiB;IAChC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAqBD;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,kBAEhC,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,aAAa,CAAC,iBAAiB,CA8BxD,CAAC;AAEF,eAAO,MAAM,aAAa,kCAAc,CAAC"}
@@ -12,7 +12,6 @@ const fs_1 = require("fs");
12
12
  const devkit_internals_1 = require("nx/src/devkit-internals");
13
13
  const cache_directory_1 = require("nx/src/utils/cache-directory");
14
14
  const path_1 = require("path");
15
- const pmc = (0, devkit_1.getPackageManagerCommand)();
16
15
  const nextConfigBlob = '**/next.config.{ts,js,cjs,mjs}';
17
16
  function readTargetsCache(cachePath) {
18
17
  return (0, fs_1.existsSync)(cachePath) ? (0, devkit_1.readJsonFile)(cachePath) : {};
@@ -38,8 +37,9 @@ exports.createNodes = [
38
37
  const cachePath = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, `next-${optionsHash}.json`);
39
38
  const targetsCache = readTargetsCache(cachePath);
40
39
  const isTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)();
40
+ const pmc = (0, devkit_1.getPackageManagerCommand)((0, devkit_1.detectPackageManager)(context.workspaceRoot));
41
41
  try {
42
- return await (0, devkit_1.createNodesFromFiles)((configFile, options, context) => createNodesInternal(configFile, options, context, targetsCache, isTsSolutionSetup), configFiles, options, context);
42
+ return await (0, devkit_1.createNodesFromFiles)((configFile, options, context) => createNodesInternal(configFile, options, context, targetsCache, isTsSolutionSetup, pmc), configFiles, options, context);
43
43
  }
44
44
  finally {
45
45
  writeTargetsToCache(cachePath, targetsCache);
@@ -47,7 +47,7 @@ exports.createNodes = [
47
47
  },
48
48
  ];
49
49
  exports.createNodesV2 = exports.createNodes;
50
- async function createNodesInternal(configFilePath, options, context, targetsCache, isTsSolutionSetup) {
50
+ async function createNodesInternal(configFilePath, options, context, targetsCache, isTsSolutionSetup, pmc) {
51
51
  const projectRoot = (0, path_1.dirname)(configFilePath);
52
52
  // Do not create a project if package.json and project.json isn't there.
53
53
  const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
@@ -57,7 +57,7 @@ async function createNodesInternal(configFilePath, options, context, targetsCach
57
57
  }
58
58
  options = normalizeOptions(options);
59
59
  const hash = await (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, context, [(0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot))]);
60
- targetsCache[hash] ??= await buildNextTargets(configFilePath, projectRoot, options, context, isTsSolutionSetup);
60
+ targetsCache[hash] ??= await buildNextTargets(configFilePath, projectRoot, options, context, isTsSolutionSetup, pmc);
61
61
  return {
62
62
  projects: {
63
63
  [projectRoot]: {
@@ -67,7 +67,7 @@ async function createNodesInternal(configFilePath, options, context, targetsCach
67
67
  },
68
68
  };
69
69
  }
70
- async function buildNextTargets(nextConfigPath, projectRoot, options, context, isTsSolutionSetup) {
70
+ async function buildNextTargets(nextConfigPath, projectRoot, options, context, isTsSolutionSetup, pmc) {
71
71
  const nextConfig = await getNextConfig(nextConfigPath, context);
72
72
  const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
73
73
  const targets = {};
@@ -160,10 +160,14 @@ function normalizeOptions(options) {
160
160
  function getInputs(namedInputs) {
161
161
  return [
162
162
  ...('production' in namedInputs
163
- ? ['default', '^production']
163
+ ? ['default', '^default']
164
164
  : ['default', '^default']),
165
165
  {
166
166
  externalDependencies: ['next'],
167
167
  },
168
+ {
169
+ dependentTasksOutputFiles: '**/*.d.ts',
170
+ transitive: true,
171
+ },
168
172
  ];
169
173
  }
@@ -1 +1 @@
1
- {"version":3,"file":"jest-config-util.d.ts","sourceRoot":"","sources":["../../../../../packages/next/src/utils/jest-config-util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAkB,MAAM,YAAY,CAAC;AAelD,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,IAAI,EACV,OAAO,EAAE;IACP,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,QAwDF"}
1
+ {"version":3,"file":"jest-config-util.d.ts","sourceRoot":"","sources":["../../../../../packages/next/src/utils/jest-config-util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAkB,MAAM,YAAY,CAAC;AAelD,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,IAAI,EACV,OAAO,EAAE;IACP,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,QAkFF"}
@@ -22,6 +22,10 @@ function updateJestConfig(host, options) {
22
22
  const offset = (0, devkit_1.offsetFromRoot)(options.projectRoot);
23
23
  const isCommonJS = configPath.endsWith('.js') || configPath.endsWith('.cts');
24
24
  // Easier to override the whole file rather than replace content since the structure has changed with `next/jest.js` being used.
25
+ // The wrapper around createJestConfig disables SWC path alias resolution.
26
+ // Without explicit baseUrl, Next.js resolves aliases from the app root instead
27
+ // of the workspace root, producing wrong paths. The Nx jest resolver handles
28
+ // alias resolution correctly, so we let it take over.
25
29
  const newContent = isCommonJS
26
30
  ? `const nextJest = require('next/jest.js');
27
31
 
@@ -40,7 +44,18 @@ const config = {
40
44
  testEnvironment: 'jsdom',
41
45
  };
42
46
 
43
- module.exports = createJestConfig(config);
47
+ const jestConfig = createJestConfig(config);
48
+
49
+ module.exports = async () => {
50
+ const resolved = await jestConfig();
51
+ // Disable SWC path alias resolution — handled by Nx jest resolver.
52
+ for (const value of Object.values(resolved.transform)) {
53
+ if (Array.isArray(value) && value[1]?.resolvedBaseUrl) {
54
+ value[1] = { ...value[1], resolvedBaseUrl: undefined };
55
+ }
56
+ }
57
+ return resolved;
58
+ };
44
59
  `
45
60
  : `import type { Config } from 'jest';
46
61
  import nextJest from 'next/jest.js';
@@ -60,7 +75,18 @@ const config: Config = {
60
75
  testEnvironment: 'jsdom',
61
76
  };
62
77
 
63
- export default createJestConfig(config);
78
+ const jestConfig = createJestConfig(config);
79
+
80
+ export default async () => {
81
+ const resolved = await jestConfig();
82
+ // Disable SWC path alias resolution — handled by Nx jest resolver.
83
+ for (const value of Object.values(resolved.transform)) {
84
+ if (Array.isArray(value) && value[1]?.resolvedBaseUrl) {
85
+ value[1] = { ...value[1], resolvedBaseUrl: undefined };
86
+ }
87
+ }
88
+ return resolved;
89
+ };
64
90
  `;
65
91
  host.write(configPath, newContent);
66
92
  }
package/project.json DELETED
@@ -1,57 +0,0 @@
1
- {
2
- "name": "next",
3
- "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
- "sourceRoot": "packages/next",
5
- "projectType": "library",
6
- "targets": {
7
- "build": {
8
- "outputs": ["{workspaceRoot}/dist/packages/next/README.md"],
9
- "command": "node ./scripts/copy-readme.js next"
10
- },
11
- "legacy-post-build": {
12
- "executor": "@nx/workspace-plugin:legacy-post-build",
13
- "options": {
14
- "tsConfig": "./tsconfig.lib.json",
15
- "assets": [
16
- {
17
- "input": "packages/next",
18
- "glob": "**/files/**",
19
- "output": "/"
20
- },
21
- {
22
- "input": "packages/next",
23
- "glob": "**/files/**/.gitkeep",
24
- "output": "/"
25
- },
26
- {
27
- "input": "packages/next",
28
- "glob": "**/files/**/.babelrc__tmpl__",
29
- "output": "/"
30
- },
31
- {
32
- "input": "packages/next",
33
- "glob": "**/*.json",
34
- "ignore": ["**/tsconfig*.json", "project.json", ".eslintrc.json"],
35
- "output": "/"
36
- },
37
- {
38
- "input": "packages/next",
39
- "glob": "**/*.js",
40
- "ignore": ["**/jest.config.js"],
41
- "output": "/"
42
- },
43
- {
44
- "input": "packages/next",
45
- "glob": "**/*.d.ts",
46
- "output": "/"
47
- },
48
- {
49
- "input": "",
50
- "glob": "LICENSE",
51
- "output": "/"
52
- }
53
- ]
54
- }
55
- }
56
- }
57
- }