@nx/next 0.0.0-pr-31222-862e973 → 0.0.0-pr-31313-387cdca
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/LICENSE +1 -1
- package/README.md +1 -1
- package/executors.json +0 -6
- package/generators.json +2 -2
- package/migrations.json +24 -52
- package/package.json +11 -13
- package/plugin.d.ts +1 -1
- package/plugin.js +2 -1
- package/plugins/component-testing.js +4 -0
- package/plugins/with-nx.d.ts +4 -0
- package/plugins/with-nx.js +6 -21
- package/src/executors/build/lib/create-next-config-file.js +7 -2
- package/src/executors/server/schema.json +1 -0
- package/src/executors/server/server.impl.d.ts +1 -1
- package/src/executors/server/server.impl.js +1 -1
- package/src/generators/application/application.js +32 -6
- package/src/generators/application/files/app/page.tsx__tmpl__ +12 -15
- package/src/generators/application/files/common/next-env.d.ts__tmpl__ +1 -1
- package/src/generators/application/files/common/next.config.js__tmpl__ +9 -15
- package/src/generators/application/files/common/specs/__fileName__.spec.tsx__tmpl__ +5 -5
- package/src/generators/application/files/common/tsconfig.json__tmpl__ +12 -5
- package/src/generators/application/files/pages/__fileName__.tsx__tmpl__ +10 -13
- package/src/generators/application/lib/add-e2e.js +54 -53
- package/src/generators/application/lib/add-linting.js +4 -1
- package/src/generators/application/lib/add-project.js +29 -9
- package/src/generators/application/lib/create-application-files.js +6 -4
- package/src/generators/application/lib/normalize-options.d.ts +4 -1
- package/src/generators/application/lib/normalize-options.js +12 -9
- package/src/generators/application/schema.d.ts +6 -4
- package/src/generators/application/schema.json +23 -18
- package/src/generators/component/component.d.ts +3 -21
- package/src/generators/component/component.js +6 -37
- package/src/generators/component/schema.json +13 -45
- package/src/generators/convert-to-inferred/convert-to-inferred.js +1 -1
- package/src/generators/custom-server/custom-server.d.ts +1 -1
- package/src/generators/custom-server/custom-server.js +31 -17
- package/src/generators/custom-server/files/server/main.ts__tmpl__ +1 -1
- package/src/generators/custom-server/files/tsconfig.server.json__tmpl__ +3 -2
- package/src/generators/cypress-component-configuration/cypress-component-configuration.js +4 -1
- package/src/generators/init/init.js +23 -10
- package/src/generators/library/lib/normalize-options.d.ts +1 -0
- package/src/generators/library/lib/normalize-options.js +6 -4
- package/src/generators/library/library.js +20 -3
- package/src/generators/library/schema.d.ts +5 -5
- package/src/generators/library/schema.json +39 -26
- package/src/generators/page/page.d.ts +0 -1
- package/src/generators/page/page.js +33 -54
- package/src/generators/page/schema.d.ts +2 -11
- package/src/generators/page/schema.json +6 -28
- package/src/generators/setup-tailwind/files/postcss.config.js__tmpl__ +15 -0
- package/src/generators/setup-tailwind/files/tailwind.config.js__tmpl__ +23 -0
- package/src/generators/setup-tailwind/lib/add-tailwind-style-imports.d.ts +3 -0
- package/src/generators/setup-tailwind/lib/add-tailwind-style-imports.js +27 -0
- package/src/generators/setup-tailwind/lib/update-project.d.ts +3 -0
- package/src/generators/setup-tailwind/lib/update-project.js +11 -0
- package/src/generators/setup-tailwind/schema.d.ts +6 -0
- package/src/generators/setup-tailwind/schema.js +2 -0
- package/src/generators/setup-tailwind/schema.json +47 -0
- package/src/generators/setup-tailwind/setup-tailwind.d.ts +4 -0
- package/src/generators/setup-tailwind/setup-tailwind.js +34 -0
- package/src/plugins/plugin.d.ts +14 -1
- package/src/plugins/plugin.js +64 -42
- package/src/utils/add-swc-to-custom-server.d.ts +1 -1
- package/src/utils/add-swc-to-custom-server.js +8 -12
- package/src/utils/version-utils.d.ts +9 -0
- package/src/utils/version-utils.js +46 -0
- package/src/utils/versions.d.ts +3 -2
- package/src/utils/versions.js +4 -3
- package/tailwind.d.ts +7 -2
- package/tailwind.js +39 -4
- package/plugins/with-stylus.d.ts +0 -3
- package/plugins/with-stylus.js +0 -11
- package/src/executors/export/export.impl.d.ts +0 -17
- package/src/executors/export/export.impl.js +0 -58
- package/src/executors/export/schema.json +0 -30
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +0 -2
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +0 -9
- package/src/migrations/update-16-3-0/remove-root-build-option.d.ts +0 -2
- package/src/migrations/update-16-3-0/remove-root-build-option.js +0 -17
- package/src/migrations/update-16-4-0/update-nx-next-dependency.d.ts +0 -2
- package/src/migrations/update-16-4-0/update-nx-next-dependency.js +0 -17
- package/src/migrations/update-17-2-7/remove-eslint-rules-patch.d.ts +0 -2
- package/src/migrations/update-17-2-7/remove-eslint-rules-patch.js +0 -15
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
[](https://circleci.com/gh/nrwl/nx)
|
|
11
11
|
[]()
|
|
12
|
-
[](https://www.npmjs.com/package/nx)
|
|
13
13
|
[]()
|
|
14
14
|
[](http://commitizen.github.io/cz-cli/)
|
|
15
15
|
[](https://gitter.im/nrwl-nx/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
package/executors.json
CHANGED
|
@@ -9,12 +9,6 @@
|
|
|
9
9
|
"implementation": "./src/executors/server/server.impl",
|
|
10
10
|
"schema": "./src/executors/server/schema.json",
|
|
11
11
|
"description": "Serve a Next.js application."
|
|
12
|
-
},
|
|
13
|
-
"export": {
|
|
14
|
-
"implementation": "./src/executors/export/export.impl",
|
|
15
|
-
"schema": "./src/executors/export/schema.json",
|
|
16
|
-
"description": "Export a Next.js application. The exported application is located at `dist/$outputPath/exported`.",
|
|
17
|
-
"x-deprecated": "Use static exports in next.config.js instead. See: https://nextjs.org/docs/pages/building-your-application/deploying/static-exports."
|
|
18
12
|
}
|
|
19
13
|
}
|
|
20
14
|
}
|
package/generators.json
CHANGED
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
"description": "Create an application."
|
|
18
18
|
},
|
|
19
19
|
"page": {
|
|
20
|
-
"factory": "./src/generators/page/page
|
|
20
|
+
"factory": "./src/generators/page/page",
|
|
21
21
|
"schema": "./src/generators/page/schema.json",
|
|
22
22
|
"description": "Create a page."
|
|
23
23
|
},
|
|
24
24
|
"component": {
|
|
25
|
-
"factory": "./src/generators/component/component
|
|
25
|
+
"factory": "./src/generators/component/component",
|
|
26
26
|
"schema": "./src/generators/component/schema.json",
|
|
27
27
|
"description": "Create a component."
|
|
28
28
|
},
|
package/migrations.json
CHANGED
|
@@ -1,76 +1,48 @@
|
|
|
1
1
|
{
|
|
2
|
-
"generators": {
|
|
3
|
-
"update-16-0-0-add-nx-packages": {
|
|
4
|
-
"cli": "nx",
|
|
5
|
-
"version": "16.0.0-beta.1",
|
|
6
|
-
"description": "Replace @nrwl/next with @nx/next",
|
|
7
|
-
"implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages"
|
|
8
|
-
},
|
|
9
|
-
"update-16-3-0-remove-root-build-option": {
|
|
10
|
-
"cli": "nx",
|
|
11
|
-
"version": "16.3.0-beta.9",
|
|
12
|
-
"description": "Remove root build option from project configurations since it is not needed.",
|
|
13
|
-
"implementation": "./src/migrations/update-16-3-0/remove-root-build-option"
|
|
14
|
-
},
|
|
15
|
-
"update-16-4-0-update-next-dependency": {
|
|
16
|
-
"cli": "nx",
|
|
17
|
-
"version": "16.4.0-beta.3",
|
|
18
|
-
"description": "Update package.json moving @nx/next from dependency to devDependency",
|
|
19
|
-
"implementation": "./src/migrations/update-16-4-0/update-nx-next-dependency"
|
|
20
|
-
},
|
|
21
|
-
"update-17-2-7": {
|
|
22
|
-
"cli": "nx",
|
|
23
|
-
"version": "17.2.7",
|
|
24
|
-
"description": "Remove patched eslint rule for @next/next/no-html-link-for-pages",
|
|
25
|
-
"implementation": "./src/migrations/update-17-2-7/remove-eslint-rules-patch"
|
|
26
|
-
}
|
|
27
|
-
},
|
|
2
|
+
"generators": {},
|
|
28
3
|
"packageJsonUpdates": {
|
|
29
|
-
"
|
|
30
|
-
"version": "
|
|
4
|
+
"19.0.3": {
|
|
5
|
+
"version": "19.0.3-beta.0",
|
|
31
6
|
"packages": {
|
|
32
7
|
"next": {
|
|
33
|
-
"version": "
|
|
8
|
+
"version": "14.2.3",
|
|
34
9
|
"alwaysAddToPackageJson": false
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"16.4.0-beta.4": {
|
|
39
|
-
"version": "16.4.0-beta.4",
|
|
40
|
-
"packages": {
|
|
41
|
-
"stylus": {
|
|
42
|
-
"version": "^0.59.0",
|
|
10
|
+
},
|
|
11
|
+
"eslint-config-next": {
|
|
12
|
+
"version": "14.2.3",
|
|
43
13
|
"alwaysAddToPackageJson": false
|
|
44
14
|
}
|
|
45
15
|
}
|
|
46
16
|
},
|
|
47
|
-
"
|
|
48
|
-
"version": "
|
|
17
|
+
"20.7.1-beta.0": {
|
|
18
|
+
"version": "20.7.1-beta.0",
|
|
49
19
|
"packages": {
|
|
50
|
-
"next": {
|
|
51
|
-
"version": "
|
|
20
|
+
"eslint-config-next": {
|
|
21
|
+
"version": "^15.2.4",
|
|
52
22
|
"alwaysAddToPackageJson": false
|
|
53
23
|
}
|
|
54
24
|
}
|
|
55
25
|
},
|
|
56
|
-
"
|
|
57
|
-
"version": "
|
|
26
|
+
"20.7.1-beta.0-next14": {
|
|
27
|
+
"version": "20.7.1-beta.0",
|
|
28
|
+
"requires": {
|
|
29
|
+
"next": "^14.0.0"
|
|
30
|
+
},
|
|
58
31
|
"packages": {
|
|
59
|
-
"
|
|
60
|
-
"version": "~
|
|
32
|
+
"next": {
|
|
33
|
+
"version": "~14.2.26",
|
|
61
34
|
"alwaysAddToPackageJson": false
|
|
62
35
|
}
|
|
63
36
|
}
|
|
64
37
|
},
|
|
65
|
-
"
|
|
66
|
-
"version": "
|
|
38
|
+
"20.7.1-beta.0-next15": {
|
|
39
|
+
"version": "20.7.1-beta.0",
|
|
40
|
+
"requires": {
|
|
41
|
+
"next": "^15.0.0"
|
|
42
|
+
},
|
|
67
43
|
"packages": {
|
|
68
44
|
"next": {
|
|
69
|
-
"version": "
|
|
70
|
-
"alwaysAddToPackageJson": false
|
|
71
|
-
},
|
|
72
|
-
"eslint-config-next": {
|
|
73
|
-
"version": "14.2.3",
|
|
45
|
+
"version": "~15.2.4",
|
|
74
46
|
"alwaysAddToPackageJson": false
|
|
75
47
|
}
|
|
76
48
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/next",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-31313-387cdca",
|
|
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,27 +35,25 @@
|
|
|
35
35
|
"next": ">=14.0.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@nx/devkit": "0.0.0-pr-
|
|
38
|
+
"@nx/devkit": "0.0.0-pr-31313-387cdca",
|
|
39
39
|
"@babel/plugin-proposal-decorators": "^7.22.7",
|
|
40
|
-
"@svgr/webpack": "^8.0
|
|
40
|
+
"@svgr/webpack": "^8.1.0",
|
|
41
41
|
"copy-webpack-plugin": "^10.2.4",
|
|
42
42
|
"file-loader": "^6.2.0",
|
|
43
43
|
"ignore": "^5.0.4",
|
|
44
|
-
"picocolors": "^1.1.0",
|
|
45
44
|
"semver": "^7.5.3",
|
|
46
45
|
"tslib": "^2.3.0",
|
|
47
46
|
"webpack-merge": "^5.8.0",
|
|
48
|
-
"@nx/js": "0.0.0-pr-
|
|
49
|
-
"@nx/eslint": "0.0.0-pr-
|
|
50
|
-
"@nx/react": "0.0.0-pr-
|
|
51
|
-
"@nx/web": "0.0.0-pr-
|
|
52
|
-
"@nx/webpack": "0.0.0-pr-
|
|
53
|
-
"@phenomnomnominal/tsquery": "~5.0.1"
|
|
54
|
-
"@nrwl/next": "0.0.0-pr-31222-862e973"
|
|
47
|
+
"@nx/js": "0.0.0-pr-31313-387cdca",
|
|
48
|
+
"@nx/eslint": "0.0.0-pr-31313-387cdca",
|
|
49
|
+
"@nx/react": "0.0.0-pr-31313-387cdca",
|
|
50
|
+
"@nx/web": "0.0.0-pr-31313-387cdca",
|
|
51
|
+
"@nx/webpack": "0.0.0-pr-31313-387cdca",
|
|
52
|
+
"@phenomnomnominal/tsquery": "~5.0.1"
|
|
55
53
|
},
|
|
56
54
|
"publishConfig": {
|
|
57
55
|
"access": "public"
|
|
58
56
|
},
|
|
59
|
-
"
|
|
60
|
-
"
|
|
57
|
+
"types": "./index.d.ts",
|
|
58
|
+
"type": "commonjs"
|
|
61
59
|
}
|
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; } });
|
|
@@ -7,6 +7,7 @@ const devkit_1 = require("@nx/devkit");
|
|
|
7
7
|
const react_1 = require("@nx/react");
|
|
8
8
|
const webpack_1 = require("@nx/webpack");
|
|
9
9
|
const path_1 = require("path");
|
|
10
|
+
const configuration_1 = require("nx/src/config/configuration");
|
|
10
11
|
function nxComponentTestingPreset(pathToConfig, options) {
|
|
11
12
|
if (global.NX_GRAPH_CREATION) {
|
|
12
13
|
// this is only used by plugins, so we don't need the component testing
|
|
@@ -34,6 +35,8 @@ function nxComponentTestingPreset(pathToConfig, options) {
|
|
|
34
35
|
const parsedBuildTarget = (0, devkit_1.parseTargetString)(buildTarget, {
|
|
35
36
|
cwd: process.cwd(),
|
|
36
37
|
root: devkit_1.workspaceRoot,
|
|
38
|
+
projectsConfigurations: (0, devkit_1.readProjectsConfigurationFromProjectGraph)(graph),
|
|
39
|
+
nxJsonConfiguration: (0, configuration_1.readNxJson)(devkit_1.workspaceRoot),
|
|
37
40
|
isVerbose: false,
|
|
38
41
|
projectName: ctProjectName,
|
|
39
42
|
projectGraph: graph,
|
|
@@ -67,6 +70,7 @@ Able to find CT project, ${!!ctProjectConfig}.`);
|
|
|
67
70
|
projectRoot: ctProjectConfig.root,
|
|
68
71
|
sourceRoot: ctProjectConfig.sourceRoot,
|
|
69
72
|
main: '',
|
|
73
|
+
useTsconfigPaths: undefined,
|
|
70
74
|
fileReplacements: buildFileReplacements,
|
|
71
75
|
assets: buildAssets,
|
|
72
76
|
outputPath: buildOuputPath,
|
package/plugins/with-nx.d.ts
CHANGED
|
@@ -13,6 +13,10 @@ export interface SvgrOptions {
|
|
|
13
13
|
}
|
|
14
14
|
export interface WithNxOptions extends NextConfig {
|
|
15
15
|
nx?: {
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Add SVGR support in your Webpack configuration without relying on Nx. See https://react-svgr.com/docs/webpack/
|
|
18
|
+
* TODO(v22): Remove this option and migrate userland webpack config to explicitly configure @svgr/webpack
|
|
19
|
+
* */
|
|
16
20
|
svgr?: boolean | SvgrOptions;
|
|
17
21
|
babelUpwardRootMode?: boolean;
|
|
18
22
|
fileReplacements?: {
|
package/plugins/with-nx.js
CHANGED
|
@@ -43,7 +43,7 @@ function getNxContext(graph, target) {
|
|
|
43
43
|
return getNxContext(graph, parseTargetString(targetOptions.devServerTarget, partialExecutorContext));
|
|
44
44
|
}
|
|
45
45
|
else if (targetOptions.buildTarget) {
|
|
46
|
-
// Executors such as @nx/next:server
|
|
46
|
+
// Executors such as @nx/next:server define the buildTarget option.
|
|
47
47
|
return getNxContext(graph, parseTargetString(targetOptions.buildTarget, partialExecutorContext));
|
|
48
48
|
}
|
|
49
49
|
// Default case, return info for current target.
|
|
@@ -231,32 +231,17 @@ function getNextConfig(nextConfig = {}, context = getWithNxContext()) {
|
|
|
231
231
|
*/
|
|
232
232
|
// Default SVGR support to be on for projects.
|
|
233
233
|
if (nx?.svgr !== false || typeof nx?.svgr === 'object') {
|
|
234
|
+
forNextVersion('>=15.0.0', () => {
|
|
235
|
+
// Since Next.js 15, turbopack could be enabled by default.
|
|
236
|
+
console.warn(`NX: Next.js SVGR support is deprecated. If used with turbopack, it may not work as expected and is not recommended. Please configure SVGR manually.`);
|
|
237
|
+
});
|
|
234
238
|
const defaultSvgrOptions = {
|
|
235
239
|
svgo: false,
|
|
236
240
|
titleProp: true,
|
|
237
241
|
ref: true,
|
|
238
242
|
};
|
|
239
243
|
const svgrOptions = typeof nx?.svgr === 'object' ? nx.svgr : defaultSvgrOptions;
|
|
240
|
-
// TODO(
|
|
241
|
-
// It should be:
|
|
242
|
-
// use: [{
|
|
243
|
-
// test: /\.svg$/i,
|
|
244
|
-
// type: 'asset',
|
|
245
|
-
// resourceQuery: /react/, // *.svg?react
|
|
246
|
-
// },
|
|
247
|
-
// {
|
|
248
|
-
// test: /\.svg$/i,
|
|
249
|
-
// issuer: /\.[jt]sx?$/,
|
|
250
|
-
// resourceQuery: { not: [/react/] }, // exclude react component if *.svg?react
|
|
251
|
-
// use: ['@svgr/webpack'],
|
|
252
|
-
// }],
|
|
253
|
-
// See:
|
|
254
|
-
// - SVGR: https://react-svgr.com/docs/webpack/#use-svgr-and-asset-svg-in-the-same-project
|
|
255
|
-
// - Vite: https://www.npmjs.com/package/vite-plugin-svgr
|
|
256
|
-
// - Rsbuild: https://github.com/web-infra-dev/rsbuild/pull/1783
|
|
257
|
-
// Note: We also need a migration for any projects that are using SVGR to convert
|
|
258
|
-
// `import { ReactComponent as X } from './x.svg` to
|
|
259
|
-
// `import X from './x.svg?react';
|
|
244
|
+
// TODO(v22): Remove SVGR support
|
|
260
245
|
config.module.rules.push({
|
|
261
246
|
test: /\.svg$/,
|
|
262
247
|
issuer: { not: /\.(css|scss|sass)$/ },
|
|
@@ -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;
|
|
@@ -149,7 +154,7 @@ function stripOuterQuotes(str) {
|
|
|
149
154
|
}
|
|
150
155
|
// Exported for testing
|
|
151
156
|
function ensureFileExtensions(files, absoluteDir) {
|
|
152
|
-
const extensions = ['.js', '.cjs', '.mjs', '.json'];
|
|
157
|
+
const extensions = ['.js', '.cjs', '.mjs', '.json', '.ts'];
|
|
153
158
|
return files.map((file) => {
|
|
154
159
|
const providedExt = (0, path_1.extname)(file);
|
|
155
160
|
if (providedExt && extensions.includes(providedExt))
|
|
@@ -10,7 +10,7 @@ const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
|
|
10
10
|
const wait_for_port_open_1 = require("@nx/web/src/utils/wait-for-port-open");
|
|
11
11
|
async function* serveExecutor(options, context) {
|
|
12
12
|
const buildOptions = (0, devkit_1.readTargetOptions)((0, devkit_1.parseTargetString)(options.buildTarget, context), context);
|
|
13
|
-
const projectRoot = context.
|
|
13
|
+
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
14
14
|
// This is required for the default custom server to work. See the @nx/next:app generator.
|
|
15
15
|
const nextDir = !options.dev && (0, path_1.resolve)(context.root, buildOptions.outputPath);
|
|
16
16
|
process.env.NX_NEXT_DIR ??= options.dev ? projectRoot : nextDir;
|
|
@@ -4,8 +4,9 @@ exports.applicationGenerator = applicationGenerator;
|
|
|
4
4
|
exports.applicationGeneratorInternal = applicationGeneratorInternal;
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const js_1 = require("@nx/js");
|
|
7
|
-
const
|
|
7
|
+
const setup_tailwind_1 = require("../setup-tailwind/setup-tailwind");
|
|
8
8
|
const versions_1 = require("@nx/react/src/utils/versions");
|
|
9
|
+
const version_utils_1 = require("@nx/react/src/utils/version-utils");
|
|
9
10
|
const normalize_options_1 = require("./lib/normalize-options");
|
|
10
11
|
const add_e2e_1 = require("./lib/add-e2e");
|
|
11
12
|
const add_jest_1 = require("./lib/add-jest");
|
|
@@ -21,10 +22,13 @@ const update_cypress_tsconfig_1 = require("./lib/update-cypress-tsconfig");
|
|
|
21
22
|
const show_possible_warnings_1 = require("./lib/show-possible-warnings");
|
|
22
23
|
const versions_2 = require("../../utils/versions");
|
|
23
24
|
const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
|
|
25
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
26
|
+
const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields");
|
|
27
|
+
const add_swc_to_custom_server_1 = require("../../utils/add-swc-to-custom-server");
|
|
24
28
|
async function applicationGenerator(host, schema) {
|
|
25
29
|
return await applicationGeneratorInternal(host, {
|
|
26
30
|
addPlugin: false,
|
|
27
|
-
|
|
31
|
+
useProjectJson: true,
|
|
28
32
|
...schema,
|
|
29
33
|
});
|
|
30
34
|
}
|
|
@@ -36,6 +40,9 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
36
40
|
js: options.js,
|
|
37
41
|
skipPackageJson: options.skipPackageJson,
|
|
38
42
|
skipFormat: true,
|
|
43
|
+
addTsPlugin: options.isTsSolutionSetup,
|
|
44
|
+
formatter: options.formatter,
|
|
45
|
+
platform: 'web',
|
|
39
46
|
});
|
|
40
47
|
tasks.push(jsInitTask);
|
|
41
48
|
const nextTask = await (0, init_1.nextInitGenerator)(host, {
|
|
@@ -45,6 +52,11 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
45
52
|
tasks.push(nextTask);
|
|
46
53
|
(0, create_application_files_1.createApplicationFiles)(host, options);
|
|
47
54
|
(0, add_project_1.addProject)(host, options);
|
|
55
|
+
// If we are using the new TS solution
|
|
56
|
+
// We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
|
|
57
|
+
if (options.isTsSolutionSetup) {
|
|
58
|
+
await (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.appProjectRoot);
|
|
59
|
+
}
|
|
48
60
|
const e2eTask = await (0, add_e2e_1.addE2e)(host, options);
|
|
49
61
|
tasks.push(e2eTask);
|
|
50
62
|
const jestTask = await (0, add_jest_1.addJest)(host, options);
|
|
@@ -52,7 +64,7 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
52
64
|
const lintTask = await (0, add_linting_1.addLinting)(host, options);
|
|
53
65
|
tasks.push(lintTask);
|
|
54
66
|
if (options.style === 'tailwind') {
|
|
55
|
-
const tailwindTask = await (0,
|
|
67
|
+
const tailwindTask = await (0, setup_tailwind_1.setupTailwindGenerator)(host, {
|
|
56
68
|
project: options.projectName,
|
|
57
69
|
});
|
|
58
70
|
tasks.push(tailwindTask);
|
|
@@ -65,6 +77,10 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
65
77
|
(0, update_jest_config_1.updateJestConfig)(host, options);
|
|
66
78
|
(0, update_cypress_tsconfig_1.updateCypressTsConfig)(host, options);
|
|
67
79
|
(0, set_defaults_1.setDefaults)(host, options);
|
|
80
|
+
if (options.swc) {
|
|
81
|
+
const swcTask = (0, add_swc_to_custom_server_1.configureForSwc)(host, options.appProjectRoot);
|
|
82
|
+
tasks.push(swcTask);
|
|
83
|
+
}
|
|
68
84
|
if (options.customServer) {
|
|
69
85
|
await (0, custom_server_1.customServerGenerator)(host, {
|
|
70
86
|
project: options.projectName,
|
|
@@ -72,15 +88,25 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
72
88
|
});
|
|
73
89
|
}
|
|
74
90
|
if (!options.skipPackageJson) {
|
|
91
|
+
const reactVersions = await (0, version_utils_1.getReactDependenciesVersionsToInstall)(host);
|
|
75
92
|
const devDependencies = {
|
|
76
|
-
'@types/react':
|
|
77
|
-
'@types/react-dom':
|
|
93
|
+
'@types/react': reactVersions['@types/react'],
|
|
94
|
+
'@types/react-dom': reactVersions['@types/react-dom'],
|
|
78
95
|
};
|
|
79
|
-
if (
|
|
96
|
+
if (options.unitTestRunner && options.unitTestRunner !== 'none') {
|
|
80
97
|
devDependencies['@testing-library/react'] = versions_1.testingLibraryReactVersion;
|
|
98
|
+
devDependencies['@testing-library/dom'] = versions_1.testingLibraryDomVersion;
|
|
81
99
|
}
|
|
82
100
|
tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, { tslib: versions_2.tsLibVersion }, devDependencies));
|
|
83
101
|
}
|
|
102
|
+
(0, ts_solution_setup_1.updateTsconfigFiles)(host, options.appProjectRoot, 'tsconfig.json', {
|
|
103
|
+
jsx: 'preserve',
|
|
104
|
+
module: 'esnext',
|
|
105
|
+
moduleResolution: 'bundler',
|
|
106
|
+
}, options.linter === 'eslint'
|
|
107
|
+
? ['.next', 'eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
|
|
108
|
+
: ['.next'], options.src ? 'src' : '.');
|
|
109
|
+
(0, sort_fields_1.sortPackageJsonFields)(host, options.appProjectRoot);
|
|
84
110
|
if (!options.skipFormat) {
|
|
85
111
|
await (0, devkit_1.formatFiles)(host);
|
|
86
112
|
}
|
|
@@ -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
|
/*
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
/// <reference types="next/image-types/global" />
|
|
3
3
|
|
|
4
4
|
// NOTE: This file should not be edited
|
|
5
|
-
// see https://nextjs.org/docs
|
|
5
|
+
// see https://nextjs.org/docs/<%- appDirType %>/api-reference/config/typescript for more information.
|
|
@@ -12,11 +12,9 @@ const { withLess } = require('@nx/next/plugins/with-less');
|
|
|
12
12
|
* @type {import('@nx/next/plugins/with-nx').WithNxOptions}
|
|
13
13
|
**/
|
|
14
14
|
const nextConfig = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
svgr: false,
|
|
19
|
-
},
|
|
15
|
+
// Use this to set Nx-specific options
|
|
16
|
+
// See: https://nx.dev/recipes/next/next-config-setup
|
|
17
|
+
nx: {},
|
|
20
18
|
};
|
|
21
19
|
|
|
22
20
|
const plugins = [
|
|
@@ -36,11 +34,9 @@ module.exports = composePlugins(...plugins)(nextConfig);
|
|
|
36
34
|
* @type {import('@nx/next/plugins/with-nx').WithNxOptions}
|
|
37
35
|
**/
|
|
38
36
|
const nextConfig = {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
svgr: false,
|
|
43
|
-
},
|
|
37
|
+
// Use this to set Nx-specific options
|
|
38
|
+
// See: https://nx.dev/recipes/next/next-config-setup
|
|
39
|
+
nx: {},
|
|
44
40
|
<% if (style === 'styled-components') { %>
|
|
45
41
|
compiler: {
|
|
46
42
|
// For other options, see https://styled-components.com/docs/tooling#babel-plugin
|
|
@@ -66,11 +62,9 @@ module.exports = composePlugins(...plugins)(nextConfig);
|
|
|
66
62
|
* @type {import('@nx/next/plugins/with-nx').WithNxOptions}
|
|
67
63
|
**/
|
|
68
64
|
const nextConfig = {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
svgr: false,
|
|
73
|
-
},
|
|
65
|
+
// Use this to set Nx-specific options
|
|
66
|
+
// See: https://nx.dev/recipes/next/next-config-setup
|
|
67
|
+
nx: {},
|
|
74
68
|
};
|
|
75
69
|
|
|
76
70
|
const plugins = [
|
|
@@ -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', () => {
|
|
@@ -3,16 +3,23 @@
|
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"jsx": "preserve",
|
|
5
5
|
<% if (style === '@emotion/styled') { %>"jsxImportSource": "@emotion/react",<% } %>
|
|
6
|
-
"allowJs": true,
|
|
7
|
-
"esModuleInterop": true,
|
|
8
|
-
"allowSyntheticDefaultImports": true,
|
|
9
6
|
"strict": true,
|
|
10
|
-
"forceConsistentCasingInFileNames": true,
|
|
11
7
|
"noEmit": true,
|
|
8
|
+
"emitDeclarationOnly": false,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"module": "esnext",
|
|
11
|
+
"moduleResolution": "bundler",
|
|
12
12
|
"resolveJsonModule": true,
|
|
13
13
|
"isolatedModules": true,
|
|
14
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
15
|
+
"allowJs": true,
|
|
16
|
+
"allowSyntheticDefaultImports": true,
|
|
17
|
+
"forceConsistentCasingInFileNames": true,
|
|
14
18
|
"incremental": true,
|
|
15
|
-
"plugins": [{ "name": "next" }]
|
|
19
|
+
"plugins": [{ "name": "next" }]<% if (isUsingTsSolutionSetup) { %>,
|
|
20
|
+
"paths": {
|
|
21
|
+
"@/*": [<% if (src) { %>"./src/*"<% } else { %>"./*"<% } %>]
|
|
22
|
+
}<% } %>
|
|
16
23
|
},
|
|
17
24
|
"include": [
|
|
18
25
|
"<%= rootPath %>**/*.ts",
|
|
@@ -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
|
/*
|