@nx/next 23.0.0-beta.0 → 23.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.
Files changed (62) hide show
  1. package/index.d.ts +0 -1
  2. package/index.d.ts.map +1 -1
  3. package/index.js +1 -3
  4. package/package.json +10 -10
  5. package/plugins/with-nx.d.ts.map +1 -1
  6. package/plugins/with-nx.js +3 -11
  7. package/src/generators/application/application.d.ts.map +1 -1
  8. package/src/generators/application/application.js +0 -15
  9. package/src/generators/application/files/app/page.tsx__tmpl__ +4 -16
  10. package/src/generators/application/files/common/__dot__babelrc +2 -19
  11. package/src/generators/application/files/common/index.d.ts__tmpl__ +0 -7
  12. package/src/generators/application/files/common/next.config.js__tmpl__ +0 -56
  13. package/src/generators/application/files/common/tsconfig.json__tmpl__ +0 -1
  14. package/src/generators/application/files/pages/__fileName__.tsx__tmpl__ +4 -13
  15. package/src/generators/application/lib/add-e2e.d.ts.map +1 -1
  16. package/src/generators/application/lib/add-e2e.js +2 -4
  17. package/src/generators/application/lib/create-application-files.d.ts.map +1 -1
  18. package/src/generators/application/lib/create-application-files.js +2 -21
  19. package/src/generators/application/lib/normalize-options.d.ts +0 -1
  20. package/src/generators/application/lib/normalize-options.d.ts.map +1 -1
  21. package/src/generators/application/lib/normalize-options.js +0 -4
  22. package/src/generators/application/schema.json +2 -21
  23. package/src/generators/component/schema.json +2 -21
  24. package/src/generators/library/library.d.ts.map +1 -1
  25. package/src/generators/library/library.js +0 -6
  26. package/src/generators/library/schema.json +2 -21
  27. package/src/generators/page/schema.json +2 -17
  28. package/src/utils/styles.d.ts +0 -62
  29. package/src/utils/styles.d.ts.map +1 -1
  30. package/src/utils/styles.js +4 -50
  31. package/src/utils/versions.d.ts +1 -4
  32. package/src/utils/versions.d.ts.map +1 -1
  33. package/src/utils/versions.js +2 -5
  34. package/tailwind.d.ts +3 -5
  35. package/tailwind.d.ts.map +1 -1
  36. package/tailwind.js +36 -11
  37. package/src/generators/application/files/app-styled-components/layout.tsx__tmpl__ +0 -21
  38. package/src/generators/application/files/app-styled-components/registry.tsx__tmpl__ +0 -33
  39. package/src/generators/application/files/app-styled-jsx/layout.tsx__tmpl__ +0 -16
  40. package/src/generators/application/files/app-styled-jsx/registry.tsx__tmpl__ +0 -23
  41. package/src/generators/application/files/pages/_document.tsx__tmpl__ +0 -33
  42. package/src/generators/application/lib/show-possible-warnings.d.ts +0 -4
  43. package/src/generators/application/lib/show-possible-warnings.d.ts.map +0 -1
  44. package/src/generators/application/lib/show-possible-warnings.js +0 -9
  45. package/src/generators/setup-tailwind/files/postcss.config.js__tmpl__ +0 -15
  46. package/src/generators/setup-tailwind/files/tailwind.config.js__tmpl__ +0 -23
  47. package/src/generators/setup-tailwind/lib/add-tailwind-style-imports.d.ts +0 -4
  48. package/src/generators/setup-tailwind/lib/add-tailwind-style-imports.d.ts.map +0 -1
  49. package/src/generators/setup-tailwind/lib/add-tailwind-style-imports.js +0 -27
  50. package/src/generators/setup-tailwind/lib/update-project.d.ts +0 -4
  51. package/src/generators/setup-tailwind/lib/update-project.d.ts.map +0 -1
  52. package/src/generators/setup-tailwind/lib/update-project.js +0 -11
  53. package/src/generators/setup-tailwind/schema.d.ts +0 -7
  54. package/src/generators/setup-tailwind/schema.d.ts.map +0 -1
  55. package/src/generators/setup-tailwind/schema.js +0 -2
  56. package/src/generators/setup-tailwind/schema.json +0 -47
  57. package/src/generators/setup-tailwind/setup-tailwind.d.ts +0 -5
  58. package/src/generators/setup-tailwind/setup-tailwind.d.ts.map +0 -1
  59. package/src/generators/setup-tailwind/setup-tailwind.js +0 -35
  60. package/src/utils/generate-globs.d.ts +0 -6
  61. package/src/utils/generate-globs.d.ts.map +0 -1
  62. package/src/utils/generate-globs.js +0 -28
@@ -1,66 +1,4 @@
1
1
  import { GeneratorCallback, Tree } from '@nx/devkit';
2
- export declare const nextSpecificStyleDependenciesBabel: {
3
- 'styled-components': {
4
- dependencies: import("packages/react/src/utils/dependencies").DependencyEntries;
5
- devDependencies: {
6
- 'babel-plugin-styled-components': string;
7
- };
8
- };
9
- '@emotion/styled': {
10
- dependencies: {
11
- '@emotion/server': string;
12
- };
13
- devDependencies: import("packages/react/src/utils/dependencies").DependencyEntries;
14
- };
15
- css: {
16
- dependencies: {};
17
- devDependencies: {};
18
- };
19
- scss: {
20
- dependencies: {};
21
- devDependencies: {
22
- sass: string;
23
- };
24
- };
25
- less: {
26
- dependencies: {};
27
- devDependencies: {
28
- less: string;
29
- 'less-loader': string;
30
- };
31
- };
32
- };
33
- export declare const nextSpecificStyleDependenciesSwc: {
34
- 'styled-components': {
35
- dependencies: import("packages/react/src/utils/dependencies").DependencyEntries;
36
- devDependencies: {
37
- 'babel-plugin-styled-components': string;
38
- };
39
- };
40
- '@emotion/styled': {
41
- dependencies: {
42
- '@emotion/server': string;
43
- };
44
- devDependencies: import("packages/react/src/utils/dependencies").DependencyEntries;
45
- };
46
- css: {
47
- dependencies: {};
48
- devDependencies: {};
49
- };
50
- scss: {
51
- dependencies: {};
52
- devDependencies: {
53
- sass: string;
54
- };
55
- };
56
- less: {
57
- dependencies: {};
58
- devDependencies: {
59
- less: string;
60
- 'less-loader': string;
61
- };
62
- };
63
- };
64
2
  export declare function addStyleDependencies(host: Tree, options: {
65
3
  style?: string;
66
4
  swc?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../packages/next/src/utils/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EACjB,IAAI,EACL,MAAM,YAAY,CAAC;AAgCpB,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiB9C,CAAC;AAEF,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgB5C,CAAC;AAEF,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,OAAO,CAAA;CAAE,GACzC,iBAAiB,CAYnB"}
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../packages/next/src/utils/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EACjB,IAAI,EACL,MAAM,YAAY,CAAC;AAepB,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,OAAO,CAAA;CAAE,GACzC,iBAAiB,CAUnB"}
@@ -1,66 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.nextSpecificStyleDependenciesSwc = exports.nextSpecificStyleDependenciesBabel = void 0;
4
3
  exports.addStyleDependencies = addStyleDependencies;
5
4
  const devkit_1 = require("@nx/devkit");
6
- const versions_1 = require("@nx/react/src/utils/versions");
7
- const styled_1 = require("@nx/react/src/utils/styled");
8
- const versions_2 = require("./versions");
9
- const nextSpecificStyleDependenciesCommon = {
5
+ const versions_1 = require("./versions");
6
+ const nextSpecificStyleDependencies = {
10
7
  css: {
11
8
  dependencies: {},
12
9
  devDependencies: {},
13
10
  },
14
11
  scss: {
15
12
  dependencies: {},
16
- devDependencies: { sass: versions_2.sassVersion },
17
- },
18
- less: {
19
- dependencies: {},
20
- devDependencies: {
21
- less: versions_1.lessVersion,
22
- 'less-loader': versions_2.lessLoader,
23
- },
24
- },
25
- };
26
- exports.nextSpecificStyleDependenciesBabel = {
27
- ...nextSpecificStyleDependenciesCommon,
28
- 'styled-components': {
29
- dependencies: styled_1.cssInJsDependenciesBabel['styled-components'].dependencies,
30
- devDependencies: {
31
- ...styled_1.cssInJsDependenciesBabel['styled-components'].devDependencies,
32
- 'babel-plugin-styled-components': versions_2.babelPluginStyledComponentsVersion,
33
- },
34
- },
35
- '@emotion/styled': {
36
- dependencies: {
37
- ...styled_1.cssInJsDependenciesBabel['@emotion/styled'].dependencies,
38
- '@emotion/server': versions_2.emotionServerVersion,
39
- },
40
- devDependencies: styled_1.cssInJsDependenciesBabel['@emotion/styled'].devDependencies,
41
- },
42
- };
43
- exports.nextSpecificStyleDependenciesSwc = {
44
- ...nextSpecificStyleDependenciesCommon,
45
- 'styled-components': {
46
- dependencies: styled_1.cssInJsDependenciesSwc['styled-components'].dependencies,
47
- devDependencies: {
48
- ...styled_1.cssInJsDependenciesSwc['styled-components'].devDependencies,
49
- 'babel-plugin-styled-components': versions_2.babelPluginStyledComponentsVersion,
50
- },
51
- },
52
- '@emotion/styled': {
53
- dependencies: {
54
- ...styled_1.cssInJsDependenciesSwc['@emotion/styled'].dependencies,
55
- '@emotion/server': versions_2.emotionServerVersion,
56
- },
57
- devDependencies: styled_1.cssInJsDependenciesSwc['@emotion/styled'].devDependencies,
13
+ devDependencies: { sass: versions_1.sassVersion },
58
14
  },
59
15
  };
60
16
  function addStyleDependencies(host, options) {
61
- const extraDependencies = options.swc
62
- ? exports.nextSpecificStyleDependenciesSwc[options.style]
63
- : exports.nextSpecificStyleDependenciesBabel[options.style];
17
+ const extraDependencies = nextSpecificStyleDependencies[options.style];
64
18
  return extraDependencies
65
19
  ? (0, devkit_1.addDependenciesToPackageJson)(host, extraDependencies.dependencies, extraDependencies.devDependencies)
66
20
  : () => { };
@@ -7,9 +7,6 @@ export declare const eslintConfigNext16Version = "^16.1.6";
7
7
  export declare const eslintConfigNext15Version = "^15.2.4";
8
8
  export declare const eslintConfigNext14Version = "~14.2.26";
9
9
  export declare const eslintConfigNextVersion = "^16.1.6";
10
- export declare const sassVersion = "1.62.1";
11
- export declare const lessLoader = "11.1.0";
12
- export declare const emotionServerVersion = "11.11.0";
13
- export declare const babelPluginStyledComponentsVersion = "1.10.7";
10
+ export declare const sassVersion = "1.97.2";
14
11
  export declare const tsLibVersion = "^2.3.0";
15
12
  //# sourceMappingURL=versions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../../../../../packages/next/src/utils/versions.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,KAAwC,CAAC;AAE/D,eAAO,MAAM,aAAa,YAAY,CAAC;AACvC,eAAO,MAAM,aAAa,YAAY,CAAC;AACvC,eAAO,MAAM,aAAa,aAAa,CAAC;AACxC,eAAO,MAAM,WAAW,YAAgB,CAAC;AACzC,eAAO,MAAM,yBAAyB,YAAY,CAAC;AACnD,eAAO,MAAM,yBAAyB,YAAY,CAAC;AACnD,eAAO,MAAM,yBAAyB,aAAa,CAAC;AACpD,eAAO,MAAM,uBAAuB,YAA4B,CAAC;AACjE,eAAO,MAAM,WAAW,WAAW,CAAC;AACpC,eAAO,MAAM,UAAU,WAAW,CAAC;AACnC,eAAO,MAAM,oBAAoB,YAAY,CAAC;AAC9C,eAAO,MAAM,kCAAkC,WAAW,CAAC;AAC3D,eAAO,MAAM,YAAY,WAAW,CAAC"}
1
+ {"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../../../../../packages/next/src/utils/versions.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,KAAwC,CAAC;AAE/D,eAAO,MAAM,aAAa,YAAY,CAAC;AACvC,eAAO,MAAM,aAAa,YAAY,CAAC;AACvC,eAAO,MAAM,aAAa,aAAa,CAAC;AACxC,eAAO,MAAM,WAAW,YAAgB,CAAC;AACzC,eAAO,MAAM,yBAAyB,YAAY,CAAC;AACnD,eAAO,MAAM,yBAAyB,YAAY,CAAC;AACnD,eAAO,MAAM,yBAAyB,aAAa,CAAC;AACpD,eAAO,MAAM,uBAAuB,YAA4B,CAAC;AACjE,eAAO,MAAM,WAAW,WAAW,CAAC;AACpC,eAAO,MAAM,YAAY,WAAW,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tsLibVersion = exports.babelPluginStyledComponentsVersion = exports.emotionServerVersion = exports.lessLoader = exports.sassVersion = exports.eslintConfigNextVersion = exports.eslintConfigNext14Version = exports.eslintConfigNext15Version = exports.eslintConfigNext16Version = exports.nextVersion = exports.next14Version = exports.next15Version = exports.next16Version = exports.nxVersion = void 0;
3
+ exports.tsLibVersion = exports.sassVersion = exports.eslintConfigNextVersion = exports.eslintConfigNext14Version = exports.eslintConfigNext15Version = exports.eslintConfigNext16Version = exports.nextVersion = exports.next14Version = exports.next15Version = exports.next16Version = exports.nxVersion = void 0;
4
4
  exports.nxVersion = require('../../package.json').version;
5
5
  exports.next16Version = '~16.1.6';
6
6
  exports.next15Version = '~15.2.4';
@@ -10,8 +10,5 @@ exports.eslintConfigNext16Version = '^16.1.6';
10
10
  exports.eslintConfigNext15Version = '^15.2.4';
11
11
  exports.eslintConfigNext14Version = '~14.2.26';
12
12
  exports.eslintConfigNextVersion = exports.eslintConfigNext16Version;
13
- exports.sassVersion = '1.62.1';
14
- exports.lessLoader = '11.1.0';
15
- exports.emotionServerVersion = '11.11.0';
16
- exports.babelPluginStyledComponentsVersion = '1.10.7';
13
+ exports.sassVersion = '1.97.2';
17
14
  exports.tsLibVersion = '^2.3.0';
package/tailwind.d.ts CHANGED
@@ -1,8 +1,6 @@
1
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
2
+ * @deprecated `@nx/next/tailwind` will be removed in Nx 24. Migrate to Tailwind CSS v4 which no longer needs glob patterns.
3
+ * See: https://nx.dev/docs/technologies/react/guides/using-tailwind-css-in-react
6
4
  */
7
- export declare function createGlobPatternsForDependencies(dirPath: string, fileGlobPatternToInclude?: string, fileGlobPatternToExclude?: string): any;
5
+ export declare function createGlobPatternsForDependencies(dirPath: string, fileGlobPatternToInclude?: string, fileGlobPatternToExclude?: string): string[];
8
6
  //# sourceMappingURL=tailwind.d.ts.map
package/tailwind.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"tailwind.d.ts","sourceRoot":"","sources":["../../../packages/next/tailwind.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,wBAAgB,iCAAiC,CAC/C,OAAO,EAAE,MAAM,EACf,wBAAwB,GAAE,MAAqC,EAC/D,wBAAwB,GAAE,MAAoD,OAuC/E"}
1
+ {"version":3,"file":"tailwind.d.ts","sourceRoot":"","sources":["../../../packages/next/tailwind.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,wBAAgB,iCAAiC,CAC/C,OAAO,EAAE,MAAM,EACf,wBAAwB,GAAE,MAAqC,EAC/D,wBAAwB,GAAE,MAAoD,YAmE/E"}
package/tailwind.js CHANGED
@@ -3,18 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createGlobPatternsForDependencies = createGlobPatternsForDependencies;
4
4
  const generate_globs_1 = require("@nx/js/src/utils/generate-globs");
5
5
  const path_1 = require("path");
6
+ let hasWarned = false;
6
7
  /**
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
8
+ * @deprecated `@nx/next/tailwind` will be removed in Nx 24. Migrate to Tailwind CSS v4 which no longer needs glob patterns.
9
+ * See: https://nx.dev/docs/technologies/react/guides/using-tailwind-css-in-react
11
10
  */
12
11
  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
- */
12
+ if (!hasWarned) {
13
+ hasWarned = true;
14
+ console.warn(`\nWARNING: "@nx/next/tailwind" is deprecated and will be removed in Nx 24.\n` +
15
+ `Migrate to Tailwind CSS v4 which no longer needs glob patterns for content detection.\n` +
16
+ `See: https://nx.dev/docs/technologies/react/guides/using-tailwind-css-in-react\n`);
17
+ }
18
18
  const tailwindVersion = require(require.resolve('tailwindcss/package.json', {
19
19
  paths: [dirPath],
20
20
  })).version;
@@ -28,13 +28,38 @@ function createGlobPatternsForDependencies(dirPath, fileGlobPatternToInclude = '
28
28
  ];
29
29
  }
30
30
  catch (e) {
31
+ /**
32
+ * It should not be possible to reach this point when the utility is invoked as part of the normal
33
+ * lifecycle of Nx executors. However, other tooling, such as the VSCode Tailwind IntelliSense plugin
34
+ * or JetBrains editors such as WebStorm, may execute the tailwind.config.js file in order to provide
35
+ * autocomplete features, for example.
36
+ *
37
+ * In order to best support that use-case, we therefore do not hard error when the ProjectGraph is
38
+ * fundamentally unavailable in this tailwind-specific context.
39
+ */
31
40
  console.warn('\nWARNING: There was an error creating glob patterns, returning an empty array\n' +
32
41
  `${e.message}\n`);
42
+ return [];
33
43
  }
34
44
  }
35
45
  else {
36
- const { createGlobPatternsForDependencies: reactGlobPatternFunction, } = require('@nx/react/tailwind');
37
- return reactGlobPatternFunction(dirPath, fileGlobPatternToInclude);
46
+ try {
47
+ return (0, generate_globs_1.createGlobPatternsForDependencies)(dirPath, fileGlobPatternToInclude);
48
+ }
49
+ catch (e) {
50
+ /**
51
+ * It should not be possible to reach this point when the utility is invoked as part of the normal
52
+ * lifecycle of Nx executors. However, other tooling, such as the VSCode Tailwind IntelliSense plugin
53
+ * or JetBrains editors such as WebStorm, may execute the tailwind.config.js file in order to provide
54
+ * autocomplete features, for example.
55
+ *
56
+ * In order to best support that use-case, we therefore do not hard error when the ProjectGraph is
57
+ * fundamentally unavailable in this tailwind-specific context.
58
+ */
59
+ console.warn('\nWARNING: There was an error creating glob patterns, returning an empty array\n' +
60
+ `${e.message}\n`);
61
+ return [];
62
+ }
38
63
  }
39
64
  }
40
65
  return [];
@@ -1,21 +0,0 @@
1
- import './global.<%= stylesExt %>';
2
- import { StyledComponentsRegistry } from './registry';
3
-
4
- export const metadata = {
5
- title: 'Welcome to demo2',
6
- description: 'Generated by create-nx-workspace',
7
- };
8
-
9
- export default function RootLayout({
10
- children,
11
- }: {
12
- children: React.ReactNode;
13
- }) {
14
- return (
15
- <html lang="en">
16
- <body>
17
- <StyledComponentsRegistry>{children}</StyledComponentsRegistry>
18
- </body>
19
- </html>
20
- );
21
- }
@@ -1,33 +0,0 @@
1
- 'use client';
2
-
3
- import React, { useState } from 'react';
4
- import { useServerInsertedHTML } from 'next/navigation';
5
- import { ServerStyleSheet, StyleSheetManager } from 'styled-components';
6
-
7
- export function StyledComponentsRegistry({
8
- children,
9
- }: {
10
- children: React.ReactNode;
11
- }) {
12
- // Only create stylesheet once with lazy initial state
13
- // x-ref: https://reactjs.org/docs/hooks-reference.html#lazy-initial-state
14
- const [styledComponentsStyleSheet] = useState(() => new ServerStyleSheet());
15
-
16
- useServerInsertedHTML(() => {
17
- const styles = styledComponentsStyleSheet.getStyleElement();
18
-
19
- // Types are out of date, clearTag is not defined.
20
- // See: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/65021
21
- (styledComponentsStyleSheet.instance as any).clearTag();
22
-
23
- return <>{styles}</>;
24
- });
25
-
26
- if (typeof window !== 'undefined') return <>{children}</>;
27
-
28
- return (
29
- <StyleSheetManager sheet={styledComponentsStyleSheet.instance}>
30
- {children}
31
- </StyleSheetManager>
32
- );
33
- }
@@ -1,16 +0,0 @@
1
- import './global.<%= stylesExt %>';
2
- import { StyledJsxRegistry } from './registry';
3
-
4
- export default function RootLayout({
5
- children,
6
- }: {
7
- children: React.ReactNode;
8
- }) {
9
- return (
10
- <html>
11
- <body>
12
- <StyledJsxRegistry>{children}</StyledJsxRegistry>
13
- </body>
14
- </html>
15
- );
16
- }
@@ -1,23 +0,0 @@
1
- 'use client';
2
-
3
- import React, { useState } from 'react';
4
- import { useServerInsertedHTML } from 'next/navigation';
5
- import { StyleRegistry, createStyleRegistry } from 'styled-jsx';
6
-
7
- export function StyledJsxRegistry({
8
- children,
9
- }: {
10
- children: React.ReactNode;
11
- }) {
12
- // Only create stylesheet once with lazy initial state
13
- // x-ref: https://reactjs.org/docs/hooks-reference.html#lazy-initial-state
14
- const [jsxStyleRegistry] = useState(() => createStyleRegistry());
15
-
16
- useServerInsertedHTML(() => {
17
- const styles = jsxStyleRegistry.styles();
18
- jsxStyleRegistry.flush();
19
- return <>{styles}</>;
20
- });
21
-
22
- return <StyleRegistry registry={jsxStyleRegistry}>{children}</StyleRegistry>;
23
- }
@@ -1,33 +0,0 @@
1
- /* eslint-disable react/display-name */
2
- import Document, { Html, Head, Main, NextScript, DocumentContext, DocumentInitialProps } from 'next/document';
3
- import { ServerStyleSheet } from 'styled-components';
4
-
5
- export default class CustomDocument extends Document {
6
- static async getInitialProps(ctx: DocumentContext): Promise<DocumentInitialProps> {
7
- const originalRenderPage = ctx.renderPage;
8
-
9
- const sheet = new ServerStyleSheet();
10
-
11
- ctx.renderPage = () => originalRenderPage({
12
- enhanceApp: (App) => (props) => sheet.collectStyles(<App {...props} />),
13
- enhanceComponent: (Component) => Component,
14
- });
15
-
16
- const intialProps = await Document.getInitialProps(ctx);
17
- const styles = sheet.getStyleElement();
18
-
19
- return {...intialProps, styles };
20
- }
21
-
22
- render() {
23
- return (
24
- <Html>
25
- <Head>{this.props.styles}</Head>
26
- <body>
27
- <Main />
28
- <NextScript />
29
- </body>
30
- </Html>
31
- );
32
- }
33
- }
@@ -1,4 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- import { NormalizedSchema } from './normalize-options';
3
- export declare function showPossibleWarnings(tree: Tree, options: NormalizedSchema): void;
4
- //# sourceMappingURL=show-possible-warnings.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"show-possible-warnings.d.ts","sourceRoot":"","sources":["../../../../../../../packages/next/src/generators/application/lib/show-possible-warnings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,IAAI,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,gBAAgB,QAMzE"}
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.showPossibleWarnings = showPossibleWarnings;
4
- const devkit_1 = require("@nx/devkit");
5
- function showPossibleWarnings(tree, options) {
6
- if (options.style === '@emotion/styled' && options.appDir) {
7
- devkit_1.logger.warn(`Emotion may not work with the App Router. See: https://nextjs.org/docs/app/building-your-application/styling/css-in-js`);
8
- }
9
- }
@@ -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,4 +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;
4
- //# sourceMappingURL=add-tailwind-style-imports.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"add-tailwind-style-imports.d.ts","sourceRoot":"","sources":["../../../../../../../packages/next/src/generators/setup-tailwind/lib/add-tailwind-style-imports.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,oBAAoB,EAEpB,IAAI,EACL,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAWjD,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,oBAAoB,EAC7B,QAAQ,EAAE,oBAAoB,QA2B/B"}
@@ -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,4 +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;
4
- //# sourceMappingURL=update-project.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"update-project.d.ts","sourceRoot":"","sources":["../../../../../../../packages/next/src/generators/setup-tailwind/lib/update-project.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAG7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAEjD,wBAAgB,aAAa,CAC3B,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,oBAAoB,QAU9B"}
@@ -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,7 +0,0 @@
1
- export interface SetupTailwindOptions {
2
- project: string;
3
- buildTarget?: string;
4
- skipFormat?: boolean;
5
- skipPackageJson?: boolean;
6
- }
7
- //# sourceMappingURL=schema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../../../packages/next/src/generators/setup-tailwind/schema.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B"}
@@ -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,5 +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;
5
- //# sourceMappingURL=setup-tailwind.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setup-tailwind.d.ts","sourceRoot":"","sources":["../../../../../../packages/next/src/generators/setup-tailwind/setup-tailwind.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAgB1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAKrD,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,oBAAoB,8BA8C9B;AAED,eAAe,sBAAsB,CAAC"}
@@ -1,35 +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
- devkit_1.logger.warn(`The 'setup-tailwind' generator is deprecated. Generating Tailwind configuration is no longer maintained. This generator will be removed in Nx 23.`);
11
- const tasks = [];
12
- const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
13
- if (tree.exists((0, devkit_1.joinPathFragments)(project.root, 'postcss.config.js')) ||
14
- tree.exists((0, devkit_1.joinPathFragments)(project.root, 'tailwind.config.js'))) {
15
- 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.`);
16
- return;
17
- }
18
- (0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files'), project.root, {
19
- tmpl: '',
20
- });
21
- (0, add_tailwind_style_imports_1.addTailwindStyleImports)(tree, project, options);
22
- (0, update_project_1.updateProject)(tree, project, options);
23
- if (!options.skipPackageJson) {
24
- tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
25
- autoprefixer: versions_1.autoprefixerVersion,
26
- postcss: versions_1.postcssVersion,
27
- tailwindcss: versions_1.tailwindcssVersion,
28
- }));
29
- }
30
- if (!options.skipFormat) {
31
- await (0, devkit_1.formatFiles)(tree);
32
- }
33
- return (0, devkit_1.runTasksInSerial)(...tasks);
34
- }
35
- exports.default = setupTailwindGenerator;