@nx/next 0.0.0-pr-22179-271588f

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 (158) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +68 -0
  3. package/babel.d.ts +0 -0
  4. package/babel.js +12 -0
  5. package/executors.json +20 -0
  6. package/generators.json +47 -0
  7. package/index.d.ts +8 -0
  8. package/index.js +19 -0
  9. package/migrations.json +106 -0
  10. package/package.json +60 -0
  11. package/plugin.d.ts +1 -0
  12. package/plugin.js +5 -0
  13. package/plugins/component-testing.d.ts +2 -0
  14. package/plugins/component-testing.js +96 -0
  15. package/plugins/with-less.d.ts +3 -0
  16. package/plugins/with-less.js +79 -0
  17. package/plugins/with-nx.d.ts +25 -0
  18. package/plugins/with-nx.js +297 -0
  19. package/plugins/with-stylus.d.ts +3 -0
  20. package/plugins/with-stylus.js +12 -0
  21. package/src/executors/build/build.impl.d.ts +5 -0
  22. package/src/executors/build/build.impl.js +106 -0
  23. package/src/executors/build/lib/check-project.d.ts +1 -0
  24. package/src/executors/build/lib/check-project.js +12 -0
  25. package/src/executors/build/lib/create-next-config-file.d.ts +14 -0
  26. package/src/executors/build/lib/create-next-config-file.js +162 -0
  27. package/src/executors/build/lib/test-fixtures/ensure-exts/baz.json +1 -0
  28. package/src/executors/build/lib/update-package-json.d.ts +3 -0
  29. package/src/executors/build/lib/update-package-json.js +30 -0
  30. package/src/executors/build/schema.json +76 -0
  31. package/src/executors/export/export.impl.d.ts +17 -0
  32. package/src/executors/export/export.impl.js +58 -0
  33. package/src/executors/export/schema.json +30 -0
  34. package/src/executors/server/custom-server.impl.d.ts +6 -0
  35. package/src/executors/server/custom-server.impl.js +36 -0
  36. package/src/executors/server/schema.json +63 -0
  37. package/src/executors/server/server.impl.d.ts +6 -0
  38. package/src/executors/server/server.impl.js +66 -0
  39. package/src/generators/application/application.d.ts +4 -0
  40. package/src/generators/application/application.js +85 -0
  41. package/src/generators/application/files/app/api/hello/route.ts__tmpl__ +4 -0
  42. package/src/generators/application/files/app/global.__stylesExt____tmpl__ +1 -0
  43. package/src/generators/application/files/app/page.module.__style__ +1 -0
  44. package/src/generators/application/files/app/page.tsx__tmpl__ +30 -0
  45. package/src/generators/application/files/app-default-layout/layout.tsx__tmpl__ +18 -0
  46. package/src/generators/application/files/app-styled-components/layout.tsx__tmpl__ +21 -0
  47. package/src/generators/application/files/app-styled-components/registry.tsx__tmpl__ +33 -0
  48. package/src/generators/application/files/app-styled-jsx/layout.tsx__tmpl__ +16 -0
  49. package/src/generators/application/files/app-styled-jsx/registry.tsx__tmpl__ +23 -0
  50. package/src/generators/application/files/common/__dot__babelrc +21 -0
  51. package/src/generators/application/files/common/index.d.ts__tmpl__ +13 -0
  52. package/src/generators/application/files/common/next-env.d.ts__tmpl__ +5 -0
  53. package/src/generators/application/files/common/next.config.js__tmpl__ +82 -0
  54. package/src/generators/application/files/common/public/.gitkeep +0 -0
  55. package/src/generators/application/files/common/public/favicon.ico +0 -0
  56. package/src/generators/application/files/common/specs/__fileName__.spec.tsx__tmpl__ +18 -0
  57. package/src/generators/application/files/common/tsconfig.json__tmpl__ +29 -0
  58. package/src/generators/application/files/pages/__fileName__.module.__style__ +1 -0
  59. package/src/generators/application/files/pages/__fileName__.tsx__tmpl__ +30 -0
  60. package/src/generators/application/files/pages/_app.tsx__tmpl__ +18 -0
  61. package/src/generators/application/files/pages/_document.tsx__tmpl__ +33 -0
  62. package/src/generators/application/files/pages/styles.__stylesExt____tmpl__ +1 -0
  63. package/src/generators/application/lib/add-e2e.d.ts +3 -0
  64. package/src/generators/application/lib/add-e2e.js +72 -0
  65. package/src/generators/application/lib/add-jest.d.ts +3 -0
  66. package/src/generators/application/lib/add-jest.js +38 -0
  67. package/src/generators/application/lib/add-linting.d.ts +3 -0
  68. package/src/generators/application/lib/add-linting.js +62 -0
  69. package/src/generators/application/lib/add-plugin.d.ts +2 -0
  70. package/src/generators/application/lib/add-plugin.js +25 -0
  71. package/src/generators/application/lib/add-project.d.ts +3 -0
  72. package/src/generators/application/lib/add-project.js +66 -0
  73. package/src/generators/application/lib/create-application-files.d.ts +3 -0
  74. package/src/generators/application/lib/create-application-files.helpers.d.ts +2 -0
  75. package/src/generators/application/lib/create-application-files.helpers.js +846 -0
  76. package/src/generators/application/lib/create-application-files.js +114 -0
  77. package/src/generators/application/lib/normalize-options.d.ts +14 -0
  78. package/src/generators/application/lib/normalize-options.js +56 -0
  79. package/src/generators/application/lib/set-defaults.d.ts +3 -0
  80. package/src/generators/application/lib/set-defaults.js +14 -0
  81. package/src/generators/application/lib/show-possible-warnings.d.ts +3 -0
  82. package/src/generators/application/lib/show-possible-warnings.js +10 -0
  83. package/src/generators/application/lib/update-cypress-tsconfig.d.ts +3 -0
  84. package/src/generators/application/lib/update-cypress-tsconfig.js +16 -0
  85. package/src/generators/application/lib/update-jest-config.d.ts +3 -0
  86. package/src/generators/application/lib/update-jest-config.js +15 -0
  87. package/src/generators/application/schema.d.ts +24 -0
  88. package/src/generators/application/schema.json +146 -0
  89. package/src/generators/component/component.d.ts +28 -0
  90. package/src/generators/component/component.js +66 -0
  91. package/src/generators/component/schema.json +125 -0
  92. package/src/generators/custom-server/custom-server.d.ts +3 -0
  93. package/src/generators/custom-server/custom-server.js +104 -0
  94. package/src/generators/custom-server/files/server/main.ts__tmpl__ +46 -0
  95. package/src/generators/custom-server/files/tsconfig.server.json__tmpl__ +17 -0
  96. package/src/generators/custom-server/schema.d.ts +4 -0
  97. package/src/generators/custom-server/schema.json +30 -0
  98. package/src/generators/cypress-component-configuration/cypress-component-configuration.d.ts +5 -0
  99. package/src/generators/cypress-component-configuration/cypress-component-configuration.js +87 -0
  100. package/src/generators/cypress-component-configuration/schema.d.ts +6 -0
  101. package/src/generators/cypress-component-configuration/schema.json +42 -0
  102. package/src/generators/init/init.d.ts +5 -0
  103. package/src/generators/init/init.js +46 -0
  104. package/src/generators/init/lib/add-plugin.d.ts +2 -0
  105. package/src/generators/init/lib/add-plugin.js +26 -0
  106. package/src/generators/init/schema.d.ts +7 -0
  107. package/src/generators/init/schema.json +34 -0
  108. package/src/generators/library/lib/normalize-options.d.ts +7 -0
  109. package/src/generators/library/lib/normalize-options.js +26 -0
  110. package/src/generators/library/library.d.ts +5 -0
  111. package/src/generators/library/library.js +92 -0
  112. package/src/generators/library/schema.d.ts +28 -0
  113. package/src/generators/library/schema.json +156 -0
  114. package/src/generators/page/page.d.ts +5 -0
  115. package/src/generators/page/page.js +96 -0
  116. package/src/generators/page/schema.d.ts +20 -0
  117. package/src/generators/page/schema.json +111 -0
  118. package/src/migrations/update-15-8-8/add-style-packages.d.ts +3 -0
  119. package/src/migrations/update-15-8-8/add-style-packages.js +23 -0
  120. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
  121. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
  122. package/src/migrations/update-16-3-0/remove-root-build-option.d.ts +2 -0
  123. package/src/migrations/update-16-3-0/remove-root-build-option.js +17 -0
  124. package/src/migrations/update-16-4-0/update-nx-next-dependency.d.ts +2 -0
  125. package/src/migrations/update-16-4-0/update-nx-next-dependency.js +17 -0
  126. package/src/migrations/update-17-2-7/remove-eslint-rules-patch.d.ts +2 -0
  127. package/src/migrations/update-17-2-7/remove-eslint-rules-patch.js +15 -0
  128. package/src/plugins/plugin.d.ts +11 -0
  129. package/src/plugins/plugin.js +182 -0
  130. package/src/utils/add-gitignore-entry.d.ts +2 -0
  131. package/src/utils/add-gitignore-entry.js +17 -0
  132. package/src/utils/add-swc-to-custom-server.d.ts +2 -0
  133. package/src/utils/add-swc-to-custom-server.js +37 -0
  134. package/src/utils/compose-plugins.d.ts +3 -0
  135. package/src/utils/compose-plugins.js +22 -0
  136. package/src/utils/config-invalid-function.fixture.d.ts +0 -0
  137. package/src/utils/config-invalid-function.fixture.js +1 -0
  138. package/src/utils/config-not-a-function.fixture.d.ts +0 -0
  139. package/src/utils/config-not-a-function.fixture.js +1 -0
  140. package/src/utils/config.d.ts +13 -0
  141. package/src/utils/config.js +24 -0
  142. package/src/utils/constants.d.ts +1 -0
  143. package/src/utils/constants.js +4 -0
  144. package/src/utils/create-cli-options.d.ts +1 -0
  145. package/src/utils/create-cli-options.js +13 -0
  146. package/src/utils/create-copy-plugin.d.ts +2 -0
  147. package/src/utils/create-copy-plugin.js +64 -0
  148. package/src/utils/generate-globs.d.ts +5 -0
  149. package/src/utils/generate-globs.js +29 -0
  150. package/src/utils/styles.d.ts +67 -0
  151. package/src/utils/styles.js +67 -0
  152. package/src/utils/types.d.ts +57 -0
  153. package/src/utils/types.js +2 -0
  154. package/src/utils/versions.d.ts +12 -0
  155. package/src/utils/versions.js +15 -0
  156. package/tailwind.d.ts +2 -0
  157. package/tailwind.js +6 -0
  158. package/typings/image.d.ts +12 -0
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2017-2023 Narwhal Technologies Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,68 @@
1
+ <p style="text-align: center;">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-dark.svg">
4
+ <img alt="Nx - Smart Monorepos · Fast CI" src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-light.svg" width="100%">
5
+ </picture>
6
+ </p>
7
+
8
+ <div style="text-align: center;">
9
+
10
+ [![CircleCI](https://circleci.com/gh/nrwl/nx.svg?style=svg)](https://circleci.com/gh/nrwl/nx)
11
+ [![License](https://img.shields.io/npm/l/@nx/workspace.svg?style=flat-square)]()
12
+ [![NPM Version](https://badge.fury.io/js/%40nrwl%2Fworkspace.svg)](https://www.npmjs.com/@nx/workspace)
13
+ [![Semantic Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)]()
14
+ [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
15
+ [![Join the chat at https://gitter.im/nrwl-nx/community](https://badges.gitter.im/nrwl-nx/community.svg)](https://gitter.im/nrwl-nx/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
16
+ [![Join us on the Official Nx Discord Server](https://img.shields.io/discord/1143497901675401286?label=discord)](https://go.nx.dev/community)
17
+
18
+ </div>
19
+
20
+
21
+ <hr>
22
+
23
+ # Nx: Smart Monorepos · Fast CI
24
+
25
+ Nx is a build system with built-in tooling and advanced CI capabilities. It helps you maintain and scale monorepos, both locally and on CI.
26
+
27
+ This package is a [Next.js plugin for Nx](https://nx.dev/next/overview).
28
+
29
+ ## Getting Started
30
+
31
+ ### Creating an Nx Workspace
32
+
33
+ **Using `npx`**
34
+
35
+ ```bash
36
+ npx create-nx-workspace
37
+ ```
38
+
39
+ **Using `npm init`**
40
+
41
+ ```bash
42
+ npm init nx-workspace
43
+ ```
44
+
45
+ **Using `yarn create`**
46
+
47
+ ```bash
48
+ yarn create nx-workspace
49
+ ```
50
+
51
+ ### Adding Nx to an Existing Repository
52
+
53
+ Run:
54
+
55
+ ```bash
56
+ npx nx@latest init
57
+ ```
58
+
59
+ ## Documentation & Resources
60
+
61
+ - [Nx.Dev: Documentation, Guides, Tutorials](https://nx.dev)
62
+ - [Intro to Nx](https://nx.dev/getting-started/intro)
63
+ - [Official Nx YouTube Channel](https://www.youtube.com/@NxDevtools)
64
+ - [Blog Posts About Nx](https://blog.nrwl.io/nx/home)
65
+
66
+ <p style="text-align: center;"><a href="https://nx.dev/#learning-materials" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-courses-and-videos.svg"
67
+ width="100%" alt="Nx - Smart Monorepos · Fast CI"></a></p>
68
+
package/babel.d.ts ADDED
File without changes
package/babel.js ADDED
@@ -0,0 +1,12 @@
1
+ /*
2
+ * Babel preset to provide Next.js support for Nx.
3
+ */
4
+ module.exports = function (api, options) {
5
+ api.assertVersion(7);
6
+ return {
7
+ presets: [['next/babel', options]],
8
+ plugins: [
9
+ [require.resolve('@babel/plugin-proposal-decorators'), { legacy: true }],
10
+ ],
11
+ };
12
+ };
package/executors.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "executors": {
3
+ "build": {
4
+ "implementation": "./src/executors/build/build.impl",
5
+ "schema": "./src/executors/build/schema.json",
6
+ "description": "Build a Next.js application."
7
+ },
8
+ "server": {
9
+ "implementation": "./src/executors/server/server.impl",
10
+ "schema": "./src/executors/server/schema.json",
11
+ "description": "Serve a Next.js application."
12
+ },
13
+ "export": {
14
+ "implementation": "./src/executors/export/export.impl",
15
+ "schema": "./src/executors/export/schema.json",
16
+ "description": "Export a Next.js application. The exported application is located at `dist/$outputPath/exported`.",
17
+ "x-deprecated": "Use static exports in next.config.js instead. See: https://nextjs.org/docs/pages/building-your-application/deploying/static-exports."
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "nx/next",
3
+ "version": "0.1",
4
+ "extends": ["@nx/react"],
5
+ "generators": {
6
+ "init": {
7
+ "factory": "./src/generators/init/init#nextInitGeneratorInternal",
8
+ "schema": "./src/generators/init/schema.json",
9
+ "description": "Initialize the `@nrwl/next` plugin.",
10
+ "hidden": true
11
+ },
12
+ "application": {
13
+ "factory": "./src/generators/application/application#applicationGeneratorInternal",
14
+ "schema": "./src/generators/application/schema.json",
15
+ "aliases": ["app"],
16
+ "x-type": "application",
17
+ "description": "Create an application."
18
+ },
19
+ "page": {
20
+ "factory": "./src/generators/page/page#pageGeneratorInternal",
21
+ "schema": "./src/generators/page/schema.json",
22
+ "description": "Create a page."
23
+ },
24
+ "component": {
25
+ "factory": "./src/generators/component/component#componentGeneratorInternal",
26
+ "schema": "./src/generators/component/schema.json",
27
+ "description": "Create a component."
28
+ },
29
+ "library": {
30
+ "factory": "./src/generators/library/library#libraryGeneratorInternal",
31
+ "schema": "./src/generators/library/schema.json",
32
+ "aliases": ["lib"],
33
+ "x-type": "library",
34
+ "description": "Create a library."
35
+ },
36
+ "custom-server": {
37
+ "factory": "./src/generators/custom-server/custom-server#customServerGenerator",
38
+ "schema": "./src/generators/custom-server/schema.json",
39
+ "description": "Set up a custom server."
40
+ },
41
+ "cypress-component-configuration": {
42
+ "factory": "./src/generators/cypress-component-configuration/cypress-component-configuration#cypressComponentConfigurationInternal",
43
+ "schema": "./src/generators/cypress-component-configuration/schema.json",
44
+ "description": "cypress-component-configuration generator"
45
+ }
46
+ }
47
+ }
package/index.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ export * from './src/utils/types';
2
+ export { createGlobPatternsOfDependentProjects } from './src/utils/generate-globs';
3
+ export { applicationGenerator } from './src/generators/application/application';
4
+ export { componentGenerator } from './src/generators/component/component';
5
+ export { libraryGenerator } from './src/generators/library/library';
6
+ export { pageGenerator } from './src/generators/page/page';
7
+ export { withNx } from './plugins/with-nx';
8
+ export { composePlugins } from './src/utils/compose-plugins';
package/index.js ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.composePlugins = exports.withNx = exports.pageGenerator = exports.libraryGenerator = exports.componentGenerator = exports.applicationGenerator = exports.createGlobPatternsOfDependentProjects = void 0;
4
+ const tslib_1 = require("tslib");
5
+ tslib_1.__exportStar(require("./src/utils/types"), exports);
6
+ var generate_globs_1 = require("./src/utils/generate-globs");
7
+ Object.defineProperty(exports, "createGlobPatternsOfDependentProjects", { enumerable: true, get: function () { return generate_globs_1.createGlobPatternsOfDependentProjects; } });
8
+ var application_1 = require("./src/generators/application/application");
9
+ Object.defineProperty(exports, "applicationGenerator", { enumerable: true, get: function () { return application_1.applicationGenerator; } });
10
+ var component_1 = require("./src/generators/component/component");
11
+ Object.defineProperty(exports, "componentGenerator", { enumerable: true, get: function () { return component_1.componentGenerator; } });
12
+ var library_1 = require("./src/generators/library/library");
13
+ Object.defineProperty(exports, "libraryGenerator", { enumerable: true, get: function () { return library_1.libraryGenerator; } });
14
+ var page_1 = require("./src/generators/page/page");
15
+ Object.defineProperty(exports, "pageGenerator", { enumerable: true, get: function () { return page_1.pageGenerator; } });
16
+ var with_nx_1 = require("./plugins/with-nx");
17
+ Object.defineProperty(exports, "withNx", { enumerable: true, get: function () { return with_nx_1.withNx; } });
18
+ var compose_plugins_1 = require("./src/utils/compose-plugins");
19
+ Object.defineProperty(exports, "composePlugins", { enumerable: true, get: function () { return compose_plugins_1.composePlugins; } });
@@ -0,0 +1,106 @@
1
+ {
2
+ "generators": {
3
+ "add-style-packages": {
4
+ "cli": "nx",
5
+ "version": "15.8.8-beta.0",
6
+ "description": "Add less and stylus packages if used.",
7
+ "factory": "./src/migrations/update-15-8-8/add-style-packages"
8
+ },
9
+ "update-16-0-0-add-nx-packages": {
10
+ "cli": "nx",
11
+ "version": "16.0.0-beta.1",
12
+ "description": "Replace @nrwl/next with @nx/next",
13
+ "implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages"
14
+ },
15
+ "update-16-3-0-remove-root-build-option": {
16
+ "cli": "nx",
17
+ "version": "16.3.0-beta.9",
18
+ "description": "Remove root build option from project configurations since it is not needed.",
19
+ "implementation": "./src/migrations/update-16-3-0/remove-root-build-option"
20
+ },
21
+ "update-16-4-0-update-next-dependency": {
22
+ "cli": "nx",
23
+ "version": "16.4.0-beta.3",
24
+ "description": "Update package.json moving @nx/next from dependency to devDependency",
25
+ "implementation": "./src/migrations/update-16-4-0/update-nx-next-dependency"
26
+ },
27
+ "update-17-2-7": {
28
+ "cli": "nx",
29
+ "version": "17.2.7",
30
+ "description": "Remove patched eslint rule for @next/next/no-html-link-for-pages",
31
+ "implementation": "./src/migrations/update-17-2-7/remove-eslint-rules-patch"
32
+ }
33
+ },
34
+ "packageJsonUpdates": {
35
+ "15.0.4": {
36
+ "version": "15.0.4-beta.0",
37
+ "packages": {
38
+ "next": {
39
+ "version": "13.0.0",
40
+ "alwaysAddToPackageJson": false
41
+ },
42
+ "eslint-config-next": {
43
+ "version": "13.0.0",
44
+ "alwaysAddToPackageJson": false
45
+ },
46
+ "less-loader": {
47
+ "version": "11.1.0",
48
+ "alwaysAddToPackageJson": false
49
+ },
50
+ "stylus-loader": {
51
+ "version": "7.1.0",
52
+ "alwaysAddToPackageJson": false
53
+ }
54
+ }
55
+ },
56
+ "15.4.5": {
57
+ "version": "15.4.5-beta.0",
58
+ "packages": {
59
+ "next": {
60
+ "version": "13.1.1",
61
+ "alwaysAddToPackageJson": false
62
+ },
63
+ "eslint-config-next": {
64
+ "version": "13.1.1",
65
+ "alwaysAddToPackageJson": false
66
+ }
67
+ }
68
+ },
69
+ "16.0.0": {
70
+ "version": "16.0.0-beta.0",
71
+ "packages": {
72
+ "next": {
73
+ "version": "13.3.0",
74
+ "alwaysAddToPackageJson": false
75
+ }
76
+ }
77
+ },
78
+ "16.4.0-beta.4": {
79
+ "version": "16.4.0-beta.4",
80
+ "packages": {
81
+ "stylus": {
82
+ "version": "^0.59.0",
83
+ "alwaysAddToPackageJson": false
84
+ }
85
+ }
86
+ },
87
+ "17.3.1-beta.0": {
88
+ "version": "17.3.1-beta.0",
89
+ "packages": {
90
+ "next": {
91
+ "version": "14.0.4",
92
+ "alwaysAddToPackageJson": false
93
+ }
94
+ }
95
+ },
96
+ "18.0.4": {
97
+ "version": "18.0.4-beta.0",
98
+ "packages": {
99
+ "@swc-node/register": {
100
+ "version": "~1.8.0",
101
+ "alwaysAddToPackageJson": false
102
+ }
103
+ }
104
+ }
105
+ }
106
+ }
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@nx/next",
3
+ "version": "0.0.0-pr-22179-271588f",
4
+ "private": false,
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, Cypress, and Jest. No need to configure anything: watch mode, source maps, and typings just work.",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/nrwl/nx.git",
9
+ "directory": "packages/next"
10
+ },
11
+ "keywords": [
12
+ "Monorepo",
13
+ "Node",
14
+ "Next",
15
+ "Jest",
16
+ "Cypress",
17
+ "CLI"
18
+ ],
19
+ "main": "./index.js",
20
+ "typings": "./index.d.ts",
21
+ "author": "Victor Savkin",
22
+ "license": "MIT",
23
+ "bugs": {
24
+ "url": "https://github.com/nrwl/nx/issues"
25
+ },
26
+ "homepage": "https://nx.dev",
27
+ "generators": "./generators.json",
28
+ "executors": "./executors.json",
29
+ "ng-update": {
30
+ "requirements": {},
31
+ "migrations": "./migrations.json"
32
+ },
33
+ "peerDependencies": {
34
+ "next": ">=14.0.0"
35
+ },
36
+ "dependencies": {
37
+ "@nx/devkit": "0.0.0-pr-22179-271588f",
38
+ "@babel/plugin-proposal-decorators": "^7.22.7",
39
+ "@svgr/webpack": "^8.0.1",
40
+ "chalk": "^4.1.0",
41
+ "copy-webpack-plugin": "^10.2.4",
42
+ "fs-extra": "^11.1.0",
43
+ "ignore": "^5.0.4",
44
+ "semver": "^7.5.3",
45
+ "url-loader": "^4.1.1",
46
+ "tslib": "^2.3.0",
47
+ "webpack-merge": "^5.8.0",
48
+ "@nx/js": "0.0.0-pr-22179-271588f",
49
+ "@nx/eslint": "0.0.0-pr-22179-271588f",
50
+ "@nx/react": "0.0.0-pr-22179-271588f",
51
+ "@nx/web": "0.0.0-pr-22179-271588f",
52
+ "@nx/webpack": "0.0.0-pr-22179-271588f",
53
+ "@nx/workspace": "0.0.0-pr-22179-271588f",
54
+ "@nrwl/next": "0.0.0-pr-22179-271588f"
55
+ },
56
+ "publishConfig": {
57
+ "access": "public"
58
+ },
59
+ "type": "commonjs"
60
+ }
package/plugin.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { createNodes, NextPluginOptions } from './src/plugins/plugin';
package/plugin.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createNodes = void 0;
4
+ var plugin_1 = require("./src/plugins/plugin");
5
+ Object.defineProperty(exports, "createNodes", { enumerable: true, get: function () { return plugin_1.createNodes; } });
@@ -0,0 +1,2 @@
1
+ import { NxComponentTestingOptions } from '@nx/cypress/plugins/cypress-preset';
2
+ export declare function nxComponentTestingPreset(pathToConfig: string, options?: NxComponentTestingOptions): any;
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.nxComponentTestingPreset = void 0;
4
+ const ct_helpers_1 = require("@nx/cypress/src/utils/ct-helpers");
5
+ const cypress_preset_1 = require("@nx/cypress/plugins/cypress-preset");
6
+ const devkit_1 = require("@nx/devkit");
7
+ const react_1 = require("@nx/react");
8
+ const webpack_1 = require("@nx/webpack");
9
+ const path_1 = require("path");
10
+ function nxComponentTestingPreset(pathToConfig, options) {
11
+ if (global.NX_GRAPH_CREATION || global.NX_CYPRESS_INIT_GENERATOR_RUNNING) {
12
+ // this is only used by plugins, so we don't need the component testing
13
+ // options, cast to any to avoid type errors
14
+ return (0, cypress_preset_1.nxBaseCypressPreset)(pathToConfig);
15
+ }
16
+ const graph = (0, devkit_1.readCachedProjectGraph)();
17
+ const { targets: ctTargets, name: ctProjectName } = (0, ct_helpers_1.getProjectConfigByPath)(graph, pathToConfig);
18
+ const ctTargetName = options?.ctTargetName || 'component-test';
19
+ const ctConfigurationName = process.env.NX_CYPRESS_TARGET_CONFIGURATION;
20
+ const ctExecutorContext = (0, ct_helpers_1.createExecutorContext)(graph, ctTargets, ctProjectName, ctTargetName, ctConfigurationName);
21
+ let buildTarget = options?.buildTarget;
22
+ if (!buildTarget) {
23
+ const ctExecutorOptions = (0, devkit_1.readTargetOptions)({
24
+ project: ctProjectName,
25
+ target: ctTargetName,
26
+ configuration: ctConfigurationName,
27
+ }, ctExecutorContext);
28
+ buildTarget = ctExecutorOptions.devServerTarget;
29
+ }
30
+ let buildAssets = [];
31
+ let buildFileReplacements = [];
32
+ let buildOuputPath = `dist/${ctProjectName}/.next`;
33
+ if (buildTarget) {
34
+ const parsedBuildTarget = (0, devkit_1.parseTargetString)(buildTarget, {
35
+ cwd: process.cwd(),
36
+ root: devkit_1.workspaceRoot,
37
+ isVerbose: false,
38
+ projectName: ctProjectName,
39
+ projectGraph: graph,
40
+ });
41
+ const buildProjectConfig = graph.nodes[parsedBuildTarget.project]?.data;
42
+ if (buildProjectConfig?.targets?.[parsedBuildTarget.target]?.executor !==
43
+ '@nx/next:build') {
44
+ throw new Error(`The '${parsedBuildTarget.target}' target of the '${[
45
+ parsedBuildTarget.project,
46
+ ]}' project is not using the '@nx/next:build' executor. ` +
47
+ `Please make sure to use '@nx/next:build' executor in that target to use Cypress Component Testing.`);
48
+ }
49
+ const buildExecutorContext = (0, ct_helpers_1.createExecutorContext)(graph, buildProjectConfig.targets, parsedBuildTarget.project, parsedBuildTarget.target, parsedBuildTarget.configuration);
50
+ const buildExecutorOptions = (0, devkit_1.readTargetOptions)({
51
+ project: parsedBuildTarget.project,
52
+ target: parsedBuildTarget.target,
53
+ configuration: parsedBuildTarget.configuration,
54
+ }, buildExecutorContext);
55
+ buildAssets ??= buildExecutorOptions.assets;
56
+ buildFileReplacements ??= buildExecutorOptions.fileReplacements;
57
+ buildOuputPath ??= buildExecutorOptions.outputPath;
58
+ }
59
+ const ctProjectConfig = graph.nodes[ctProjectName]?.data;
60
+ if (!ctProjectConfig) {
61
+ throw new Error((0, devkit_1.stripIndents) `Unable to load project configs from the project graph.
62
+ Provided build target, ${buildTarget}.
63
+ Able to find CT project, ${!!ctProjectConfig}.`);
64
+ }
65
+ const webpackOptions = {
66
+ root: ctExecutorContext.root,
67
+ projectRoot: ctProjectConfig.root,
68
+ sourceRoot: ctProjectConfig.sourceRoot,
69
+ main: '',
70
+ fileReplacements: buildFileReplacements,
71
+ assets: buildAssets,
72
+ outputPath: buildOuputPath,
73
+ outputFileName: 'main.js',
74
+ compiler: options?.compiler || 'swc',
75
+ tsConfig: (0, path_1.join)(ctExecutorContext.root, ctProjectConfig.root, 'tsconfig.json'),
76
+ };
77
+ const configure = (0, webpack_1.composePluginsSync)((0, webpack_1.withNx)({
78
+ target: 'web',
79
+ styles: [],
80
+ scripts: [],
81
+ postcssConfig: ctProjectConfig.root,
82
+ }), (0, react_1.withReact)({}));
83
+ const webpackConfig = configure({}, {
84
+ options: webpackOptions,
85
+ context: ctExecutorContext,
86
+ });
87
+ return {
88
+ ...(0, cypress_preset_1.nxBaseCypressPreset)(pathToConfig),
89
+ specPattern: '**/*.cy.{js,jsx,ts,tsx}',
90
+ devServer: {
91
+ ...{ framework: 'react', bundler: 'webpack' },
92
+ webpackConfig,
93
+ },
94
+ };
95
+ }
96
+ exports.nxComponentTestingPreset = nxComponentTestingPreset;
@@ -0,0 +1,3 @@
1
+ import { NextConfigFn } from '../src/utils/config';
2
+ import { WithNxOptions } from './with-nx';
3
+ export declare function withLess(configOrFn: NextConfigFn | WithNxOptions): NextConfigFn;
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withLess = void 0;
4
+ // Adapted from https://raw.githubusercontent.com/elado/next-with-less/main/src/index.js
5
+ const webpack_merge_1 = require("webpack-merge");
6
+ const addLessToRegExp = (rx) => new RegExp(rx.source.replace('|sass', '|sass|less'), rx.flags);
7
+ function withLess(configOrFn) {
8
+ return async (phase) => {
9
+ const baseConfig = typeof configOrFn === 'function' ? await configOrFn(phase) : configOrFn;
10
+ const { lessLoaderOptions = {}, ...nextConfig } = baseConfig;
11
+ return Object.assign({}, nextConfig, {
12
+ webpack(config, opts) {
13
+ // there are 2 relevant sass rules in next.js - css modules and global css
14
+ let sassModuleRule;
15
+ // global sass rule (does not exist in server builds)
16
+ let sassGlobalRule;
17
+ const cssRule = config.module.rules.find((rule) => rule.oneOf?.find((r) => r?.[Symbol.for('__next_css_remove')]));
18
+ const addLessToRuleTest = (test) => {
19
+ if (Array.isArray(test)) {
20
+ return test.map((rx) => addLessToRegExp(rx));
21
+ }
22
+ else {
23
+ return addLessToRegExp(test);
24
+ }
25
+ };
26
+ cssRule.oneOf.forEach((rule) => {
27
+ if (rule.options?.__next_css_remove)
28
+ return;
29
+ if (rule.use?.loader === 'error-loader') {
30
+ rule.test = addLessToRuleTest(rule.test);
31
+ }
32
+ else if (rule.use?.loader?.includes('file-loader')) {
33
+ rule.issuer = addLessToRuleTest(rule.issuer);
34
+ }
35
+ else if (rule.use?.includes?.('ignore-loader')) {
36
+ rule.test = addLessToRuleTest(rule.test);
37
+ }
38
+ else if (rule.test?.source === '\\.module\\.(scss|sass)$') {
39
+ sassModuleRule = rule;
40
+ }
41
+ else if (rule.test?.source === '(?<!\\.module)\\.(scss|sass)$') {
42
+ sassGlobalRule = rule;
43
+ }
44
+ });
45
+ const lessLoader = {
46
+ loader: 'less-loader',
47
+ options: {
48
+ ...lessLoaderOptions,
49
+ lessOptions: {
50
+ javascriptEnabled: true,
51
+ // @ts-ignore
52
+ ...lessLoaderOptions.lessOptions,
53
+ },
54
+ },
55
+ };
56
+ let lessModuleRule = (0, webpack_merge_1.merge)(sassModuleRule);
57
+ const configureLessRule = (rule) => {
58
+ rule.test = new RegExp(rule.test.source.replace('(scss|sass)', 'less'));
59
+ // replace sass-loader (last entry) with less-loader
60
+ rule.use.splice(-1, 1, lessLoader);
61
+ };
62
+ configureLessRule(lessModuleRule);
63
+ cssRule.oneOf.splice(cssRule.oneOf.indexOf(sassModuleRule) + 1, 0, lessModuleRule);
64
+ if (sassGlobalRule) {
65
+ let lessGlobalRule = (0, webpack_merge_1.merge)(sassGlobalRule);
66
+ configureLessRule(lessGlobalRule);
67
+ cssRule.oneOf.splice(cssRule.oneOf.indexOf(sassGlobalRule) + 1, 0, lessGlobalRule);
68
+ }
69
+ if (typeof nextConfig.webpack === 'function') {
70
+ return nextConfig.webpack(config, opts);
71
+ }
72
+ return config;
73
+ },
74
+ });
75
+ };
76
+ }
77
+ exports.withLess = withLess;
78
+ module.exports = withLess;
79
+ module.exports.withLess = withLess;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * WARNING: Do not add development dependencies to top-level imports.
3
+ * Instead, `require` them inline during the build phase.
4
+ */
5
+ import type { NextConfig } from 'next';
6
+ import type { NextConfigFn } from '../src/utils/config';
7
+ import { type ProjectGraphProjectNode } from '@nx/devkit';
8
+ export interface WithNxOptions extends NextConfig {
9
+ nx?: {
10
+ svgr?: boolean;
11
+ babelUpwardRootMode?: boolean;
12
+ };
13
+ }
14
+ export interface WithNxContext {
15
+ workspaceRoot: string;
16
+ libsDir: string;
17
+ }
18
+ /**
19
+ * Try to read output dir from project, and default to '.next' if executing outside of Nx (e.g. dist is added to a docker image).
20
+ */
21
+ declare function withNx(_nextConfig?: WithNxOptions, context?: WithNxContext): NextConfigFn;
22
+ export declare function getNextConfig(nextConfig?: WithNxOptions, context?: WithNxContext): NextConfig;
23
+ export declare function getAliasForProject(node: ProjectGraphProjectNode, paths: Record<string, string[]>): null | string;
24
+ export declare function forNextVersion(range: string, fn: () => void): void;
25
+ export { withNx };