@nx/next 0.0.0-pr-30418-4e2b721 → 0.0.0-pr-3-ec41644

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.
Files changed (26) hide show
  1. package/package.json +7 -7
  2. package/src/generators/application/application.js +9 -11
  3. package/src/generators/application/lib/add-e2e.js +27 -28
  4. package/src/generators/application/lib/add-project.js +19 -21
  5. package/src/generators/application/lib/create-application-files.js +1 -1
  6. package/src/generators/application/lib/normalize-options.d.ts +1 -4
  7. package/src/generators/application/lib/normalize-options.js +5 -10
  8. package/src/generators/application/schema.d.ts +0 -1
  9. package/src/generators/application/schema.json +0 -4
  10. package/src/generators/library/lib/normalize-options.js +2 -4
  11. package/src/generators/library/library.js +1 -3
  12. package/src/generators/library/schema.d.ts +0 -1
  13. package/src/generators/library/schema.json +0 -4
  14. package/tailwind.d.ts +2 -7
  15. package/tailwind.js +4 -39
  16. package/src/generators/setup-tailwind/files/postcss.config.js__tmpl__ +0 -15
  17. package/src/generators/setup-tailwind/files/tailwind.config.js__tmpl__ +0 -23
  18. package/src/generators/setup-tailwind/lib/add-tailwind-style-imports.d.ts +0 -3
  19. package/src/generators/setup-tailwind/lib/add-tailwind-style-imports.js +0 -27
  20. package/src/generators/setup-tailwind/lib/update-project.d.ts +0 -3
  21. package/src/generators/setup-tailwind/lib/update-project.js +0 -11
  22. package/src/generators/setup-tailwind/schema.d.ts +0 -6
  23. package/src/generators/setup-tailwind/schema.js +0 -2
  24. package/src/generators/setup-tailwind/schema.json +0 -47
  25. package/src/generators/setup-tailwind/setup-tailwind.d.ts +0 -4
  26. package/src/generators/setup-tailwind/setup-tailwind.js +0 -34
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/next",
3
- "version": "0.0.0-pr-30418-4e2b721",
3
+ "version": "0.0.0-pr-3-ec41644",
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": "0.0.0-pr-30418-4e2b721",
38
+ "@nx/devkit": "0.0.0-pr-3-ec41644",
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": "0.0.0-pr-30418-4e2b721",
48
- "@nx/eslint": "0.0.0-pr-30418-4e2b721",
49
- "@nx/react": "0.0.0-pr-30418-4e2b721",
50
- "@nx/web": "0.0.0-pr-30418-4e2b721",
51
- "@nx/webpack": "0.0.0-pr-30418-4e2b721",
47
+ "@nx/js": "0.0.0-pr-3-ec41644",
48
+ "@nx/eslint": "0.0.0-pr-3-ec41644",
49
+ "@nx/react": "0.0.0-pr-3-ec41644",
50
+ "@nx/web": "0.0.0-pr-3-ec41644",
51
+ "@nx/webpack": "0.0.0-pr-3-ec41644",
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 setup_tailwind_1 = require("../setup-tailwind/setup-tailwind");
7
+ const react_1 = require("@nx/react");
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");
@@ -28,7 +28,6 @@ const add_swc_to_custom_server_1 = require("../../utils/add-swc-to-custom-server
28
28
  async function applicationGenerator(host, schema) {
29
29
  return await applicationGeneratorInternal(host, {
30
30
  addPlugin: false,
31
- useProjectJson: true,
32
31
  ...schema,
33
32
  });
34
33
  }
@@ -40,8 +39,8 @@ async function applicationGeneratorInternal(host, schema) {
40
39
  js: options.js,
41
40
  skipPackageJson: options.skipPackageJson,
42
41
  skipFormat: true,
43
- addTsPlugin: options.isTsSolutionSetup,
44
- formatter: options.formatter,
42
+ addTsPlugin: schema.useTsSolution,
43
+ formatter: schema.formatter,
45
44
  platform: 'web',
46
45
  });
47
46
  tasks.push(jsInitTask);
@@ -52,11 +51,6 @@ async function applicationGeneratorInternal(host, schema) {
52
51
  tasks.push(nextTask);
53
52
  (0, create_application_files_1.createApplicationFiles)(host, options);
54
53
  (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
- }
60
54
  const e2eTask = await (0, add_e2e_1.addE2e)(host, options);
61
55
  tasks.push(e2eTask);
62
56
  const jestTask = await (0, add_jest_1.addJest)(host, options);
@@ -64,7 +58,7 @@ async function applicationGeneratorInternal(host, schema) {
64
58
  const lintTask = await (0, add_linting_1.addLinting)(host, options);
65
59
  tasks.push(lintTask);
66
60
  if (options.style === 'tailwind') {
67
- const tailwindTask = await (0, setup_tailwind_1.setupTailwindGenerator)(host, {
61
+ const tailwindTask = await (0, react_1.setupTailwindGenerator)(host, {
68
62
  project: options.projectName,
69
63
  });
70
64
  tasks.push(tailwindTask);
@@ -95,7 +89,6 @@ async function applicationGeneratorInternal(host, schema) {
95
89
  };
96
90
  if (options.unitTestRunner && options.unitTestRunner !== 'none') {
97
91
  devDependencies['@testing-library/react'] = versions_1.testingLibraryReactVersion;
98
- devDependencies['@testing-library/dom'] = versions_1.testingLibraryDomVersion;
99
92
  }
100
93
  tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, { tslib: versions_2.tsLibVersion }, devDependencies));
101
94
  }
@@ -106,6 +99,11 @@ async function applicationGeneratorInternal(host, schema) {
106
99
  }, options.linter === 'eslint'
107
100
  ? ['.next', 'eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
108
101
  : ['.next'], options.src ? 'src' : '.');
102
+ // If we are using the new TS solution
103
+ // We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
104
+ if (options.useTsSolution) {
105
+ (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.appProjectRoot);
106
+ }
109
107
  (0, sort_fields_1.sortPackageJsonFields)(host, options.appProjectRoot);
110
108
  if (!options.skipFormat) {
111
109
  await (0, devkit_1.formatFiles)(host);
@@ -2,12 +2,13 @@
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");
8
5
  const eslint_1 = require("@nx/eslint");
9
- const web_1 = require("@nx/web");
10
6
  const versions_1 = require("../../../utils/versions");
7
+ const web_1 = require("@nx/web");
8
+ const find_plugin_for_config_file_1 = require("@nx/devkit/src/utils/find-plugin-for-config-file");
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");
11
12
  async function addE2e(host, options) {
12
13
  const nxJson = (0, devkit_1.readNxJson)(host);
13
14
  const hasPlugin = nxJson.plugins?.some((p) => typeof p === 'string'
@@ -24,15 +25,17 @@ async function addE2e(host, options) {
24
25
  spa: true,
25
26
  });
26
27
  }
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
- };
28
+ if ((0, ts_solution_setup_1.isUsingTsSolutionSetup)(host)) {
29
+ (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), {
30
+ name: options.e2eProjectName,
31
+ version: '0.0.1',
32
+ private: true,
33
+ nx: {
34
+ projectType: 'application',
35
+ sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
36
+ implicitDependencies: [options.projectName],
37
+ },
38
+ });
36
39
  }
37
40
  else {
38
41
  (0, devkit_1.addProjectConfiguration)(host, options.e2eProjectName, {
@@ -44,9 +47,6 @@ async function addE2e(host, options) {
44
47
  implicitDependencies: [options.projectName],
45
48
  });
46
49
  }
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,15 +81,17 @@ 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
- 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
- };
84
+ if ((0, ts_solution_setup_1.isUsingTsSolutionSetup)(host)) {
85
+ (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), {
86
+ name: options.e2eProjectName,
87
+ version: '0.0.1',
88
+ private: true,
89
+ nx: {
90
+ projectType: 'application',
91
+ sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
92
+ implicitDependencies: [options.projectName],
93
+ },
94
+ });
93
95
  }
94
96
  else {
95
97
  (0, devkit_1.addProjectConfiguration)(host, options.e2eProjectName, {
@@ -101,9 +103,6 @@ async function addE2e(host, options) {
101
103
  implicitDependencies: [options.projectName],
102
104
  });
103
105
  }
104
- if (!options.useProjectJson || options.isTsSolutionSetup) {
105
- (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), packageJson);
106
- }
107
106
  const e2eTask = await configurationGenerator(host, {
108
107
  rootProject: options.rootProject,
109
108
  project: options.e2eProjectName,
@@ -3,6 +3,8 @@ 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");
6
8
  const versions_1 = require("../../../utils/versions");
7
9
  const react_1 = require("@nx/react");
8
10
  function addProject(host, options) {
@@ -55,31 +57,27 @@ function addProject(host, options) {
55
57
  targets,
56
58
  tags: options.parsedTags,
57
59
  };
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
- }
60
+ if ((0, ts_solution_setup_1.isUsingTsSolutionSetup)(host)) {
61
+ (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), {
62
+ name: (0, get_import_path_1.getImportPath)(host, options.name),
63
+ version: '0.0.1',
64
+ private: true,
65
+ dependencies: {
66
+ next: versions_1.nextVersion,
67
+ react: react_1.reactVersion,
68
+ 'react-dom': react_1.reactDomVersion,
69
+ },
70
+ nx: {
71
+ name: options.name,
72
+ projectType: 'application',
73
+ sourceRoot: options.appProjectRoot,
74
+ tags: options.parsedTags?.length ? options.parsedTags : undefined,
75
+ },
76
+ });
76
77
  }
77
78
  else {
78
79
  (0, devkit_1.addProjectConfiguration)(host, options.projectName, {
79
80
  ...project,
80
81
  });
81
82
  }
82
- if (!options.useProjectJson || options.isTsSolutionSetup) {
83
- (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), packageJson);
84
- }
85
83
  }
@@ -18,7 +18,7 @@ function createApplicationFiles(host, options) {
18
18
  : 'pages/'
19
19
  : '';
20
20
  const templateVariables = {
21
- ...(0, devkit_1.names)(options.projectSimpleName),
21
+ ...(0, devkit_1.names)(options.name),
22
22
  ...options,
23
23
  dot: '.',
24
24
  tmpl: '',
@@ -1,17 +1,14 @@
1
1
  import { Tree } from '@nx/devkit';
2
2
  import { Schema } from '../schema';
3
- export interface NormalizedSchema extends Omit<Schema, 'name' | 'useTsSolution'> {
3
+ export interface NormalizedSchema extends Schema {
4
4
  projectName: string;
5
- projectSimpleName: string;
6
5
  appProjectRoot: string;
7
- importPath: string;
8
6
  outputPath: string;
9
7
  e2eProjectName: string;
10
8
  e2eProjectRoot: string;
11
9
  parsedTags: string[];
12
10
  fileName: string;
13
11
  styledModule: null | string;
14
- isTsSolutionSetup: boolean;
15
12
  js?: boolean;
16
13
  }
17
14
  export declare function normalizeOptions(host: Tree, options: Schema): Promise<NormalizedSchema>;
@@ -5,10 +5,9 @@ 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");
9
8
  async function normalizeOptions(host, options) {
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, {
9
+ await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
10
+ const { projectName: appProjectName, projectRoot: appProjectRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
12
11
  name: options.name,
13
12
  projectType: 'application',
14
13
  directory: options.directory,
@@ -19,11 +18,10 @@ async function normalizeOptions(host, options) {
19
18
  const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
20
19
  nxJson.useInferencePlugins !== false;
21
20
  options.addPlugin ??= addPlugin;
22
- const isTsSolutionSetup = options.useTsSolution || (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
23
- const appProjectName = !isTsSolutionSetup || options.name ? projectName : importPath;
24
21
  const e2eProjectName = options.rootProject ? 'e2e' : `${appProjectName}-e2e`;
25
22
  const e2eProjectRoot = options.rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
26
- const outputPath = (0, devkit_1.joinPathFragments)('dist', appProjectRoot, ...(options.rootProject ? [projectNames.projectFileName] : []));
23
+ const name = (0, devkit_1.names)(options.name).fileName;
24
+ const outputPath = (0, devkit_1.joinPathFragments)('dist', appProjectRoot, ...(options.rootProject ? [name] : []));
27
25
  const parsedTags = options.tags
28
26
  ? options.tags.split(',').map((s) => s.trim())
29
27
  : [];
@@ -44,15 +42,12 @@ async function normalizeOptions(host, options) {
44
42
  e2eTestRunner: options.e2eTestRunner || 'playwright',
45
43
  fileName,
46
44
  linter: options.linter || eslint_1.Linter.EsLint,
45
+ name,
47
46
  outputPath,
48
47
  parsedTags,
49
48
  projectName: appProjectName,
50
- projectSimpleName: projectNames.projectSimpleName,
51
49
  style: options.style || 'css',
52
50
  styledModule,
53
51
  unitTestRunner: options.unitTestRunner || 'jest',
54
- importPath,
55
- isTsSolutionSetup,
56
- useProjectJson: options.useProjectJson ?? !isTsSolutionSetup,
57
52
  };
58
53
  }
@@ -22,5 +22,4 @@ export interface Schema {
22
22
  addPlugin?: boolean;
23
23
  useTsSolution?: boolean;
24
24
  formatter?: 'prettier' | 'none';
25
- useProjectJson?: boolean;
26
25
  }
@@ -144,10 +144,6 @@
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."
151
147
  }
152
148
  },
153
149
  "required": ["directory"],
@@ -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.ensureRootProjectName)(options, 'library');
8
+ await (0, project_name_and_root_utils_1.ensureProjectName)(host, 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,12 +16,10 @@ 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);
20
19
  return {
21
20
  ...options,
22
21
  importPath,
23
22
  projectRoot,
24
- isUsingTsSolutionConfig,
25
- useProjectJson: options.useProjectJson ?? !isUsingTsSolutionConfig,
23
+ isUsingTsSolutionConfig: (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host),
26
24
  };
27
25
  }
@@ -14,7 +14,6 @@ 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,
18
17
  ...rawOptions,
19
18
  });
20
19
  }
@@ -45,7 +44,6 @@ async function libraryGeneratorInternal(host, rawOptions) {
45
44
  }
46
45
  if (options.unitTestRunner && options.unitTestRunner !== 'none') {
47
46
  devDependencies['@testing-library/react'] = versions_1.testingLibraryReactVersion;
48
- devDependencies['@testing-library/dom'] = versions_1.testingLibraryDomVersion;
49
47
  }
50
48
  tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, { tslib: versions_2.tsLibVersion }, devDependencies));
51
49
  }
@@ -97,7 +95,7 @@ async function libraryGeneratorInternal(host, rawOptions) {
97
95
  ? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
98
96
  : undefined);
99
97
  if (options.isUsingTsSolutionConfig) {
100
- await (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.projectRoot);
98
+ (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.projectRoot);
101
99
  }
102
100
  (0, sort_fields_1.sortPackageJsonFields)(host, options.projectRoot);
103
101
  if (!options.skipFormat) {
@@ -24,5 +24,4 @@ export interface Schema {
24
24
  setParserOptionsProject?: boolean;
25
25
  skipPackageJson?: boolean;
26
26
  addPlugin?: boolean;
27
- useProjectJson?: boolean;
28
27
  }
@@ -158,10 +158,6 @@
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."
165
161
  }
166
162
  },
167
163
  "required": ["directory"],
package/tailwind.d.ts CHANGED
@@ -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;
1
+ import { createGlobPatternsForDependencies } from '@nx/react/tailwind';
2
+ export { createGlobPatternsForDependencies };
package/tailwind.js CHANGED
@@ -1,41 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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
- }
3
+ exports.createGlobPatternsForDependencies = void 0;
4
+ // Re-exporting for convenience and backwards compatibility.
5
+ const tailwind_1 = require("@nx/react/tailwind");
6
+ Object.defineProperty(exports, "createGlobPatternsForDependencies", { enumerable: true, get: function () { return tailwind_1.createGlobPatternsForDependencies; } });
@@ -1,15 +0,0 @@
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
- }
@@ -1,23 +0,0 @@
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
- };
@@ -1,3 +0,0 @@
1
- import { ProjectConfiguration, Tree } from '@nx/devkit';
2
- import { SetupTailwindOptions } from '../schema';
3
- export declare function addTailwindStyleImports(tree: Tree, project: ProjectConfiguration, _options: SetupTailwindOptions): void;
@@ -1,27 +0,0 @@
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
- }
@@ -1,3 +0,0 @@
1
- import type { ProjectConfiguration, Tree } from '@nx/devkit';
2
- import { SetupTailwindOptions } from '../schema';
3
- export declare function updateProject(tree: Tree, config: ProjectConfiguration, options: SetupTailwindOptions): void;
@@ -1,11 +0,0 @@
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
- }
@@ -1,6 +0,0 @@
1
- export interface SetupTailwindOptions {
2
- project: string;
3
- buildTarget?: string;
4
- skipFormat?: boolean;
5
- skipPackageJson?: boolean;
6
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,47 +0,0 @@
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
- }
@@ -1,4 +0,0 @@
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;
@@ -1,34 +0,0 @@
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;