@nx/remix 23.3.0 → 24.0.0-beta.0

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 (157) hide show
  1. package/README.md +10 -7
  2. package/dist/generators.d.ts +1 -13
  3. package/dist/generators.js +3 -28
  4. package/dist/plugin.d.ts +1 -1
  5. package/dist/plugin.js +1 -2
  6. package/dist/plugins/component-testing/index.d.ts +1 -0
  7. package/dist/plugins/component-testing/index.js +1 -0
  8. package/dist/readme-template.md +10 -4
  9. package/dist/src/generators/convert-to-inferred/convert-to-inferred.js +2 -0
  10. package/dist/src/migrations/update-24-0-0/convert-to-inferred.d.ts +2 -0
  11. package/dist/src/migrations/update-24-0-0/convert-to-inferred.js +26 -0
  12. package/dist/src/migrations/update-24-0-0/migrate-to-react-router.md +50 -0
  13. package/dist/src/plugins/plugin.d.ts +5 -3
  14. package/dist/src/plugins/plugin.js +8 -7
  15. package/dist/src/utils/create-watch-paths.d.ts +1 -0
  16. package/dist/src/utils/create-watch-paths.js +1 -0
  17. package/dist/src/utils/deprecation.d.ts +2 -4
  18. package/dist/src/utils/deprecation.js +11 -13
  19. package/dist/src/utils/versions.d.ts +1 -19
  20. package/dist/src/utils/versions.js +1 -28
  21. package/generators.json +2 -79
  22. package/migrations.json +10 -0
  23. package/package.json +8 -19
  24. package/readme-template.md +10 -4
  25. package/dist/src/executors/build/build.impl.d.ts +0 -5
  26. package/dist/src/executors/build/build.impl.js +0 -121
  27. package/dist/src/executors/build/schema.d.ts +0 -8
  28. package/dist/src/executors/build/schema.json +0 -47
  29. package/dist/src/executors/serve/schema.d.ts +0 -9
  30. package/dist/src/executors/serve/schema.json +0 -43
  31. package/dist/src/executors/serve/serve.impl.d.ts +0 -6
  32. package/dist/src/executors/serve/serve.impl.js +0 -79
  33. package/dist/src/generators/action/action.impl.d.ts +0 -3
  34. package/dist/src/generators/action/action.impl.js +0 -37
  35. package/dist/src/generators/action/schema.d.ts +0 -3
  36. package/dist/src/generators/action/schema.json +0 -18
  37. package/dist/src/generators/application/application.impl.d.ts +0 -5
  38. package/dist/src/generators/application/application.impl.js +0 -239
  39. package/dist/src/generators/application/files/common/app/entry.client.tsx__tmpl__ +0 -18
  40. package/dist/src/generators/application/files/common/app/entry.server.tsx__tmpl__ +0 -139
  41. package/dist/src/generators/application/files/common/app/root.tsx__tmpl__ +0 -47
  42. package/dist/src/generators/application/files/common/app/routes/_index.tsx__tmpl__ +0 -9
  43. package/dist/src/generators/application/files/common/public/favicon.ico +0 -0
  44. package/dist/src/generators/application/files/common/tests/routes/_index.spec.tsx__tmpl__ +0 -17
  45. package/dist/src/generators/application/files/common/tsconfig.app.json__tmpl__ +0 -25
  46. package/dist/src/generators/application/files/common/tsconfig.json__tmpl__ +0 -27
  47. package/dist/src/generators/application/files/common/vite.config.mts__tmpl__ +0 -25
  48. package/dist/src/generators/application/files/non-root/.gitignore__tmpl__ +0 -4
  49. package/dist/src/generators/application/files/non-root/package.json__tmpl__ +0 -20
  50. package/dist/src/generators/application/files/nx-welcome/claimed/app/nx-welcome.tsx__tmpl__ +0 -868
  51. package/dist/src/generators/application/files/nx-welcome/not-configured/app/nx-welcome.tsx__tmpl__ +0 -868
  52. package/dist/src/generators/application/files/nx-welcome/unclaimed/app/nx-welcome.tsx__tmpl__ +0 -866
  53. package/dist/src/generators/application/files/ts-solution/package.json__tmpl__ +0 -20
  54. package/dist/src/generators/application/files/ts-solution/tsconfig.app.json__tmpl__ +0 -41
  55. package/dist/src/generators/application/files/ts-solution/tsconfig.json__tmpl__ +0 -10
  56. package/dist/src/generators/application/lib/add-e2e.d.ts +0 -3
  57. package/dist/src/generators/application/lib/add-e2e.js +0 -117
  58. package/dist/src/generators/application/lib/ignore-vite-temp-files.d.ts +0 -2
  59. package/dist/src/generators/application/lib/ignore-vite-temp-files.js +0 -50
  60. package/dist/src/generators/application/lib/index.d.ts +0 -4
  61. package/dist/src/generators/application/lib/index.js +0 -7
  62. package/dist/src/generators/application/lib/normalize-options.d.ts +0 -12
  63. package/dist/src/generators/application/lib/normalize-options.js +0 -40
  64. package/dist/src/generators/application/lib/update-unit-test-config.d.ts +0 -2
  65. package/dist/src/generators/application/lib/update-unit-test-config.js +0 -57
  66. package/dist/src/generators/application/schema.d.ts +0 -18
  67. package/dist/src/generators/application/schema.json +0 -70
  68. package/dist/src/generators/cypress-component-configuration/cypress-component-configuration.impl.d.ts +0 -5
  69. package/dist/src/generators/cypress-component-configuration/cypress-component-configuration.impl.js +0 -35
  70. package/dist/src/generators/cypress-component-configuration/files/cypress.config.ts__tmpl__ +0 -6
  71. package/dist/src/generators/cypress-component-configuration/schema.d.ts +0 -6
  72. package/dist/src/generators/cypress-component-configuration/schema.json +0 -41
  73. package/dist/src/generators/error-boundary/error-boundary.impl.d.ts +0 -3
  74. package/dist/src/generators/error-boundary/error-boundary.impl.js +0 -14
  75. package/dist/src/generators/error-boundary/lib/add-v2-error-boundary.d.ts +0 -3
  76. package/dist/src/generators/error-boundary/lib/add-v2-error-boundary.js +0 -37
  77. package/dist/src/generators/error-boundary/lib/index.d.ts +0 -2
  78. package/dist/src/generators/error-boundary/lib/index.js +0 -5
  79. package/dist/src/generators/error-boundary/lib/normalize-options.d.ts +0 -3
  80. package/dist/src/generators/error-boundary/lib/normalize-options.js +0 -13
  81. package/dist/src/generators/error-boundary/schema.d.ts +0 -4
  82. package/dist/src/generators/error-boundary/schema.json +0 -26
  83. package/dist/src/generators/init/init.d.ts +0 -5
  84. package/dist/src/generators/init/init.js +0 -67
  85. package/dist/src/generators/init/schema.d.ts +0 -7
  86. package/dist/src/generators/init/schema.json +0 -33
  87. package/dist/src/generators/library/lib/add-tsconfig-entry-points.d.ts +0 -3
  88. package/dist/src/generators/library/lib/add-tsconfig-entry-points.js +0 -20
  89. package/dist/src/generators/library/lib/add-unit-testing.d.ts +0 -3
  90. package/dist/src/generators/library/lib/add-unit-testing.js +0 -31
  91. package/dist/src/generators/library/lib/index.d.ts +0 -4
  92. package/dist/src/generators/library/lib/index.js +0 -7
  93. package/dist/src/generators/library/lib/normalize-options.d.ts +0 -8
  94. package/dist/src/generators/library/lib/normalize-options.js +0 -31
  95. package/dist/src/generators/library/lib/update-buildable-config.d.ts +0 -3
  96. package/dist/src/generators/library/lib/update-buildable-config.js +0 -23
  97. package/dist/src/generators/library/library.impl.d.ts +0 -6
  98. package/dist/src/generators/library/library.impl.js +0 -78
  99. package/dist/src/generators/library/schema.d.ts +0 -19
  100. package/dist/src/generators/library/schema.json +0 -89
  101. package/dist/src/generators/loader/loader.impl.d.ts +0 -3
  102. package/dist/src/generators/loader/loader.impl.js +0 -37
  103. package/dist/src/generators/loader/schema.d.ts +0 -3
  104. package/dist/src/generators/loader/schema.json +0 -18
  105. package/dist/src/generators/meta/lib/v2.impl.d.ts +0 -3
  106. package/dist/src/generators/meta/lib/v2.impl.js +0 -24
  107. package/dist/src/generators/meta/meta.impl.d.ts +0 -3
  108. package/dist/src/generators/meta/meta.impl.js +0 -9
  109. package/dist/src/generators/meta/schema.d.ts +0 -3
  110. package/dist/src/generators/meta/schema.json +0 -18
  111. package/dist/src/generators/preset/lib/normalize-options.d.ts +0 -10
  112. package/dist/src/generators/preset/lib/normalize-options.js +0 -19
  113. package/dist/src/generators/preset/preset.impl.d.ts +0 -3
  114. package/dist/src/generators/preset/preset.impl.js +0 -34
  115. package/dist/src/generators/preset/schema.d.ts +0 -4
  116. package/dist/src/generators/preset/schema.json +0 -14
  117. package/dist/src/generators/resource-route/resource-route.impl.d.ts +0 -3
  118. package/dist/src/generators/resource-route/resource-route.impl.js +0 -37
  119. package/dist/src/generators/resource-route/schema.d.ts +0 -6
  120. package/dist/src/generators/resource-route/schema.json +0 -44
  121. package/dist/src/generators/route/route.impl.d.ts +0 -3
  122. package/dist/src/generators/route/route.impl.js +0 -62
  123. package/dist/src/generators/route/schema.d.ts +0 -8
  124. package/dist/src/generators/route/schema.json +0 -55
  125. package/dist/src/generators/setup/schema.json +0 -14
  126. package/dist/src/generators/setup/setup.impl.d.ts +0 -2
  127. package/dist/src/generators/setup/setup.impl.js +0 -38
  128. package/dist/src/generators/storybook-configuration/files/vite.config.mts__tpl__ +0 -15
  129. package/dist/src/generators/storybook-configuration/schema.d.ts +0 -14
  130. package/dist/src/generators/storybook-configuration/schema.json +0 -78
  131. package/dist/src/generators/storybook-configuration/storybook-configuration.impl.d.ts +0 -4
  132. package/dist/src/generators/storybook-configuration/storybook-configuration.impl.js +0 -33
  133. package/dist/src/generators/style/schema.d.ts +0 -3
  134. package/dist/src/generators/style/schema.json +0 -25
  135. package/dist/src/generators/style/style.impl.d.ts +0 -3
  136. package/dist/src/generators/style/style.impl.js +0 -55
  137. package/dist/src/generators/utils/update-dependencies.d.ts +0 -2
  138. package/dist/src/generators/utils/update-dependencies.js +0 -32
  139. package/dist/src/utils/assert-and-pin-remix-typescript.d.ts +0 -21
  140. package/dist/src/utils/assert-and-pin-remix-typescript.js +0 -36
  141. package/dist/src/utils/get-default-export-name.d.ts +0 -2
  142. package/dist/src/utils/get-default-export-name.js +0 -7
  143. package/dist/src/utils/get-default-export.d.ts +0 -2
  144. package/dist/src/utils/get-default-export.js +0 -14
  145. package/dist/src/utils/insert-import.d.ts +0 -4
  146. package/dist/src/utils/insert-import.js +0 -53
  147. package/dist/src/utils/insert-statement-after-imports.d.ts +0 -5
  148. package/dist/src/utils/insert-statement-after-imports.js +0 -27
  149. package/dist/src/utils/insert-statement-in-default-function.d.ts +0 -2
  150. package/dist/src/utils/insert-statement-in-default-function.js +0 -22
  151. package/dist/src/utils/remix-config.d.ts +0 -6
  152. package/dist/src/utils/remix-config.js +0 -75
  153. package/dist/src/utils/remix-route-utils.d.ts +0 -4
  154. package/dist/src/utils/remix-route-utils.js +0 -26
  155. package/dist/src/utils/testing-config-utils.d.ts +0 -5
  156. package/dist/src/utils/testing-config-utils.js +0 -83
  157. package/executors.json +0 -14
@@ -1,7 +1,7 @@
1
- <p style="text-align: center;">
1
+ <p align="center">
2
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 Builds" src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-light.svg" width="100%">
3
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-logo-light.svg">
4
+ <img alt="Nx Logo" src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-logo.svg" width="140">
5
5
  </picture>
6
6
  </p>
7
7
 
@@ -13,6 +13,12 @@
13
13
 
14
14
  Get to green PRs in half the time. Nx optimizes your builds, scales your CI, and fixes failed PRs. Built for developers and AI agents.
15
15
 
16
- This package is a [Remix plugin for Nx](https://nx.dev/nx-api/remix).
16
+ > `@nx/remix` is deprecated and will be removed in Nx 25. Nx 24 removes all executors and generators except `convert-to-inferred`.
17
+
18
+ Existing Remix v2 applications can keep using `@nx/remix/plugin` until Nx 25. The Nx 24 migration converts legacy executor targets to inferred tasks. Run `nx g @nx/remix:convert-to-inferred` to convert them manually.
19
+
20
+ For continued development, migrate to React Router with `@nx/react`. The `migrate-to-react-router` prompt migration guides an AI agent through the framework upgrade and Nx configuration, then asks it to run build and other relevant targets.
21
+
22
+ See the [Remix migration instructions](https://nx.dev/docs/technologies/react/remix/introduction).
17
23
 
18
24
  {{content}}
@@ -1,5 +0,0 @@
1
- import { type ExecutorContext } from '@nx/devkit';
2
- import { type RemixBuildSchema } from './schema';
3
- export default function buildExecutor(options: RemixBuildSchema, context: ExecutorContext): Promise<{
4
- success: boolean;
5
- }>;
@@ -1,121 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = buildExecutor;
4
- const devkit_1 = require("@nx/devkit");
5
- const js_1 = require("@nx/js");
6
- const child_process_1 = require("child_process");
7
- const fs_extra_1 = require("fs-extra");
8
- const path_1 = require("path");
9
- const deprecation_1 = require("../../utils/deprecation");
10
- function buildRemixBuildArgs(options) {
11
- const args = ['build'];
12
- if (options.sourcemap) {
13
- args.push(`--sourcemap`);
14
- }
15
- return args;
16
- }
17
- async function runBuild(options, context) {
18
- const projectRoot = context.projectGraph.nodes[context.projectName].data.root;
19
- return new Promise((resolve, reject) => {
20
- const remixBin = require.resolve('@remix-run/dev/dist/cli');
21
- const args = buildRemixBuildArgs(options);
22
- const p = (0, child_process_1.fork)(remixBin, args, {
23
- cwd: (0, path_1.join)(context.root, projectRoot),
24
- stdio: 'inherit',
25
- });
26
- p.on('exit', (code) => {
27
- if (code === 0)
28
- resolve();
29
- else
30
- reject();
31
- });
32
- });
33
- }
34
- async function buildExecutor(options, context) {
35
- (0, deprecation_1.warnRemixBuildExecutorDeprecation)();
36
- const projectRoot = context.projectGraph.nodes[context.projectName].data.root;
37
- try {
38
- await runBuild(options, context);
39
- }
40
- catch (error) {
41
- devkit_1.logger.error(`Error occurred while trying to build application. See above for more details.`);
42
- return { success: false };
43
- }
44
- let outputIsDirectory = false;
45
- try {
46
- outputIsDirectory = (0, fs_extra_1.statSync)(options.outputPath).isDirectory();
47
- }
48
- catch {
49
- // path does not exist; will be created below
50
- }
51
- if (!outputIsDirectory) {
52
- (0, fs_extra_1.mkdir)(options.outputPath);
53
- }
54
- const packageManager = (0, devkit_1.detectPackageManager)(context.root);
55
- let packageJson;
56
- if (options.generatePackageJson) {
57
- packageJson = (0, js_1.createPackageJson)(context.projectName, context.projectGraph, {
58
- target: context.targetName,
59
- root: context.root,
60
- isProduction: !options.includeDevDependenciesInPackageJson, // By default we remove devDependencies since this is a production build.
61
- skipPackageManager: options.skipPackageManager,
62
- });
63
- // Update `package.json` to reflect how users should run the build artifacts
64
- packageJson.scripts ??= {};
65
- // Don't override existing custom script since project may have its own server.
66
- if (!packageJson.scripts.start) {
67
- packageJson.scripts['start'] = 'remix-serve ./build/index.js';
68
- }
69
- updatePackageJson(packageJson, context);
70
- }
71
- else {
72
- packageJson = (0, devkit_1.readJsonFile)((0, path_1.join)(projectRoot, 'package.json'));
73
- }
74
- if (options.generateLockfile) {
75
- (0, js_1.generatePrunedDeployOutput)(packageJson, context.projectGraph, projectRoot, {
76
- outputDirectory: options.outputPath,
77
- packageManager,
78
- workspaceRoot: context.root,
79
- });
80
- }
81
- if (options.generatePackageJson) {
82
- (0, devkit_1.writeJsonFile)(`${options.outputPath}/package.json`, packageJson);
83
- }
84
- // If output path is different from source path, then copy over the config and public files.
85
- // This is the default behavior when running `nx build <app>`.
86
- if (options.outputPath.replace(/\/$/, '') !== projectRoot) {
87
- (0, fs_extra_1.copySync)((0, path_1.join)(projectRoot, 'public'), (0, path_1.join)(options.outputPath, 'public'), {
88
- dereference: true,
89
- });
90
- (0, fs_extra_1.copySync)((0, path_1.join)(projectRoot, 'build'), (0, path_1.join)(options.outputPath, 'build'), {
91
- dereference: true,
92
- });
93
- }
94
- return { success: true };
95
- }
96
- function updatePackageJson(packageJson, context) {
97
- if (!packageJson.scripts) {
98
- packageJson.scripts = {};
99
- }
100
- if (!packageJson.scripts.start) {
101
- packageJson.scripts.start = 'remix-serve build';
102
- }
103
- packageJson.dependencies ??= {};
104
- // These are always required for a production Remix app to run.
105
- const requiredPackages = [
106
- 'react',
107
- 'react-dom',
108
- 'isbot',
109
- '@remix-run/css-bundle',
110
- '@remix-run/node',
111
- '@remix-run/react',
112
- '@remix-run/serve',
113
- '@remix-run/dev',
114
- ];
115
- for (const pkg of requiredPackages) {
116
- const externalNode = context.projectGraph.externalNodes[`npm:${pkg}`];
117
- if (externalNode) {
118
- packageJson.dependencies[pkg] ??= externalNode.data.version;
119
- }
120
- }
121
- }
@@ -1,8 +0,0 @@
1
- export interface RemixBuildSchema {
2
- generateLockfile?: boolean;
3
- generatePackageJson?: boolean;
4
- includeDevDependenciesInPackageJson?: boolean;
5
- outputPath: string;
6
- skipPackageManager?: boolean;
7
- sourcemap?: boolean;
8
- }
@@ -1,47 +0,0 @@
1
- {
2
- "version": 2,
3
- "outputCapture": "pipe",
4
- "$schema": "https://json-schema.org/schema",
5
- "cli": "nx",
6
- "title": "Remix Build",
7
- "description": "Build a Remix app.",
8
- "type": "object",
9
- "x-deprecated": "The `@nx/remix:build` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/remix:convert-to-inferred` to migrate to the `@nx/remix/plugin` inferred plugin. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.",
10
- "properties": {
11
- "outputPath": {
12
- "type": "string",
13
- "description": "The output path of the generated files.",
14
- "x-completion-type": "directory",
15
- "x-priority": "important"
16
- },
17
- "includeDevDependenciesInPackageJson": {
18
- "type": "boolean",
19
- "description": "Include `devDependencies` in the generated package.json file. By default only production `dependencies` are included.",
20
- "default": false
21
- },
22
- "generatePackageJson": {
23
- "type": "boolean",
24
- "description": "Generate package.json file in the output folder.",
25
- "default": false
26
- },
27
- "generateLockfile": {
28
- "type": "boolean",
29
- "description": "Generate a lockfile (e.g. package-lock.json) that matches the workspace lockfile to ensure package versions match.",
30
- "default": false
31
- },
32
- "skipOverrides": {
33
- "type": "boolean",
34
- "description": "Do not add a `overrides` and `resolutions` entries to the generated package.json file. Only works in conjunction with `generatePackageJson` option."
35
- },
36
- "skipPackageManager": {
37
- "type": "boolean",
38
- "description": "Do not add a `packageManager` entry to the generated package.json file. Only works in conjunction with `generatePackageJson` option."
39
- },
40
- "sourcemap": {
41
- "type": "boolean",
42
- "description": "Generate source maps for production.",
43
- "default": false
44
- }
45
- },
46
- "required": ["outputPath"]
47
- }
@@ -1,9 +0,0 @@
1
- export interface RemixServeSchema {
2
- port: number;
3
- devServerPort?: number;
4
- debug?: boolean;
5
- command?: string;
6
- manual?: boolean;
7
- tlsKey?: string;
8
- tlsCert?: string;
9
- }
@@ -1,43 +0,0 @@
1
- {
2
- "version": 2,
3
- "continuous": true,
4
- "outputCapture": "pipe",
5
- "cli": "nx",
6
- "title": "Remix Serve",
7
- "description": "Serve a Remix app.",
8
- "type": "object",
9
- "x-deprecated": "The `@nx/remix:serve` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/remix:convert-to-inferred` to migrate to the `@nx/remix/plugin` inferred plugin. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.",
10
- "properties": {
11
- "port": {
12
- "type": "number",
13
- "description": "Set PORT environment variable that can be used to serve the Remix application.",
14
- "default": 4200
15
- },
16
- "devServerPort": {
17
- "type": "number",
18
- "description": "Port to start the dev server on."
19
- },
20
- "debug": {
21
- "type": "boolean",
22
- "description": "Attach a Node.js inspector.",
23
- "default": false
24
- },
25
- "command": {
26
- "type": "string",
27
- "description": "Command used to run your app server."
28
- },
29
- "manual": {
30
- "type": "boolean",
31
- "description": "Enable manual mode",
32
- "default": false
33
- },
34
- "tlsKey": {
35
- "type": "string",
36
- "description": "Path to TLS key (key.pem)."
37
- },
38
- "tlsCert": {
39
- "type": "string",
40
- "description": "Path to TLS certificate (cert.pem)."
41
- }
42
- }
43
- }
@@ -1,6 +0,0 @@
1
- import { type ExecutorContext } from '@nx/devkit';
2
- import { type RemixServeSchema } from './schema';
3
- export default function serveExecutor(schema: RemixServeSchema, context: ExecutorContext): AsyncGenerator<{
4
- success: boolean;
5
- baseUrl: string;
6
- }, void, any>;
@@ -1,79 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = serveExecutor;
4
- const devkit_1 = require("@nx/devkit");
5
- const internal_1 = require("@nx/devkit/internal");
6
- const internal_2 = require("@nx/web/internal");
7
- const node_child_process_1 = require("node:child_process");
8
- const node_path_1 = require("node:path");
9
- const deprecation_1 = require("../../utils/deprecation");
10
- function normalizeOptions(schema) {
11
- return {
12
- ...schema,
13
- port: schema.port ?? 4200,
14
- debug: schema.debug ?? false,
15
- manual: schema.manual ?? false,
16
- };
17
- }
18
- function buildRemixDevArgs(options) {
19
- const args = [];
20
- if (options.command) {
21
- args.push(`--command=${options.command}`);
22
- }
23
- if (options.devServerPort) {
24
- args.push(`--port=${options.devServerPort}`);
25
- }
26
- if (options.debug) {
27
- args.push(`--debug`);
28
- }
29
- if (options.manual) {
30
- args.push(`--manual`);
31
- }
32
- if (options.tlsKey) {
33
- args.push(`--tls-key=${options.tlsKey}`);
34
- }
35
- if (options.tlsCert) {
36
- args.push(`--tls-cert=${options.tlsCert}`);
37
- }
38
- return args;
39
- }
40
- async function* serveExecutor(schema, context) {
41
- (0, deprecation_1.warnRemixServeExecutorDeprecation)();
42
- const options = normalizeOptions(schema);
43
- const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
44
- const remixBin = require.resolve('@remix-run/dev/dist/cli');
45
- const args = buildRemixDevArgs(options);
46
- // Cast to any to overwrite NODE_ENV
47
- process.env.NODE_ENV = process.env.NODE_ENV
48
- ? process.env.NODE_ENV
49
- : 'development';
50
- process.env.PORT = `${options.port}`;
51
- yield* (0, internal_1.createAsyncIterable)(async ({ done, next, error }) => {
52
- const server = (0, node_child_process_1.fork)(remixBin, ['dev', ...args], {
53
- cwd: (0, node_path_1.join)(devkit_1.workspaceRoot, projectRoot),
54
- stdio: 'inherit',
55
- });
56
- server.once('exit', (code) => {
57
- if (code === 0) {
58
- done();
59
- }
60
- else {
61
- error(new Error(`Remix app exited with code ${code}`));
62
- }
63
- });
64
- const killServer = () => {
65
- if (server.connected) {
66
- server.kill('SIGTERM');
67
- }
68
- };
69
- process.on('exit', () => killServer());
70
- process.on('SIGINT', () => killServer());
71
- process.on('SIGTERM', () => killServer());
72
- process.on('SIGHUP', () => killServer());
73
- await (0, internal_2.waitForPortOpen)(options.port);
74
- next({
75
- success: true,
76
- baseUrl: `http://localhost:${options.port}`,
77
- });
78
- });
79
- }
@@ -1,3 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- import { LoaderSchema } from './schema';
3
- export default function (tree: Tree, schema: LoaderSchema): Promise<void>;
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = default_1;
4
- const devkit_1 = require("@nx/devkit");
5
- const insert_import_1 = require("../../utils/insert-import");
6
- const insert_statement_after_imports_1 = require("../../utils/insert-statement-after-imports");
7
- const insert_statement_in_default_function_1 = require("../../utils/insert-statement-in-default-function");
8
- const versions_1 = require("../../utils/versions");
9
- async function default_1(tree, schema) {
10
- (0, versions_1.assertSupportedRemixVersion)(tree);
11
- const routeFilePath = schema.path;
12
- if (!tree.exists(routeFilePath)) {
13
- throw new Error(`Route path does not exist: ${routeFilePath}. Please generate a Remix route first.`);
14
- }
15
- (0, insert_import_1.insertImport)(tree, routeFilePath, 'ActionFunctionArgs', '@remix-run/node', {
16
- typeOnly: true,
17
- });
18
- (0, insert_import_1.insertImport)(tree, routeFilePath, 'json', '@remix-run/node');
19
- (0, insert_import_1.insertImport)(tree, routeFilePath, 'useActionData', '@remix-run/react');
20
- (0, insert_statement_after_imports_1.insertStatementAfterImports)(tree, routeFilePath, `
21
- export const action = async ({ request }: ActionFunctionArgs) => {
22
- let formData = await request.formData();
23
-
24
- return json({message: formData.toString()}, { status: 200 });
25
- };
26
-
27
- `);
28
- const statement = `\nconst actionMessage = useActionData<typeof action>();`;
29
- try {
30
- (0, insert_statement_in_default_function_1.insertStatementInDefaultFunction)(tree, routeFilePath, statement);
31
- }
32
- catch (err) {
33
- }
34
- finally {
35
- await (0, devkit_1.formatFiles)(tree);
36
- }
37
- }
@@ -1,3 +0,0 @@
1
- export interface LoaderSchema {
2
- path: string;
3
- }
@@ -1,18 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/schema",
3
- "$id": "action",
4
- "type": "object",
5
- "description": "Generate an action for a given route.",
6
- "properties": {
7
- "path": {
8
- "type": "string",
9
- "description": "The route path or path to the filename of the route.",
10
- "$default": {
11
- "$source": "argv",
12
- "index": 0
13
- },
14
- "x-prompt": "What is the path of the route? (e.g. 'apps/demo/app/routes/foo/bar.tsx')"
15
- }
16
- },
17
- "required": ["path"]
18
- }
@@ -1,5 +0,0 @@
1
- import { GeneratorCallback, Tree } from '@nx/devkit';
2
- import { NxRemixGeneratorSchema } from './schema';
3
- export declare function remixApplicationGenerator(tree: Tree, options: NxRemixGeneratorSchema): Promise<GeneratorCallback>;
4
- export declare function remixApplicationGeneratorInternal(tree: Tree, _options: NxRemixGeneratorSchema): Promise<GeneratorCallback>;
5
- export default remixApplicationGenerator;
@@ -1,239 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.remixApplicationGenerator = remixApplicationGenerator;
4
- exports.remixApplicationGeneratorInternal = remixApplicationGeneratorInternal;
5
- const tslib_1 = require("tslib");
6
- const internal_1 = require("@nx/devkit/internal");
7
- const devkit_1 = require("@nx/devkit");
8
- const js_1 = require("@nx/js");
9
- const internal_2 = require("@nx/js/internal");
10
- const testing_config_utils_1 = require("../../utils/testing-config-utils");
11
- const versions_1 = require("../../utils/versions");
12
- const init_1 = tslib_1.__importDefault(require("../init/init"));
13
- const update_dependencies_1 = require("../utils/update-dependencies");
14
- const lib_1 = require("./lib");
15
- function remixApplicationGenerator(tree, options) {
16
- return remixApplicationGeneratorInternal(tree, {
17
- addPlugin: true,
18
- useProjectJson: true,
19
- ...options,
20
- });
21
- }
22
- async function remixApplicationGeneratorInternal(tree, _options) {
23
- (0, versions_1.assertSupportedRemixVersion)(tree);
24
- const addTsPlugin = (0, internal_2.shouldConfigureTsSolutionSetup)(tree, _options.addPlugin, _options.useTsSolution);
25
- // initGenerator enforces the TS pin and hard-errors on TS6.
26
- const tasks = [
27
- await (0, init_1.default)(tree, {
28
- skipFormat: true,
29
- addPlugin: true,
30
- }),
31
- await (0, js_1.initGenerator)(tree, {
32
- skipFormat: true,
33
- addTsPlugin,
34
- formatter: _options.formatter,
35
- platform: 'web',
36
- }),
37
- ];
38
- const options = await (0, lib_1.normalizeOptions)(tree, _options);
39
- if (!options.addPlugin) {
40
- throw new Error(`To generate a new Remix Vite application, you must use Inference Plugins. Check you do not have NX_ADD_PLUGINS=false or useInferencePlugins: false in your nx.json.`);
41
- }
42
- // If we are using the new TS solution
43
- // We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
44
- if (options.isUsingTsSolutionConfig) {
45
- await (0, internal_2.addProjectToTsSolutionWorkspace)(tree, options.projectRoot);
46
- }
47
- if (options.useProjectJson) {
48
- (0, devkit_1.addProjectConfiguration)(tree, options.projectName, {
49
- root: options.projectRoot,
50
- sourceRoot: `${options.projectRoot}`,
51
- projectType: 'application',
52
- tags: options.parsedTags,
53
- targets: {},
54
- });
55
- }
56
- const installTask = (0, update_dependencies_1.updateDependencies)(tree);
57
- tasks.push(installTask);
58
- const onBoardingStatus = await (0, internal_1.createNxCloudOnboardingURLForWelcomeApp)(tree, options.nxCloudToken);
59
- const connectCloudUrl = onBoardingStatus === 'unclaimed' &&
60
- (await (0, internal_1.getNxCloudAppOnBoardingUrl)(options.nxCloudToken));
61
- const vars = {
62
- ...options,
63
- tmpl: '',
64
- offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.projectRoot),
65
- remixVersion: versions_1.remixVersion,
66
- isbotVersion: versions_1.isbotVersion,
67
- reactVersion: versions_1.reactVersion,
68
- reactDomVersion: versions_1.reactDomVersion,
69
- typesReactVersion: versions_1.typesReactVersion,
70
- typesReactDomVersion: versions_1.typesReactDomVersion,
71
- typescriptVersion: versions_1.typescriptVersion,
72
- viteVersion: versions_1.viteVersion,
73
- };
74
- (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files/common'), options.projectRoot, vars);
75
- (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, './files/nx-welcome', onBoardingStatus), options.projectRoot, { ...vars, connectCloudUrl });
76
- if (options.rootProject) {
77
- const gitignore = tree.read('.gitignore', 'utf-8');
78
- tree.write('.gitignore', `${gitignore}\n.cache\nbuild\npublic/build\n.env\n`);
79
- }
80
- else {
81
- (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files/non-root'), options.projectRoot, vars);
82
- }
83
- if (options.isUsingTsSolutionConfig) {
84
- (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files/ts-solution'), options.projectRoot, vars);
85
- }
86
- if (!options.useProjectJson) {
87
- (0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'), (json) => {
88
- if (options.projectName !== options.importPath) {
89
- json.nx = { name: options.projectName };
90
- }
91
- if (options.parsedTags?.length) {
92
- json.nx ??= {};
93
- json.nx.tags = options.parsedTags;
94
- }
95
- return json;
96
- });
97
- }
98
- if (options.unitTestRunner !== 'none') {
99
- if (options.unitTestRunner === 'vitest') {
100
- const { createOrEditViteConfig } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
101
- (0, devkit_1.ensurePackage)('@nx/vitest', versions_1.nxVersion);
102
- const { configurationGenerator, } = require('@nx/vitest/generators');
103
- const vitestTask = await configurationGenerator(tree, {
104
- uiFramework: 'react',
105
- project: options.projectName,
106
- coverageProvider: 'v8',
107
- inSourceTests: false,
108
- skipFormat: true,
109
- testEnvironment: 'jsdom',
110
- skipViteConfig: true,
111
- addPlugin: true,
112
- viteVersion: 6,
113
- });
114
- createOrEditViteConfig(tree, {
115
- project: options.projectName,
116
- includeLib: false,
117
- includeVitest: true,
118
- testEnvironment: 'jsdom',
119
- imports: [`import react from '@vitejs/plugin-react';`],
120
- plugins: [`react()`],
121
- useEsmExtension: true,
122
- }, true, undefined, true);
123
- tasks.push(vitestTask);
124
- }
125
- else {
126
- const { configurationGenerator: jestConfigurationGenerator } = (0, devkit_1.ensurePackage)('@nx/jest', versions_1.nxVersion);
127
- const jestTask = await jestConfigurationGenerator(tree, {
128
- project: options.projectName,
129
- setupFile: 'none',
130
- supportTsx: true,
131
- skipSerializers: false,
132
- skipPackageJson: false,
133
- skipFormat: true,
134
- addPlugin: true,
135
- compiler: options.useTsSolution ? 'swc' : undefined,
136
- });
137
- const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.projectName);
138
- if (projectConfig.targets?.['test']?.options) {
139
- projectConfig.targets['test'].options.passWithNoTests = true;
140
- (0, devkit_1.updateProjectConfiguration)(tree, options.projectName, projectConfig);
141
- }
142
- tasks.push(jestTask);
143
- }
144
- const pkgInstallTask = (0, lib_1.updateUnitTestConfig)(tree, options.projectRoot, options.unitTestRunner, options.rootProject);
145
- tasks.push(pkgInstallTask);
146
- }
147
- else {
148
- tree.delete((0, devkit_1.joinPathFragments)(options.projectRoot, `tests/routes/_index.spec.tsx`));
149
- }
150
- if (options.linter !== 'eslint' && options.linter !== 'none') {
151
- tasks.push(await (0, internal_2.addLintingToProject)(tree, {
152
- oxlintPlugins: ['react', 'react-perf', 'jsx-a11y'],
153
- unitTestRunner: options.unitTestRunner,
154
- linter: options.linter,
155
- project: options.projectName,
156
- addPlugin: options.addPlugin,
157
- }));
158
- }
159
- if (options.linter === 'eslint') {
160
- const { lintProjectGenerator } = (0, devkit_1.ensurePackage)('@nx/eslint', versions_1.nxVersion);
161
- const { addIgnoresToLintConfig, } = require('@nx/eslint/internal');
162
- const eslintTask = await lintProjectGenerator(tree, {
163
- linter: options.linter,
164
- project: options.projectName,
165
- tsConfigPaths: [
166
- (0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.app.json'),
167
- ],
168
- unitTestRunner: options.unitTestRunner,
169
- skipFormat: true,
170
- rootProject: options.rootProject,
171
- addPlugin: options.addPlugin,
172
- });
173
- tasks.push(eslintTask);
174
- addIgnoresToLintConfig(tree, options.projectRoot, [
175
- 'build',
176
- 'public/build',
177
- ]);
178
- }
179
- if (options.rootProject && tree.exists('tsconfig.base.json')) {
180
- // If this is a standalone project, merge tsconfig.json and tsconfig.base.json.
181
- const tsConfigBaseJson = (0, devkit_1.readJson)(tree, 'tsconfig.base.json');
182
- (0, devkit_1.updateJson)(tree, 'tsconfig.json', (json) => {
183
- delete json.extends;
184
- json.compilerOptions = {
185
- ...tsConfigBaseJson.compilerOptions,
186
- ...json.compilerOptions,
187
- // Taken from remix default setup
188
- // https://github.com/remix-run/remix/blob/68c8982/templates/remix/tsconfig.json#L15-L17
189
- paths: {
190
- '~/*': ['./app/*'],
191
- },
192
- };
193
- json.include = [
194
- ...(tsConfigBaseJson.include ?? []),
195
- ...(json.include ?? []),
196
- ];
197
- json.exclude = [
198
- ...(tsConfigBaseJson.exclude ?? []),
199
- ...(json.exclude ?? []),
200
- ];
201
- return json;
202
- });
203
- tree.delete('tsconfig.base.json');
204
- }
205
- else {
206
- // Otherwise, extract the tsconfig.base.json from tsconfig.json so we can share settings.
207
- (0, js_1.extractTsConfigBase)(tree);
208
- }
209
- if (options.rootProject) {
210
- (0, devkit_1.updateJson)(tree, `package.json`, (json) => {
211
- json.type = 'module';
212
- return json;
213
- });
214
- if (options.unitTestRunner === 'jest') {
215
- tree.write('jest.preset.js', `import { nxPreset } from '@nx/jest/preset.js';
216
- export default {...nxPreset};
217
- `);
218
- (0, testing_config_utils_1.updateJestTestMatch)(tree, 'jest.config.cts', '<rootDir>/tests/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}');
219
- }
220
- }
221
- tasks.push(await (0, lib_1.addE2E)(tree, options));
222
- await (0, lib_1.ignoreViteTempFiles)(tree, options.projectRoot);
223
- (0, internal_2.updateTsconfigFiles)(tree, options.projectRoot, 'tsconfig.app.json', {
224
- jsx: 'react-jsx',
225
- module: 'esnext',
226
- moduleResolution: 'bundler',
227
- }, options.linter === 'eslint'
228
- ? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
229
- : undefined, '.');
230
- (0, internal_2.sortPackageJsonFields)(tree, options.projectRoot);
231
- if (!options.skipFormat) {
232
- await (0, devkit_1.formatFiles)(tree);
233
- }
234
- tasks.push(() => {
235
- (0, internal_1.logShowProjectCommand)(options.projectName);
236
- });
237
- return (0, devkit_1.runTasksInSerial)(...tasks);
238
- }
239
- exports.default = remixApplicationGenerator;