@nx/next 21.0.0-beta.0 → 21.0.0-beta.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/migrations.json +33 -0
- package/package.json +7 -7
- package/src/generators/application/application.js +16 -9
- package/src/generators/application/lib/add-e2e.js +28 -27
- package/src/generators/application/lib/add-linting.js +1 -0
- package/src/generators/application/lib/add-project.js +21 -19
- package/src/generators/application/lib/create-application-files.js +1 -1
- package/src/generators/application/lib/normalize-options.d.ts +4 -1
- package/src/generators/application/lib/normalize-options.js +11 -5
- package/src/generators/application/schema.d.ts +1 -0
- package/src/generators/application/schema.json +4 -0
- package/src/generators/custom-server/custom-server.js +15 -8
- package/src/generators/custom-server/files/server/main.ts__tmpl__ +1 -1
- package/src/generators/cypress-component-configuration/cypress-component-configuration.js +4 -1
- package/src/generators/library/lib/normalize-options.js +4 -2
- package/src/generators/library/library.js +4 -2
- package/src/generators/library/schema.d.ts +1 -0
- package/src/generators/library/schema.json +4 -0
- 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/utils/add-swc-to-custom-server.d.ts +1 -1
- package/src/utils/add-swc-to-custom-server.js +8 -12
- package/src/utils/versions.d.ts +3 -3
- package/src/utils/versions.js +3 -3
- package/tailwind.d.ts +7 -2
- package/tailwind.js +39 -4
package/migrations.json
CHANGED
|
@@ -38,6 +38,39 @@
|
|
|
38
38
|
"alwaysAddToPackageJson": false
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
+
},
|
|
42
|
+
"20.7.1-beta.0": {
|
|
43
|
+
"version": "20.7.1-beta.0",
|
|
44
|
+
"packages": {
|
|
45
|
+
"eslint-config-next": {
|
|
46
|
+
"version": "^15.2.4",
|
|
47
|
+
"alwaysAddToPackageJson": false
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"20.7.1-beta.0-next14": {
|
|
52
|
+
"version": "20.7.1-beta.0",
|
|
53
|
+
"requires": {
|
|
54
|
+
"next": "^14.0.0"
|
|
55
|
+
},
|
|
56
|
+
"packages": {
|
|
57
|
+
"next": {
|
|
58
|
+
"version": "~14.2.26",
|
|
59
|
+
"alwaysAddToPackageJson": false
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"20.7.1-beta.0-next15": {
|
|
64
|
+
"version": "20.7.1-beta.0",
|
|
65
|
+
"requires": {
|
|
66
|
+
"next": "^15.0.0"
|
|
67
|
+
},
|
|
68
|
+
"packages": {
|
|
69
|
+
"next": {
|
|
70
|
+
"version": "~15.2.4",
|
|
71
|
+
"alwaysAddToPackageJson": false
|
|
72
|
+
}
|
|
73
|
+
}
|
|
41
74
|
}
|
|
42
75
|
}
|
|
43
76
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/next",
|
|
3
|
-
"version": "21.0.0-beta.
|
|
3
|
+
"version": "21.0.0-beta.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.0.0-beta.
|
|
38
|
+
"@nx/devkit": "21.0.0-beta.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.0.0-beta.
|
|
48
|
-
"@nx/eslint": "21.0.0-beta.
|
|
49
|
-
"@nx/react": "21.0.0-beta.
|
|
50
|
-
"@nx/web": "21.0.0-beta.
|
|
51
|
-
"@nx/webpack": "21.0.0-beta.
|
|
47
|
+
"@nx/js": "21.0.0-beta.2",
|
|
48
|
+
"@nx/eslint": "21.0.0-beta.2",
|
|
49
|
+
"@nx/react": "21.0.0-beta.2",
|
|
50
|
+
"@nx/web": "21.0.0-beta.2",
|
|
51
|
+
"@nx/webpack": "21.0.0-beta.2",
|
|
52
52
|
"@phenomnomnominal/tsquery": "~5.0.1"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|
|
@@ -4,7 +4,7 @@ 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
9
|
const version_utils_1 = require("@nx/react/src/utils/version-utils");
|
|
10
10
|
const normalize_options_1 = require("./lib/normalize-options");
|
|
@@ -24,9 +24,11 @@ const versions_2 = require("../../utils/versions");
|
|
|
24
24
|
const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
|
|
25
25
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
26
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");
|
|
27
28
|
async function applicationGenerator(host, schema) {
|
|
28
29
|
return await applicationGeneratorInternal(host, {
|
|
29
30
|
addPlugin: false,
|
|
31
|
+
useProjectJson: true,
|
|
30
32
|
...schema,
|
|
31
33
|
});
|
|
32
34
|
}
|
|
@@ -38,8 +40,8 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
38
40
|
js: options.js,
|
|
39
41
|
skipPackageJson: options.skipPackageJson,
|
|
40
42
|
skipFormat: true,
|
|
41
|
-
addTsPlugin:
|
|
42
|
-
formatter:
|
|
43
|
+
addTsPlugin: options.isTsSolutionSetup,
|
|
44
|
+
formatter: options.formatter,
|
|
43
45
|
platform: 'web',
|
|
44
46
|
});
|
|
45
47
|
tasks.push(jsInitTask);
|
|
@@ -50,6 +52,11 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
50
52
|
tasks.push(nextTask);
|
|
51
53
|
(0, create_application_files_1.createApplicationFiles)(host, options);
|
|
52
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
|
+
}
|
|
53
60
|
const e2eTask = await (0, add_e2e_1.addE2e)(host, options);
|
|
54
61
|
tasks.push(e2eTask);
|
|
55
62
|
const jestTask = await (0, add_jest_1.addJest)(host, options);
|
|
@@ -57,7 +64,7 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
57
64
|
const lintTask = await (0, add_linting_1.addLinting)(host, options);
|
|
58
65
|
tasks.push(lintTask);
|
|
59
66
|
if (options.style === 'tailwind') {
|
|
60
|
-
const tailwindTask = await (0,
|
|
67
|
+
const tailwindTask = await (0, setup_tailwind_1.setupTailwindGenerator)(host, {
|
|
61
68
|
project: options.projectName,
|
|
62
69
|
});
|
|
63
70
|
tasks.push(tailwindTask);
|
|
@@ -70,6 +77,10 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
70
77
|
(0, update_jest_config_1.updateJestConfig)(host, options);
|
|
71
78
|
(0, update_cypress_tsconfig_1.updateCypressTsConfig)(host, options);
|
|
72
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
|
+
}
|
|
73
84
|
if (options.customServer) {
|
|
74
85
|
await (0, custom_server_1.customServerGenerator)(host, {
|
|
75
86
|
project: options.projectName,
|
|
@@ -84,6 +95,7 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
84
95
|
};
|
|
85
96
|
if (options.unitTestRunner && options.unitTestRunner !== 'none') {
|
|
86
97
|
devDependencies['@testing-library/react'] = versions_1.testingLibraryReactVersion;
|
|
98
|
+
devDependencies['@testing-library/dom'] = versions_1.testingLibraryDomVersion;
|
|
87
99
|
}
|
|
88
100
|
tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, { tslib: versions_2.tsLibVersion }, devDependencies));
|
|
89
101
|
}
|
|
@@ -94,11 +106,6 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
94
106
|
}, options.linter === 'eslint'
|
|
95
107
|
? ['.next', 'eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
|
|
96
108
|
: ['.next'], options.src ? 'src' : '.');
|
|
97
|
-
// If we are using the new TS solution
|
|
98
|
-
// We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
|
|
99
|
-
if (options.useTsSolution) {
|
|
100
|
-
(0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.appProjectRoot);
|
|
101
|
-
}
|
|
102
109
|
(0, sort_fields_1.sortPackageJsonFields)(host, options.appProjectRoot);
|
|
103
110
|
if (!options.skipFormat) {
|
|
104
111
|
await (0, devkit_1.formatFiles)(host);
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addE2e = addE2e;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const e2e_web_server_info_utils_1 = require("@nx/devkit/src/generators/e2e-web-server-info-utils");
|
|
6
|
+
const target_defaults_utils_1 = require("@nx/devkit/src/generators/target-defaults-utils");
|
|
7
|
+
const find_plugin_for_config_file_1 = require("@nx/devkit/src/utils/find-plugin-for-config-file");
|
|
5
8
|
const eslint_1 = require("@nx/eslint");
|
|
6
|
-
const versions_1 = require("../../../utils/versions");
|
|
7
9
|
const web_1 = require("@nx/web");
|
|
8
|
-
const
|
|
9
|
-
const target_defaults_utils_1 = require("@nx/devkit/src/generators/target-defaults-utils");
|
|
10
|
-
const e2e_web_server_info_utils_1 = require("@nx/devkit/src/generators/e2e-web-server-info-utils");
|
|
11
|
-
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
10
|
+
const versions_1 = require("../../../utils/versions");
|
|
12
11
|
async function addE2e(host, options) {
|
|
13
12
|
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
14
13
|
const hasPlugin = nxJson.plugins?.some((p) => typeof p === 'string'
|
|
@@ -25,17 +24,15 @@ async function addE2e(host, options) {
|
|
|
25
24
|
spa: true,
|
|
26
25
|
});
|
|
27
26
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
});
|
|
27
|
+
const packageJson = {
|
|
28
|
+
name: options.e2eProjectName,
|
|
29
|
+
version: '0.0.1',
|
|
30
|
+
private: true,
|
|
31
|
+
};
|
|
32
|
+
if (!options.useProjectJson) {
|
|
33
|
+
packageJson.nx = {
|
|
34
|
+
implicitDependencies: [options.projectName],
|
|
35
|
+
};
|
|
39
36
|
}
|
|
40
37
|
else {
|
|
41
38
|
(0, devkit_1.addProjectConfiguration)(host, options.e2eProjectName, {
|
|
@@ -47,6 +44,9 @@ async function addE2e(host, options) {
|
|
|
47
44
|
implicitDependencies: [options.projectName],
|
|
48
45
|
});
|
|
49
46
|
}
|
|
47
|
+
if (!options.useProjectJson || options.isTsSolutionSetup) {
|
|
48
|
+
(0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), packageJson);
|
|
49
|
+
}
|
|
50
50
|
const e2eTask = await configurationGenerator(host, {
|
|
51
51
|
...options,
|
|
52
52
|
linter: eslint_1.Linter.EsLint,
|
|
@@ -81,17 +81,15 @@ async function addE2e(host, options) {
|
|
|
81
81
|
}
|
|
82
82
|
else if (options.e2eTestRunner === 'playwright') {
|
|
83
83
|
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', versions_1.nxVersion);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
},
|
|
94
|
-
});
|
|
84
|
+
const packageJson = {
|
|
85
|
+
name: options.e2eProjectName,
|
|
86
|
+
version: '0.0.1',
|
|
87
|
+
private: true,
|
|
88
|
+
};
|
|
89
|
+
if (!options.useProjectJson) {
|
|
90
|
+
packageJson.nx = {
|
|
91
|
+
implicitDependencies: [options.projectName],
|
|
92
|
+
};
|
|
95
93
|
}
|
|
96
94
|
else {
|
|
97
95
|
(0, devkit_1.addProjectConfiguration)(host, options.e2eProjectName, {
|
|
@@ -103,6 +101,9 @@ async function addE2e(host, options) {
|
|
|
103
101
|
implicitDependencies: [options.projectName],
|
|
104
102
|
});
|
|
105
103
|
}
|
|
104
|
+
if (!options.useProjectJson || options.isTsSolutionSetup) {
|
|
105
|
+
(0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), packageJson);
|
|
106
|
+
}
|
|
106
107
|
const e2eTask = await configurationGenerator(host, {
|
|
107
108
|
rootProject: options.rootProject,
|
|
108
109
|
project: options.e2eProjectName,
|
|
@@ -61,6 +61,7 @@ async function addLinting(host, options) {
|
|
|
61
61
|
tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, lint_1.extraEslintDependencies.dependencies, {
|
|
62
62
|
...lint_1.extraEslintDependencies.devDependencies,
|
|
63
63
|
'eslint-config-next': versions_1.eslintConfigNextVersion,
|
|
64
|
+
'@next/eslint-plugin-next': versions_1.eslintConfigNextVersion,
|
|
64
65
|
}));
|
|
65
66
|
}
|
|
66
67
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
@@ -3,8 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.addProject = addProject;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const target_defaults_utils_1 = require("@nx/devkit/src/generators/target-defaults-utils");
|
|
6
|
-
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
7
|
-
const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
|
|
8
6
|
const versions_1 = require("../../../utils/versions");
|
|
9
7
|
const react_1 = require("@nx/react");
|
|
10
8
|
function addProject(host, options) {
|
|
@@ -57,27 +55,31 @@ function addProject(host, options) {
|
|
|
57
55
|
targets,
|
|
58
56
|
tags: options.parsedTags,
|
|
59
57
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
58
|
+
const packageJson = {
|
|
59
|
+
name: options.importPath,
|
|
60
|
+
version: '0.0.1',
|
|
61
|
+
private: true,
|
|
62
|
+
dependencies: {
|
|
63
|
+
next: versions_1.nextVersion,
|
|
64
|
+
react: react_1.reactVersion,
|
|
65
|
+
'react-dom': react_1.reactDomVersion,
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
if (!options.useProjectJson) {
|
|
69
|
+
if (options.projectName !== options.importPath) {
|
|
70
|
+
packageJson.nx = { name: options.projectName };
|
|
71
|
+
}
|
|
72
|
+
if (options.parsedTags?.length) {
|
|
73
|
+
packageJson.nx ??= {};
|
|
74
|
+
packageJson.nx.tags = options.parsedTags;
|
|
75
|
+
}
|
|
77
76
|
}
|
|
78
77
|
else {
|
|
79
78
|
(0, devkit_1.addProjectConfiguration)(host, options.projectName, {
|
|
80
79
|
...project,
|
|
81
80
|
});
|
|
82
81
|
}
|
|
82
|
+
if (!options.useProjectJson || options.isTsSolutionSetup) {
|
|
83
|
+
(0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), packageJson);
|
|
84
|
+
}
|
|
83
85
|
}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
2
|
import { Schema } from '../schema';
|
|
3
|
-
export interface NormalizedSchema extends Schema {
|
|
3
|
+
export interface NormalizedSchema extends Omit<Schema, 'name' | 'useTsSolution'> {
|
|
4
4
|
projectName: string;
|
|
5
|
+
projectSimpleName: string;
|
|
5
6
|
appProjectRoot: string;
|
|
7
|
+
importPath: string;
|
|
6
8
|
outputPath: string;
|
|
7
9
|
e2eProjectName: string;
|
|
8
10
|
e2eProjectRoot: string;
|
|
9
11
|
parsedTags: string[];
|
|
10
12
|
fileName: string;
|
|
11
13
|
styledModule: null | string;
|
|
14
|
+
isTsSolutionSetup: boolean;
|
|
12
15
|
js?: boolean;
|
|
13
16
|
}
|
|
14
17
|
export declare function normalizeOptions(host: Tree, options: Schema): Promise<NormalizedSchema>;
|
|
@@ -5,9 +5,10 @@ const devkit_1 = require("@nx/devkit");
|
|
|
5
5
|
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
6
6
|
const eslint_1 = require("@nx/eslint");
|
|
7
7
|
const assertion_1 = require("@nx/react/src/utils/assertion");
|
|
8
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
8
9
|
async function normalizeOptions(host, options) {
|
|
9
|
-
await (0, project_name_and_root_utils_1.
|
|
10
|
-
const { projectName:
|
|
10
|
+
await (0, project_name_and_root_utils_1.ensureRootProjectName)(options, 'application');
|
|
11
|
+
const { projectName, names: projectNames, projectRoot: appProjectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
11
12
|
name: options.name,
|
|
12
13
|
projectType: 'application',
|
|
13
14
|
directory: options.directory,
|
|
@@ -18,10 +19,11 @@ async function normalizeOptions(host, options) {
|
|
|
18
19
|
const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
19
20
|
nxJson.useInferencePlugins !== false;
|
|
20
21
|
options.addPlugin ??= addPlugin;
|
|
22
|
+
const isTsSolutionSetup = options.useTsSolution || (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
|
|
23
|
+
const appProjectName = !isTsSolutionSetup || options.name ? projectName : importPath;
|
|
21
24
|
const e2eProjectName = options.rootProject ? 'e2e' : `${appProjectName}-e2e`;
|
|
22
25
|
const e2eProjectRoot = options.rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
|
|
23
|
-
const
|
|
24
|
-
const outputPath = (0, devkit_1.joinPathFragments)('dist', appProjectRoot, ...(options.rootProject ? [name] : []));
|
|
26
|
+
const outputPath = (0, devkit_1.joinPathFragments)('dist', appProjectRoot, ...(options.rootProject ? [projectNames.projectFileName] : []));
|
|
25
27
|
const parsedTags = options.tags
|
|
26
28
|
? options.tags.split(',').map((s) => s.trim())
|
|
27
29
|
: [];
|
|
@@ -42,12 +44,16 @@ async function normalizeOptions(host, options) {
|
|
|
42
44
|
e2eTestRunner: options.e2eTestRunner || 'playwright',
|
|
43
45
|
fileName,
|
|
44
46
|
linter: options.linter || eslint_1.Linter.EsLint,
|
|
45
|
-
name,
|
|
46
47
|
outputPath,
|
|
47
48
|
parsedTags,
|
|
48
49
|
projectName: appProjectName,
|
|
50
|
+
projectSimpleName: projectNames.projectSimpleName,
|
|
49
51
|
style: options.style || 'css',
|
|
52
|
+
swc: options.swc ?? true,
|
|
50
53
|
styledModule,
|
|
51
54
|
unitTestRunner: options.unitTestRunner || 'jest',
|
|
55
|
+
importPath,
|
|
56
|
+
isTsSolutionSetup,
|
|
57
|
+
useProjectJson: options.useProjectJson ?? !isTsSolutionSetup,
|
|
52
58
|
};
|
|
53
59
|
}
|
|
@@ -144,6 +144,10 @@
|
|
|
144
144
|
"default": false,
|
|
145
145
|
"hidden": true,
|
|
146
146
|
"x-priority": "internal"
|
|
147
|
+
},
|
|
148
|
+
"useProjectJson": {
|
|
149
|
+
"type": "boolean",
|
|
150
|
+
"description": "Use a `project.json` configuration file instead of inlining the Nx configuration in the `package.json` file."
|
|
147
151
|
}
|
|
148
152
|
},
|
|
149
153
|
"required": ["directory"],
|
|
@@ -8,20 +8,17 @@ const add_swc_to_custom_server_1 = require("../../utils/add-swc-to-custom-server
|
|
|
8
8
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
9
9
|
async function customServerGenerator(host, options) {
|
|
10
10
|
const project = (0, devkit_2.readProjectConfiguration)(host, options.project);
|
|
11
|
+
const swcServerName = '.server.swcrc';
|
|
11
12
|
const nxJson = (0, devkit_2.readNxJson)(host);
|
|
12
13
|
const hasPlugin = nxJson.plugins?.some((p) => typeof p === 'string'
|
|
13
14
|
? p === '@nx/next/plugin'
|
|
14
15
|
: p.plugin === '@nx/next/plugin');
|
|
15
|
-
if (project.targets?.build?.executor !== '@nx/next:build' &&
|
|
16
|
-
project.targets?.build?.executor !== '@nrwl/next:build' &&
|
|
17
|
-
!hasPlugin) {
|
|
16
|
+
if (project.targets?.build?.executor !== '@nx/next:build' && !hasPlugin) {
|
|
18
17
|
devkit_2.logger.error(`Project ${options.project} is not a Next.js project. Did you generate it with "nx g @nx/next:app"?`);
|
|
19
18
|
return;
|
|
20
19
|
}
|
|
21
20
|
// In Nx 18 next artifacts are inside the project root .next/ & dist/ (for custom server)
|
|
22
|
-
const outputPath =
|
|
23
|
-
? `dist/${project.root}`
|
|
24
|
-
: project.targets?.build?.options?.outputPath;
|
|
21
|
+
const outputPath = `dist/${project.root}-server`;
|
|
25
22
|
const root = project.root;
|
|
26
23
|
if ((!root ||
|
|
27
24
|
!outputPath ||
|
|
@@ -38,7 +35,9 @@ async function customServerGenerator(host, options) {
|
|
|
38
35
|
}
|
|
39
36
|
// In Nx 18 next artifacts are inside the project root .next/ & dist/ (for custom server)
|
|
40
37
|
// So we need ensure the mapping is correct from dist to the project root
|
|
41
|
-
const projectPathFromDist =
|
|
38
|
+
const projectPathFromDist = hasPlugin
|
|
39
|
+
? `../../${(0, devkit_2.offsetFromRoot)(project.root)}${project.root}`
|
|
40
|
+
: `${(0, devkit_2.offsetFromRoot)(`dist/${project.root}`)}${project.root}`;
|
|
42
41
|
const offset = (0, devkit_2.offsetFromRoot)(project.root);
|
|
43
42
|
const isTsSolution = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
|
|
44
43
|
(0, devkit_2.generateFiles)(host, (0, path_1.join)(__dirname, 'files'), project.root, {
|
|
@@ -72,6 +71,9 @@ async function customServerGenerator(host, options) {
|
|
|
72
71
|
tsConfig: `${root}/tsconfig.server.json`,
|
|
73
72
|
clean: false,
|
|
74
73
|
assets: [],
|
|
74
|
+
...(options.compiler === 'tsc'
|
|
75
|
+
? {}
|
|
76
|
+
: { swcrc: `${root}/${swcServerName}` }),
|
|
75
77
|
},
|
|
76
78
|
configurations: {
|
|
77
79
|
development: {},
|
|
@@ -105,6 +107,11 @@ async function customServerGenerator(host, options) {
|
|
|
105
107
|
return json;
|
|
106
108
|
});
|
|
107
109
|
if (options.compiler === 'swc') {
|
|
108
|
-
|
|
110
|
+
// Update app swc to exlude server files
|
|
111
|
+
(0, devkit_2.updateJson)(host, (0, path_1.join)(project.root, '.swcrc'), (json) => {
|
|
112
|
+
json.exclude = [...(json.exclude ?? []), 'server/**'];
|
|
113
|
+
return json;
|
|
114
|
+
});
|
|
115
|
+
return (0, add_swc_to_custom_server_1.configureForSwc)(host, project.root, swcServerName, ['src/**/*']);
|
|
109
116
|
}
|
|
110
117
|
}
|
|
@@ -15,8 +15,8 @@ import next from 'next';
|
|
|
15
15
|
// - The fallback `__dirname` is for production builds.
|
|
16
16
|
// - Feel free to change this to suit your needs.
|
|
17
17
|
|
|
18
|
-
const dir = process.env.NX_NEXT_DIR || <%- hasPlugin ? `path.join(__dirname, '${projectPathFromDist}')` : `path.join(__dirname, '..')`; %>
|
|
19
18
|
const dev = process.env.NODE_ENV === 'development';
|
|
19
|
+
const dir = process.env.NX_NEXT_DIR || <%- hasPlugin ? `path.join(__dirname, '${projectPathFromDist}')` : `path.join(__dirname, dev ? '..' : '', '${projectPathFromDist}')`; %>
|
|
20
20
|
|
|
21
21
|
// HTTP Server options:
|
|
22
22
|
// - Feel free to change this to suit your needs.
|
|
@@ -47,9 +47,12 @@ async function cypressComponentConfigurationInternal(tree, options) {
|
|
|
47
47
|
}
|
|
48
48
|
async function addFiles(tree, projectConfig, opts) {
|
|
49
49
|
const { addMountDefinition, addDefaultCTConfig } = await Promise.resolve().then(() => require('@nx/cypress/src/utils/config'));
|
|
50
|
+
const { getInstalledCypressMajorVersion } = await Promise.resolve().then(() => require('@nx/cypress/src/utils/versions'));
|
|
51
|
+
const installedCypressMajorVersion = getInstalledCypressMajorVersion(tree);
|
|
50
52
|
const ctFile = (0, devkit_1.joinPathFragments)(projectConfig.root, 'cypress', 'support', 'component.ts');
|
|
51
53
|
const updatedCommandFile = await addMountDefinition(tree.read(ctFile, 'utf-8'));
|
|
52
|
-
|
|
54
|
+
const moduleSpecifier = installedCypressMajorVersion >= 14 ? 'cypress/react' : 'cypress/react18';
|
|
55
|
+
tree.write(ctFile, `import { mount } from '${moduleSpecifier}';\nimport './styles.ct.css';\n${updatedCommandFile}`);
|
|
53
56
|
const cyFile = (0, devkit_1.joinPathFragments)(projectConfig.root, 'cypress.config.ts');
|
|
54
57
|
const updatedCyConfig = await addDefaultCTConfig(tree.read(cyFile, 'utf-8'));
|
|
55
58
|
tree.write(cyFile, `import { nxComponentTestingPreset } from '@nx/next/plugins/component-testing';\n${updatedCyConfig}`);
|
|
@@ -5,7 +5,7 @@ const devkit_1 = require("@nx/devkit");
|
|
|
5
5
|
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
6
6
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
7
7
|
async function normalizeOptions(host, options) {
|
|
8
|
-
await (0, project_name_and_root_utils_1.
|
|
8
|
+
await (0, project_name_and_root_utils_1.ensureRootProjectName)(options, 'library');
|
|
9
9
|
const { projectRoot, importPath } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
10
10
|
name: options.name,
|
|
11
11
|
projectType: 'library',
|
|
@@ -16,10 +16,12 @@ async function normalizeOptions(host, options) {
|
|
|
16
16
|
const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
17
17
|
nxJson.useInferencePlugins !== false;
|
|
18
18
|
options.addPlugin ??= addPlugin;
|
|
19
|
+
const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
|
|
19
20
|
return {
|
|
20
21
|
...options,
|
|
21
22
|
importPath,
|
|
22
23
|
projectRoot,
|
|
23
|
-
isUsingTsSolutionConfig
|
|
24
|
+
isUsingTsSolutionConfig,
|
|
25
|
+
useProjectJson: options.useProjectJson ?? !isUsingTsSolutionConfig,
|
|
24
26
|
};
|
|
25
27
|
}
|
|
@@ -14,6 +14,7 @@ const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields");
|
|
|
14
14
|
async function libraryGenerator(host, rawOptions) {
|
|
15
15
|
return await libraryGeneratorInternal(host, {
|
|
16
16
|
addPlugin: false,
|
|
17
|
+
useProjectJson: true,
|
|
17
18
|
...rawOptions,
|
|
18
19
|
});
|
|
19
20
|
}
|
|
@@ -33,7 +34,6 @@ async function libraryGeneratorInternal(host, rawOptions) {
|
|
|
33
34
|
tasks.push(initTask);
|
|
34
35
|
const libTask = await (0, library_1.libraryGenerator)(host, {
|
|
35
36
|
...options,
|
|
36
|
-
bundler: 'none',
|
|
37
37
|
skipFormat: true,
|
|
38
38
|
});
|
|
39
39
|
tasks.push(libTask);
|
|
@@ -41,9 +41,11 @@ async function libraryGeneratorInternal(host, rawOptions) {
|
|
|
41
41
|
const devDependencies = {};
|
|
42
42
|
if (options.linter === 'eslint') {
|
|
43
43
|
devDependencies['eslint-config-next'] = versions_2.eslintConfigNextVersion;
|
|
44
|
+
devDependencies['@next/eslint-plugin-next'] = versions_2.eslintConfigNextVersion;
|
|
44
45
|
}
|
|
45
46
|
if (options.unitTestRunner && options.unitTestRunner !== 'none') {
|
|
46
47
|
devDependencies['@testing-library/react'] = versions_1.testingLibraryReactVersion;
|
|
48
|
+
devDependencies['@testing-library/dom'] = versions_1.testingLibraryDomVersion;
|
|
47
49
|
}
|
|
48
50
|
tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, { tslib: versions_2.tsLibVersion }, devDependencies));
|
|
49
51
|
}
|
|
@@ -95,7 +97,7 @@ async function libraryGeneratorInternal(host, rawOptions) {
|
|
|
95
97
|
? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
|
|
96
98
|
: undefined);
|
|
97
99
|
if (options.isUsingTsSolutionConfig) {
|
|
98
|
-
(0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.projectRoot);
|
|
100
|
+
await (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.projectRoot);
|
|
99
101
|
}
|
|
100
102
|
(0, sort_fields_1.sortPackageJsonFields)(host, options.projectRoot);
|
|
101
103
|
if (!options.skipFormat) {
|
|
@@ -158,6 +158,10 @@
|
|
|
158
158
|
"default": false,
|
|
159
159
|
"description": "Do not add dependencies to `package.json`.",
|
|
160
160
|
"x-priority": "internal"
|
|
161
|
+
},
|
|
162
|
+
"useProjectJson": {
|
|
163
|
+
"type": "boolean",
|
|
164
|
+
"description": "Use a `project.json` configuration file instead of inlining the Nx configuration in the `package.json` file."
|
|
161
165
|
}
|
|
162
166
|
},
|
|
163
167
|
"required": ["directory"],
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const { join } = require('path');
|
|
2
|
+
|
|
3
|
+
// Note: If you use library-specific PostCSS/Tailwind configuration then you should remove the `postcssConfig` build
|
|
4
|
+
// option from your application's configuration (i.e. project.json).
|
|
5
|
+
//
|
|
6
|
+
// See: https://nx.dev/guides/using-tailwind-css-in-react#step-4:-applying-configuration-to-libraries
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
plugins: {
|
|
10
|
+
tailwindcss: {
|
|
11
|
+
config: join(__dirname, 'tailwind.config.js'),
|
|
12
|
+
},
|
|
13
|
+
autoprefixer: {},
|
|
14
|
+
},
|
|
15
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// const { createGlobPatternsForDependencies } = require('@nx/next/tailwind');
|
|
2
|
+
|
|
3
|
+
// The above utility import will not work if you are using Next.js' --turbo.
|
|
4
|
+
// Instead you will have to manually add the dependent paths to be included.
|
|
5
|
+
// For example
|
|
6
|
+
// ../libs/buttons/**/*.{ts,tsx,js,jsx,html}', <--- Adding a shared lib
|
|
7
|
+
// !../libs/buttons/**/*.{stories,spec}.{ts,tsx,js,jsx,html}', <--- Skip adding spec/stories files from shared lib
|
|
8
|
+
|
|
9
|
+
// If you are **not** using `--turbo` you can uncomment both lines 1 & 19.
|
|
10
|
+
// A discussion of the issue can be found: https://github.com/nrwl/nx/issues/26510
|
|
11
|
+
|
|
12
|
+
/** @type {import('tailwindcss').Config} */
|
|
13
|
+
module.exports = {
|
|
14
|
+
content: [
|
|
15
|
+
'./{src,pages,components,app}/**/*.{ts,tsx,js,jsx,html}',
|
|
16
|
+
'!./{src,pages,components,app}/**/*.{stories,spec}.{ts,tsx,js,jsx,html}',
|
|
17
|
+
// ...createGlobPatternsForDependencies(__dirname)
|
|
18
|
+
],
|
|
19
|
+
theme: {
|
|
20
|
+
extend: {},
|
|
21
|
+
},
|
|
22
|
+
plugins: [],
|
|
23
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addTailwindStyleImports = addTailwindStyleImports;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
// base directories and file types to simplify locating the stylesheet
|
|
6
|
+
const baseDirs = ['src', 'pages', 'src/pages', 'src/app', 'app'];
|
|
7
|
+
const fileNames = ['styles', 'global'];
|
|
8
|
+
const extensions = ['.css', '.scss', '.less'];
|
|
9
|
+
const knownLocations = baseDirs.flatMap((dir) => fileNames.flatMap((name) => extensions.map((ext) => `${dir}/${name}${ext}`)));
|
|
10
|
+
function addTailwindStyleImports(tree, project, _options) {
|
|
11
|
+
const candidates = knownLocations.map((currentPath) => (0, devkit_1.joinPathFragments)(project.root, currentPath));
|
|
12
|
+
const stylesPath = candidates.find((currentStylePath) => tree.exists(currentStylePath));
|
|
13
|
+
if (stylesPath) {
|
|
14
|
+
const content = tree.read(stylesPath).toString();
|
|
15
|
+
tree.write(stylesPath, `@tailwind base;\n@tailwind components;\n@tailwind utilities;\n${content}`);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
devkit_1.logger.warn((0, devkit_1.stripIndents) `
|
|
19
|
+
Could not find stylesheet to update. Add the following imports to your stylesheet (e.g. styles.css):
|
|
20
|
+
|
|
21
|
+
@tailwind base;
|
|
22
|
+
@tailwind components;
|
|
23
|
+
@tailwind utilities;
|
|
24
|
+
|
|
25
|
+
See our guide for more details: https://nx.dev/guides/using-tailwind-css-in-react`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateProject = updateProject;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
function updateProject(tree, config, options) {
|
|
6
|
+
if (config?.targets?.build?.executor === '@nx/webpack:webpack') {
|
|
7
|
+
config.targets.build.options ??= {};
|
|
8
|
+
config.targets.build.options.postcssConfig = (0, devkit_1.joinPathFragments)(config.root, 'postcss.config.js');
|
|
9
|
+
(0, devkit_1.updateProjectConfiguration)(tree, options.project, config);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"cli": "nx",
|
|
4
|
+
"$id": "NxNextTailwindSetupGenerator",
|
|
5
|
+
"title": "Configures Tailwind CSS for an application or a buildable/publishable library.",
|
|
6
|
+
"description": "Adds the Tailwind CSS configuration files for a Next.js project and installs, if needed, the packages required for Tailwind CSS to work.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"examples": [
|
|
9
|
+
{
|
|
10
|
+
"command": "nx g setup-tailwind --project=my-app",
|
|
11
|
+
"description": "Initialize Tailwind configuration for the `my-app` project."
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"properties": {
|
|
15
|
+
"project": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"description": "The name of the project to add the Tailwind CSS setup for.",
|
|
18
|
+
"alias": "p",
|
|
19
|
+
"$default": {
|
|
20
|
+
"$source": "argv",
|
|
21
|
+
"index": 0
|
|
22
|
+
},
|
|
23
|
+
"x-dropdown": "projects",
|
|
24
|
+
"x-prompt": "What project would you like to add the Tailwind CSS setup?",
|
|
25
|
+
"x-priority": "important"
|
|
26
|
+
},
|
|
27
|
+
"buildTarget": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"description": "The name of the target used to build the project. This option is not needed in most cases.",
|
|
30
|
+
"default": "build",
|
|
31
|
+
"x-priority": "important"
|
|
32
|
+
},
|
|
33
|
+
"skipFormat": {
|
|
34
|
+
"type": "boolean",
|
|
35
|
+
"description": "Skips formatting the workspace after the generator completes.",
|
|
36
|
+
"x-priority": "internal"
|
|
37
|
+
},
|
|
38
|
+
"skipPackageJson": {
|
|
39
|
+
"type": "boolean",
|
|
40
|
+
"default": false,
|
|
41
|
+
"description": "Do not add dependencies to `package.json`.",
|
|
42
|
+
"x-priority": "internal"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"additionalProperties": false,
|
|
46
|
+
"required": ["project"]
|
|
47
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
|
+
import type { SetupTailwindOptions } from './schema';
|
|
3
|
+
export declare function setupTailwindGenerator(tree: Tree, options: SetupTailwindOptions): Promise<GeneratorCallback>;
|
|
4
|
+
export default setupTailwindGenerator;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupTailwindGenerator = setupTailwindGenerator;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const versions_1 = require("@nx/react/src/utils/versions");
|
|
6
|
+
const add_tailwind_style_imports_1 = require("./lib/add-tailwind-style-imports");
|
|
7
|
+
const update_project_1 = require("./lib/update-project");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
async function setupTailwindGenerator(tree, options) {
|
|
10
|
+
const tasks = [];
|
|
11
|
+
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
12
|
+
if (tree.exists((0, devkit_1.joinPathFragments)(project.root, 'postcss.config.js')) ||
|
|
13
|
+
tree.exists((0, devkit_1.joinPathFragments)(project.root, 'tailwind.config.js'))) {
|
|
14
|
+
devkit_1.logger.info(`Skipping setup since there are existing PostCSS or Tailwind configuration files. For manual setup instructions, see https://nx.dev/guides/using-tailwind-css-in-react.`);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files'), project.root, {
|
|
18
|
+
tmpl: '',
|
|
19
|
+
});
|
|
20
|
+
(0, add_tailwind_style_imports_1.addTailwindStyleImports)(tree, project, options);
|
|
21
|
+
(0, update_project_1.updateProject)(tree, project, options);
|
|
22
|
+
if (!options.skipPackageJson) {
|
|
23
|
+
tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
24
|
+
autoprefixer: versions_1.autoprefixerVersion,
|
|
25
|
+
postcss: versions_1.postcssVersion,
|
|
26
|
+
tailwindcss: versions_1.tailwindcssVersion,
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
if (!options.skipFormat) {
|
|
30
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
31
|
+
}
|
|
32
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
33
|
+
}
|
|
34
|
+
exports.default = setupTailwindGenerator;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
|
-
export declare function configureForSwc(tree: Tree, projectRoot: string): () => void;
|
|
2
|
+
export declare function configureForSwc(tree: Tree, projectRoot: string, swcConfigName?: string, additonalExludes?: string[]): () => void;
|
|
@@ -4,28 +4,24 @@ exports.configureForSwc = configureForSwc;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const versions_1 = require("@nx/js/src/utils/versions");
|
|
6
6
|
const add_swc_config_1 = require("@nx/js/src/utils/swc/add-swc-config");
|
|
7
|
-
function configureForSwc(tree, projectRoot) {
|
|
8
|
-
const swcConfigPath = (0, devkit_1.joinPathFragments)(projectRoot,
|
|
7
|
+
function configureForSwc(tree, projectRoot, swcConfigName = '.swcrc', additonalExludes = []) {
|
|
8
|
+
const swcConfigPath = (0, devkit_1.joinPathFragments)(projectRoot, swcConfigName);
|
|
9
9
|
const rootPackageJson = (0, devkit_1.readJson)(tree, 'package.json');
|
|
10
10
|
const hasSwcDepedency = rootPackageJson.dependencies?.['@swc/core'] ||
|
|
11
11
|
rootPackageJson.devDependencies?.['@swc/core'];
|
|
12
12
|
const hasSwcCliDependency = rootPackageJson.dependencies?.['@swc/cli'] ||
|
|
13
13
|
rootPackageJson.devDependencies?.['@swc/cli'];
|
|
14
14
|
if (!tree.exists(swcConfigPath)) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
...json,
|
|
21
|
-
exclude: [...json.exclude, '.*.d.ts$'],
|
|
22
|
-
};
|
|
23
|
-
});
|
|
15
|
+
// We need to create a swc config file specific for custom server
|
|
16
|
+
(0, add_swc_config_1.addSwcConfig)(tree, projectRoot, 'commonjs', false, swcConfigName, [
|
|
17
|
+
...additonalExludes,
|
|
18
|
+
'.*.d.ts$',
|
|
19
|
+
]);
|
|
24
20
|
}
|
|
25
21
|
if (!hasSwcDepedency || !hasSwcCliDependency) {
|
|
26
22
|
addSwcDependencies(tree);
|
|
27
|
-
return () => (0, devkit_1.installPackagesTask)(tree);
|
|
28
23
|
}
|
|
24
|
+
return () => (0, devkit_1.installPackagesTask)(tree);
|
|
29
25
|
}
|
|
30
26
|
function addSwcDependencies(tree) {
|
|
31
27
|
return (0, devkit_1.addDependenciesToPackageJson)(tree, {
|
package/src/utils/versions.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const nxVersion: any;
|
|
2
|
-
export declare const nextVersion = "~15.
|
|
3
|
-
export declare const next14Version = "~14.2.
|
|
4
|
-
export declare const eslintConfigNextVersion = "
|
|
2
|
+
export declare const nextVersion = "~15.2.4";
|
|
3
|
+
export declare const next14Version = "~14.2.26";
|
|
4
|
+
export declare const eslintConfigNextVersion = "^15.2.4";
|
|
5
5
|
export declare const sassVersion = "1.62.1";
|
|
6
6
|
export declare const lessLoader = "11.1.0";
|
|
7
7
|
export declare const emotionServerVersion = "11.11.0";
|
package/src/utils/versions.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.tsLibVersion = exports.babelPluginStyledComponentsVersion = exports.emotionServerVersion = exports.lessLoader = exports.sassVersion = exports.eslintConfigNextVersion = exports.next14Version = exports.nextVersion = exports.nxVersion = void 0;
|
|
4
4
|
exports.nxVersion = require('../../package.json').version;
|
|
5
|
-
exports.nextVersion = '~15.
|
|
6
|
-
exports.next14Version = '~14.2.
|
|
7
|
-
exports.eslintConfigNextVersion = '
|
|
5
|
+
exports.nextVersion = '~15.2.4';
|
|
6
|
+
exports.next14Version = '~14.2.26';
|
|
7
|
+
exports.eslintConfigNextVersion = '^15.2.4';
|
|
8
8
|
exports.sassVersion = '1.62.1';
|
|
9
9
|
exports.lessLoader = '11.1.0';
|
|
10
10
|
exports.emotionServerVersion = '11.11.0';
|
package/tailwind.d.ts
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Generates a set of glob patterns based off the source root of the app and its dependencies
|
|
3
|
+
* @param dirPath workspace relative directory path that will be used to infer the parent project and dependencies
|
|
4
|
+
* @param fileGlobPatternToInclude pass a custom glob pattern to be used
|
|
5
|
+
* @param fileGlobPatternToExclude pass a custom glob pattern for files to be excluded
|
|
6
|
+
*/
|
|
7
|
+
export declare function createGlobPatternsForDependencies(dirPath: string, fileGlobPatternToInclude?: string, fileGlobPatternToExclude?: string): any;
|
package/tailwind.js
CHANGED
|
@@ -1,6 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createGlobPatternsForDependencies =
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
3
|
+
exports.createGlobPatternsForDependencies = createGlobPatternsForDependencies;
|
|
4
|
+
const generate_globs_1 = require("@nx/js/src/utils/generate-globs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
/**
|
|
7
|
+
* Generates a set of glob patterns based off the source root of the app and its dependencies
|
|
8
|
+
* @param dirPath workspace relative directory path that will be used to infer the parent project and dependencies
|
|
9
|
+
* @param fileGlobPatternToInclude pass a custom glob pattern to be used
|
|
10
|
+
* @param fileGlobPatternToExclude pass a custom glob pattern for files to be excluded
|
|
11
|
+
*/
|
|
12
|
+
function createGlobPatternsForDependencies(dirPath, fileGlobPatternToInclude = '/**/*.{tsx,ts,jsx,js,html}', fileGlobPatternToExclude = '/**/*.{stories,spec}.{tsx,ts,jsx,js,html}') {
|
|
13
|
+
/**
|
|
14
|
+
* There is an issue with TailwindCSS v4 and how globs patterns are consumed.
|
|
15
|
+
* This is a temporary workaround to support both TailwindCSS v4 and v3.
|
|
16
|
+
* Once TailwindCSS v3 is no longer supported, this workaround can be removed.
|
|
17
|
+
*/
|
|
18
|
+
const tailwindVersion = require(require.resolve('tailwindcss/package.json', {
|
|
19
|
+
paths: [dirPath],
|
|
20
|
+
})).version;
|
|
21
|
+
if (tailwindVersion && typeof tailwindVersion === 'string') {
|
|
22
|
+
const majorVersion = parseInt(tailwindVersion.split('.')[0], 10);
|
|
23
|
+
if (majorVersion >= 4) {
|
|
24
|
+
try {
|
|
25
|
+
return [
|
|
26
|
+
...(0, generate_globs_1.createGlobPatternsForDependencies)(dirPath, fileGlobPatternToInclude).map((glob) => (0, path_1.relative)(dirPath, glob)),
|
|
27
|
+
...(0, generate_globs_1.createGlobPatternsForDependencies)(dirPath, fileGlobPatternToExclude).map((glob) => `!${(0, path_1.relative)(dirPath, glob)}`),
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
console.warn('\nWARNING: There was an error creating glob patterns, returning an empty array\n' +
|
|
32
|
+
`${e.message}\n`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
const { createGlobPatternsForDependencies: reactGlobPatternFunction, } = require('@nx/react/tailwind');
|
|
37
|
+
return reactGlobPatternFunction(dirPath, fileGlobPatternToInclude);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return [];
|
|
41
|
+
}
|