@nx/remix 17.3.0-beta.3 → 17.3.0-beta.5

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 (35) hide show
  1. package/generators.d.ts +1 -0
  2. package/generators.js +1 -0
  3. package/generators.json +6 -0
  4. package/package.json +7 -6
  5. package/plugin.d.ts +1 -0
  6. package/plugin.js +6 -0
  7. package/src/generators/action/schema.json +0 -4
  8. package/src/generators/application/__snapshots__/application.impl.spec.ts.snap +144 -48
  9. package/src/generators/application/application.impl.js +18 -17
  10. package/src/generators/application/files/common/remix.config.js__tmpl__ +17 -0
  11. package/src/generators/application/lib/update-unit-test-config.js +4 -4
  12. package/src/generators/error-boundary/schema.json +0 -4
  13. package/src/generators/init/init.d.ts +4 -0
  14. package/src/generators/init/init.js +46 -0
  15. package/src/generators/init/schema.d.ts +4 -0
  16. package/src/generators/init/schema.json +21 -0
  17. package/src/generators/library/lib/add-unit-testing.js +1 -1
  18. package/src/generators/loader/schema.json +0 -4
  19. package/src/generators/meta/schema.json +0 -4
  20. package/src/generators/resource-route/schema.json +0 -4
  21. package/src/generators/route/route.impl.js +1 -0
  22. package/src/generators/route/schema.json +0 -4
  23. package/src/generators/setup-tailwind/__snapshots__/setup-tailwind.impl.spec.ts.snap +18 -6
  24. package/src/generators/setup-tailwind/lib/update-remix-config.js +3 -6
  25. package/src/generators/style/schema.json +0 -4
  26. package/src/generators/utils/update-dependencies.d.ts +2 -0
  27. package/src/generators/utils/update-dependencies.js +21 -0
  28. package/src/plugins/__snapshots__/plugin.spec.ts.snap +111 -0
  29. package/src/plugins/plugin.d.ts +9 -0
  30. package/src/plugins/plugin.js +136 -0
  31. package/src/utils/remix-config.d.ts +1 -0
  32. package/src/utils/remix-config.js +28 -4
  33. package/src/utils/testing-config-utils.d.ts +2 -2
  34. package/src/utils/testing-config-utils.js +9 -9
  35. package/src/generators/application/files/common/remix.config.cjs__tmpl__ +0 -11
package/generators.d.ts CHANGED
@@ -12,3 +12,4 @@ export * from './src/generators/route/route.impl';
12
12
  export * from './src/generators/setup-tailwind/setup-tailwind.impl';
13
13
  export * from './src/generators/storybook-configuration/storybook-configuration.impl';
14
14
  export * from './src/generators/style/style.impl';
15
+ export * from './src/generators/init/init';
package/generators.js CHANGED
@@ -15,3 +15,4 @@ tslib_1.__exportStar(require("./src/generators/route/route.impl"), exports);
15
15
  tslib_1.__exportStar(require("./src/generators/setup-tailwind/setup-tailwind.impl"), exports);
16
16
  tslib_1.__exportStar(require("./src/generators/storybook-configuration/storybook-configuration.impl"), exports);
17
17
  tslib_1.__exportStar(require("./src/generators/style/style.impl"), exports);
18
+ tslib_1.__exportStar(require("./src/generators/init/init"), exports);
package/generators.json CHANGED
@@ -35,6 +35,12 @@
35
35
  "aliases": ["lib"],
36
36
  "x-type": "library"
37
37
  },
38
+ "init": {
39
+ "implementation": "./src/generators/init/init",
40
+ "schema": "./src/generators/init/schema.json",
41
+ "description": "Initialize the `@nx/remix` plugin.",
42
+ "hidden": true
43
+ },
38
44
  "route": {
39
45
  "implementation": "./src/generators/route/route.impl",
40
46
  "schema": "./src/generators/route/schema.json",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/remix",
3
- "version": "17.3.0-beta.3",
3
+ "version": "17.3.0-beta.5",
4
4
  "description": "The Remix plugin for Nx contains executors and generators for managing Remix applications and libraries within an Nx workspace. It provides:\n\n\n- Integration with libraries such as Vitest, Jest, Cypress, and Storybook.\n\n- Generators for applications, libraries, routes, loaders, and more.\n\n- Library build support for publishing packages to npm or other registries.\n\n- Utilities for automatic workspace refactoring.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -28,20 +28,21 @@
28
28
  "migrations": "./migrations.json"
29
29
  },
30
30
  "dependencies": {
31
- "@nx/devkit": "17.3.0-beta.3",
32
- "@nx/js": "17.3.0-beta.3",
33
- "@nx/react": "17.3.0-beta.3",
31
+ "@nx/devkit": "17.3.0-beta.5",
32
+ "@nx/js": "17.3.0-beta.5",
33
+ "@nx/react": "17.3.0-beta.5",
34
34
  "tslib": "^2.3.1",
35
35
  "@phenomnomnominal/tsquery": "~5.0.1",
36
- "@nrwl/remix": "17.3.0-beta.3"
36
+ "@nrwl/remix": "17.3.0-beta.5"
37
37
  },
38
38
  "peerDependencies": {},
39
39
  "publishConfig": {
40
40
  "access": "public"
41
41
  },
42
42
  "exports": {
43
- "./package.json": "./package.json",
44
43
  ".": "./index.js",
44
+ "./plugin": "./plugin.js",
45
+ "./package.json": "./package.json",
45
46
  "./executors.json": "./executors.json",
46
47
  "./generators.json": "./generators.json",
47
48
  "./migrations.json": "./migrations.json",
package/plugin.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { createNodes, createDependencies, RemixPluginOptions, } from './src/plugins/plugin';
package/plugin.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createDependencies = 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; } });
6
+ Object.defineProperty(exports, "createDependencies", { enumerable: true, get: function () { return plugin_1.createDependencies; } });
@@ -21,10 +21,6 @@
21
21
  "project": {
22
22
  "type": "string",
23
23
  "description": "The name of the project.",
24
- "$default": {
25
- "$source": "projectName"
26
- },
27
- "x-prompt": "What project is this route for?",
28
24
  "pattern": "^[a-zA-Z].*$",
29
25
  "x-deprecated": "Provide the `path` option instead and use the `as-provided` format. The project will be determined from the path provided. It will be removed in Nx v18."
30
26
  }
@@ -1,16 +1,22 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`Remix Application Integrated Repo --projectNameAndRootFormat=as-provided --directory should create the application correctly 1`] = `
4
- "/**
4
+ "import { createWatchPaths } from '@nx/remix';
5
+ import { dirname } from 'path';
6
+ import { fileURLToPath } from 'url';
7
+
8
+ const __dirname = dirname(fileURLToPath(import.meta.url));
9
+
10
+ /**
5
11
  * @type {import('@remix-run/dev').AppConfig}
6
12
  */
7
- module.exports = {
13
+ export default {
8
14
  ignoredRouteFiles: ['**/.*'],
9
15
  // appDirectory: "app",
10
16
  // assetsBuildDirectory: "public/build",
11
17
  // serverBuildPath: "build/index.js",
12
18
  // publicPath: "/build/",
13
- watchPaths: () => require('@nx/remix').createWatchPaths(__dirname),
19
+ watchPaths: () => createWatchPaths(__dirname),
14
20
  };
15
21
  "
16
22
  `;
@@ -90,16 +96,22 @@ exports[`Remix Application Integrated Repo --projectNameAndRootFormat=as-provide
90
96
  `;
91
97
 
92
98
  exports[`Remix Application Integrated Repo --projectNameAndRootFormat=as-provided --directory should extract the layout directory from the directory options if it exists 1`] = `
93
- "/**
99
+ "import { createWatchPaths } from '@nx/remix';
100
+ import { dirname } from 'path';
101
+ import { fileURLToPath } from 'url';
102
+
103
+ const __dirname = dirname(fileURLToPath(import.meta.url));
104
+
105
+ /**
94
106
  * @type {import('@remix-run/dev').AppConfig}
95
107
  */
96
- module.exports = {
108
+ export default {
97
109
  ignoredRouteFiles: ['**/.*'],
98
110
  // appDirectory: "app",
99
111
  // assetsBuildDirectory: "public/build",
100
112
  // serverBuildPath: "build/index.js",
101
113
  // publicPath: "/build/",
102
- watchPaths: () => require('@nx/remix').createWatchPaths(__dirname),
114
+ watchPaths: () => createWatchPaths(__dirname),
103
115
  };
104
116
  "
105
117
  `;
@@ -193,16 +205,22 @@ export default defineConfig({
193
205
  `;
194
206
 
195
207
  exports[`Remix Application Integrated Repo --projectNameAndRootFormat=as-provided --js should create the application correctly 1`] = `
196
- "/**
208
+ "import { createWatchPaths } from '@nx/remix';
209
+ import { dirname } from 'path';
210
+ import { fileURLToPath } from 'url';
211
+
212
+ const __dirname = dirname(fileURLToPath(import.meta.url));
213
+
214
+ /**
197
215
  * @type {import('@remix-run/dev').AppConfig}
198
216
  */
199
- module.exports = {
217
+ export default {
200
218
  ignoredRouteFiles: ['**/.*'],
201
219
  // appDirectory: "app",
202
220
  // assetsBuildDirectory: "public/build",
203
221
  // serverBuildPath: "build/index.js",
204
222
  // publicPath: "/build/",
205
- watchPaths: () => require('@nx/remix').createWatchPaths(__dirname),
223
+ watchPaths: () => createWatchPaths(__dirname),
206
224
  };
207
225
  "
208
226
  `;
@@ -279,16 +297,22 @@ exports[`Remix Application Integrated Repo --projectNameAndRootFormat=as-provide
279
297
  `;
280
298
 
281
299
  exports[`Remix Application Integrated Repo --projectNameAndRootFormat=as-provided --unitTestRunner should generate the correct files for testing using jest 1`] = `
282
- "/**
300
+ "import { createWatchPaths } from '@nx/remix';
301
+ import { dirname } from 'path';
302
+ import { fileURLToPath } from 'url';
303
+
304
+ const __dirname = dirname(fileURLToPath(import.meta.url));
305
+
306
+ /**
283
307
  * @type {import('@remix-run/dev').AppConfig}
284
308
  */
285
- module.exports = {
309
+ export default {
286
310
  ignoredRouteFiles: ['**/.*'],
287
311
  // appDirectory: "app",
288
312
  // assetsBuildDirectory: "public/build",
289
313
  // serverBuildPath: "build/index.js",
290
314
  // publicPath: "/build/",
291
- watchPaths: () => require('@nx/remix').createWatchPaths(__dirname),
315
+ watchPaths: () => createWatchPaths(__dirname),
292
316
  };
293
317
  "
294
318
  `;
@@ -316,16 +340,22 @@ installGlobals();
316
340
  `;
317
341
 
318
342
  exports[`Remix Application Integrated Repo --projectNameAndRootFormat=as-provided --unitTestRunner should generate the correct files for testing using vitest 1`] = `
319
- "/**
343
+ "import { createWatchPaths } from '@nx/remix';
344
+ import { dirname } from 'path';
345
+ import { fileURLToPath } from 'url';
346
+
347
+ const __dirname = dirname(fileURLToPath(import.meta.url));
348
+
349
+ /**
320
350
  * @type {import('@remix-run/dev').AppConfig}
321
351
  */
322
- module.exports = {
352
+ export default {
323
353
  ignoredRouteFiles: ['**/.*'],
324
354
  // appDirectory: "app",
325
355
  // assetsBuildDirectory: "public/build",
326
356
  // serverBuildPath: "build/index.js",
327
357
  // publicPath: "/build/",
328
- watchPaths: () => require('@nx/remix').createWatchPaths(__dirname),
358
+ watchPaths: () => createWatchPaths(__dirname),
329
359
  };
330
360
  "
331
361
  `;
@@ -374,16 +404,22 @@ installGlobals();
374
404
  `;
375
405
 
376
406
  exports[`Remix Application Integrated Repo --projectNameAndRootFormat=as-provided should create the application correctly 1`] = `
377
- "/**
407
+ "import { createWatchPaths } from '@nx/remix';
408
+ import { dirname } from 'path';
409
+ import { fileURLToPath } from 'url';
410
+
411
+ const __dirname = dirname(fileURLToPath(import.meta.url));
412
+
413
+ /**
378
414
  * @type {import('@remix-run/dev').AppConfig}
379
415
  */
380
- module.exports = {
416
+ export default {
381
417
  ignoredRouteFiles: ['**/.*'],
382
418
  // appDirectory: "app",
383
419
  // assetsBuildDirectory: "public/build",
384
420
  // serverBuildPath: "build/index.js",
385
421
  // publicPath: "/build/",
386
- watchPaths: () => require('@nx/remix').createWatchPaths(__dirname),
422
+ watchPaths: () => createWatchPaths(__dirname),
387
423
  };
388
424
  "
389
425
  `;
@@ -463,16 +499,22 @@ exports[`Remix Application Integrated Repo --projectNameAndRootFormat=as-provide
463
499
  `;
464
500
 
465
501
  exports[`Remix Application Integrated Repo --projectNameAndRootFormat=derived --directory should create the application correctly 1`] = `
466
- "/**
502
+ "import { createWatchPaths } from '@nx/remix';
503
+ import { dirname } from 'path';
504
+ import { fileURLToPath } from 'url';
505
+
506
+ const __dirname = dirname(fileURLToPath(import.meta.url));
507
+
508
+ /**
467
509
  * @type {import('@remix-run/dev').AppConfig}
468
510
  */
469
- module.exports = {
511
+ export default {
470
512
  ignoredRouteFiles: ['**/.*'],
471
513
  // appDirectory: "app",
472
514
  // assetsBuildDirectory: "public/build",
473
515
  // serverBuildPath: "build/index.js",
474
516
  // publicPath: "/build/",
475
- watchPaths: () => require('@nx/remix').createWatchPaths(__dirname),
517
+ watchPaths: () => createWatchPaths(__dirname),
476
518
  };
477
519
  "
478
520
  `;
@@ -552,16 +594,22 @@ exports[`Remix Application Integrated Repo --projectNameAndRootFormat=derived --
552
594
  `;
553
595
 
554
596
  exports[`Remix Application Integrated Repo --projectNameAndRootFormat=derived --directory should extract the layout directory from the directory options if it exists 1`] = `
555
- "/**
597
+ "import { createWatchPaths } from '@nx/remix';
598
+ import { dirname } from 'path';
599
+ import { fileURLToPath } from 'url';
600
+
601
+ const __dirname = dirname(fileURLToPath(import.meta.url));
602
+
603
+ /**
556
604
  * @type {import('@remix-run/dev').AppConfig}
557
605
  */
558
- module.exports = {
606
+ export default {
559
607
  ignoredRouteFiles: ['**/.*'],
560
608
  // appDirectory: "app",
561
609
  // assetsBuildDirectory: "public/build",
562
610
  // serverBuildPath: "build/index.js",
563
611
  // publicPath: "/build/",
564
- watchPaths: () => require('@nx/remix').createWatchPaths(__dirname),
612
+ watchPaths: () => createWatchPaths(__dirname),
565
613
  };
566
614
  "
567
615
  `;
@@ -655,16 +703,22 @@ export default defineConfig({
655
703
  `;
656
704
 
657
705
  exports[`Remix Application Integrated Repo --projectNameAndRootFormat=derived --js should create the application correctly 1`] = `
658
- "/**
706
+ "import { createWatchPaths } from '@nx/remix';
707
+ import { dirname } from 'path';
708
+ import { fileURLToPath } from 'url';
709
+
710
+ const __dirname = dirname(fileURLToPath(import.meta.url));
711
+
712
+ /**
659
713
  * @type {import('@remix-run/dev').AppConfig}
660
714
  */
661
- module.exports = {
715
+ export default {
662
716
  ignoredRouteFiles: ['**/.*'],
663
717
  // appDirectory: "app",
664
718
  // assetsBuildDirectory: "public/build",
665
719
  // serverBuildPath: "build/index.js",
666
720
  // publicPath: "/build/",
667
- watchPaths: () => require('@nx/remix').createWatchPaths(__dirname),
721
+ watchPaths: () => createWatchPaths(__dirname),
668
722
  };
669
723
  "
670
724
  `;
@@ -741,16 +795,22 @@ exports[`Remix Application Integrated Repo --projectNameAndRootFormat=derived --
741
795
  `;
742
796
 
743
797
  exports[`Remix Application Integrated Repo --projectNameAndRootFormat=derived --unitTestRunner should generate the correct files for testing using jest 1`] = `
744
- "/**
798
+ "import { createWatchPaths } from '@nx/remix';
799
+ import { dirname } from 'path';
800
+ import { fileURLToPath } from 'url';
801
+
802
+ const __dirname = dirname(fileURLToPath(import.meta.url));
803
+
804
+ /**
745
805
  * @type {import('@remix-run/dev').AppConfig}
746
806
  */
747
- module.exports = {
807
+ export default {
748
808
  ignoredRouteFiles: ['**/.*'],
749
809
  // appDirectory: "app",
750
810
  // assetsBuildDirectory: "public/build",
751
811
  // serverBuildPath: "build/index.js",
752
812
  // publicPath: "/build/",
753
- watchPaths: () => require('@nx/remix').createWatchPaths(__dirname),
813
+ watchPaths: () => createWatchPaths(__dirname),
754
814
  };
755
815
  "
756
816
  `;
@@ -778,16 +838,22 @@ installGlobals();
778
838
  `;
779
839
 
780
840
  exports[`Remix Application Integrated Repo --projectNameAndRootFormat=derived --unitTestRunner should generate the correct files for testing using vitest 1`] = `
781
- "/**
841
+ "import { createWatchPaths } from '@nx/remix';
842
+ import { dirname } from 'path';
843
+ import { fileURLToPath } from 'url';
844
+
845
+ const __dirname = dirname(fileURLToPath(import.meta.url));
846
+
847
+ /**
782
848
  * @type {import('@remix-run/dev').AppConfig}
783
849
  */
784
- module.exports = {
850
+ export default {
785
851
  ignoredRouteFiles: ['**/.*'],
786
852
  // appDirectory: "app",
787
853
  // assetsBuildDirectory: "public/build",
788
854
  // serverBuildPath: "build/index.js",
789
855
  // publicPath: "/build/",
790
- watchPaths: () => require('@nx/remix').createWatchPaths(__dirname),
856
+ watchPaths: () => createWatchPaths(__dirname),
791
857
  };
792
858
  "
793
859
  `;
@@ -836,16 +902,22 @@ installGlobals();
836
902
  `;
837
903
 
838
904
  exports[`Remix Application Integrated Repo --projectNameAndRootFormat=derived should create the application correctly 1`] = `
839
- "/**
905
+ "import { createWatchPaths } from '@nx/remix';
906
+ import { dirname } from 'path';
907
+ import { fileURLToPath } from 'url';
908
+
909
+ const __dirname = dirname(fileURLToPath(import.meta.url));
910
+
911
+ /**
840
912
  * @type {import('@remix-run/dev').AppConfig}
841
913
  */
842
- module.exports = {
914
+ export default {
843
915
  ignoredRouteFiles: ['**/.*'],
844
916
  // appDirectory: "app",
845
917
  // assetsBuildDirectory: "public/build",
846
918
  // serverBuildPath: "build/index.js",
847
919
  // publicPath: "/build/",
848
- watchPaths: () => require('@nx/remix').createWatchPaths(__dirname),
920
+ watchPaths: () => createWatchPaths(__dirname),
849
921
  };
850
922
  "
851
923
  `;
@@ -939,16 +1011,22 @@ export default defineConfig({
939
1011
  `;
940
1012
 
941
1013
  exports[`Remix Application Standalone Project Repo --js should create the application correctly 1`] = `
942
- "/**
1014
+ "import { createWatchPaths } from '@nx/remix';
1015
+ import { dirname } from 'path';
1016
+ import { fileURLToPath } from 'url';
1017
+
1018
+ const __dirname = dirname(fileURLToPath(import.meta.url));
1019
+
1020
+ /**
943
1021
  * @type {import('@remix-run/dev').AppConfig}
944
1022
  */
945
- module.exports = {
1023
+ export default {
946
1024
  ignoredRouteFiles: ['**/.*'],
947
1025
  // appDirectory: "app",
948
1026
  // assetsBuildDirectory: "public/build",
949
1027
  // serverBuildPath: "build/index.js",
950
1028
  // publicPath: "/build/",
951
- watchPaths: () => require('@nx/remix').createWatchPaths(__dirname),
1029
+ watchPaths: () => createWatchPaths(__dirname),
952
1030
  };
953
1031
  "
954
1032
  `;
@@ -1025,16 +1103,22 @@ exports[`Remix Application Standalone Project Repo --js should create the applic
1025
1103
  `;
1026
1104
 
1027
1105
  exports[`Remix Application Standalone Project Repo --unitTestRunner should generate the correct files for testing using jest 1`] = `
1028
- "/**
1106
+ "import { createWatchPaths } from '@nx/remix';
1107
+ import { dirname } from 'path';
1108
+ import { fileURLToPath } from 'url';
1109
+
1110
+ const __dirname = dirname(fileURLToPath(import.meta.url));
1111
+
1112
+ /**
1029
1113
  * @type {import('@remix-run/dev').AppConfig}
1030
1114
  */
1031
- module.exports = {
1115
+ export default {
1032
1116
  ignoredRouteFiles: ['**/.*'],
1033
1117
  // appDirectory: "app",
1034
1118
  // assetsBuildDirectory: "public/build",
1035
1119
  // serverBuildPath: "build/index.js",
1036
1120
  // publicPath: "/build/",
1037
- watchPaths: () => require('@nx/remix').createWatchPaths(__dirname),
1121
+ watchPaths: () => createWatchPaths(__dirname),
1038
1122
  };
1039
1123
  "
1040
1124
  `;
@@ -1086,16 +1170,22 @@ test('renders loader data', async () => {
1086
1170
  `;
1087
1171
 
1088
1172
  exports[`Remix Application Standalone Project Repo --unitTestRunner should generate the correct files for testing using vitest 1`] = `
1089
- "/**
1173
+ "import { createWatchPaths } from '@nx/remix';
1174
+ import { dirname } from 'path';
1175
+ import { fileURLToPath } from 'url';
1176
+
1177
+ const __dirname = dirname(fileURLToPath(import.meta.url));
1178
+
1179
+ /**
1090
1180
  * @type {import('@remix-run/dev').AppConfig}
1091
1181
  */
1092
- module.exports = {
1182
+ export default {
1093
1183
  ignoredRouteFiles: ['**/.*'],
1094
1184
  // appDirectory: "app",
1095
1185
  // assetsBuildDirectory: "public/build",
1096
1186
  // serverBuildPath: "build/index.js",
1097
1187
  // publicPath: "/build/",
1098
- watchPaths: () => require('@nx/remix').createWatchPaths(__dirname),
1188
+ watchPaths: () => createWatchPaths(__dirname),
1099
1189
  };
1100
1190
  "
1101
1191
  `;
@@ -1164,16 +1254,22 @@ installGlobals();
1164
1254
  `;
1165
1255
 
1166
1256
  exports[`Remix Application Standalone Project Repo should create the application correctly 1`] = `
1167
- "/**
1257
+ "import { createWatchPaths } from '@nx/remix';
1258
+ import { dirname } from 'path';
1259
+ import { fileURLToPath } from 'url';
1260
+
1261
+ const __dirname = dirname(fileURLToPath(import.meta.url));
1262
+
1263
+ /**
1168
1264
  * @type {import('@remix-run/dev').AppConfig}
1169
1265
  */
1170
- module.exports = {
1266
+ export default {
1171
1267
  ignoredRouteFiles: ['**/.*'],
1172
1268
  // appDirectory: "app",
1173
1269
  // assetsBuildDirectory: "public/build",
1174
1270
  // serverBuildPath: "build/index.js",
1175
1271
  // publicPath: "/build/",
1176
- watchPaths: () => require('@nx/remix').createWatchPaths(__dirname),
1272
+ watchPaths: () => createWatchPaths(__dirname),
1177
1273
  };
1178
1274
  "
1179
1275
  `;
@@ -4,9 +4,15 @@ const devkit_1 = require("@nx/devkit");
4
4
  const create_ts_config_1 = require("@nx/js/src/utils/typescript/create-ts-config");
5
5
  const versions_1 = require("../../utils/versions");
6
6
  const lib_1 = require("./lib");
7
+ const update_dependencies_1 = require("../utils/update-dependencies");
8
+ const init_1 = require("../init/init");
9
+ const js_1 = require("@nx/js");
7
10
  async function default_1(tree, _options) {
8
11
  const options = await (0, lib_1.normalizeOptions)(tree, _options);
9
- const tasks = [];
12
+ const tasks = [
13
+ await (0, init_1.default)(tree, { skipFormat: true }),
14
+ await (0, js_1.initGenerator)(tree, { skipFormat: true }),
15
+ ];
10
16
  (0, devkit_1.addProjectConfiguration)(tree, options.projectName, {
11
17
  root: options.projectRoot,
12
18
  sourceRoot: `${options.projectRoot}`,
@@ -43,21 +49,7 @@ async function default_1(tree, _options) {
43
49
  },
44
50
  },
45
51
  });
46
- const installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {
47
- '@remix-run/node': versions_1.remixVersion,
48
- '@remix-run/react': versions_1.remixVersion,
49
- '@remix-run/serve': versions_1.remixVersion,
50
- isbot: versions_1.isbotVersion,
51
- react: versions_1.reactVersion,
52
- 'react-dom': versions_1.reactDomVersion,
53
- }, {
54
- '@remix-run/dev': versions_1.remixVersion,
55
- '@remix-run/eslint-config': versions_1.remixVersion,
56
- '@types/react': versions_1.typesReactVersion,
57
- '@types/react-dom': versions_1.typesReactDomVersion,
58
- eslint: versions_1.eslintVersion,
59
- typescript: versions_1.typescriptVersion,
60
- });
52
+ const installTask = (0, update_dependencies_1.updateDependencies)(tree);
61
53
  tasks.push(installTask);
62
54
  const vars = {
63
55
  ...options,
@@ -82,7 +74,7 @@ async function default_1(tree, _options) {
82
74
  }
83
75
  if (options.unitTestRunner !== 'none') {
84
76
  if (options.unitTestRunner === 'vitest') {
85
- const { vitestGenerator } = (0, devkit_1.ensurePackage)('@nx/vite', (0, versions_1.getPackageVersion)(tree, 'nx'));
77
+ const { vitestGenerator, createOrEditViteConfig } = (0, devkit_1.ensurePackage)('@nx/vite', (0, versions_1.getPackageVersion)(tree, 'nx'));
86
78
  const vitestTask = await vitestGenerator(tree, {
87
79
  uiFramework: 'react',
88
80
  project: options.projectName,
@@ -90,7 +82,16 @@ async function default_1(tree, _options) {
90
82
  inSourceTests: false,
91
83
  skipFormat: true,
92
84
  testEnvironment: 'jsdom',
85
+ skipViteConfig: true,
93
86
  });
87
+ createOrEditViteConfig(tree, {
88
+ project: options.projectName,
89
+ includeLib: false,
90
+ includeVitest: true,
91
+ testEnvironment: 'jsdom',
92
+ imports: [`import react from '@vitejs/plugin-react';`],
93
+ plugins: [`react()`],
94
+ }, true, undefined, true);
94
95
  tasks.push(vitestTask);
95
96
  }
96
97
  else {
@@ -0,0 +1,17 @@
1
+ import {createWatchPaths} from '@nx/remix';
2
+ import {dirname} from 'path';
3
+ import {fileURLToPath} from 'url';
4
+
5
+ const __dirname = dirname(fileURLToPath(import.meta.url));
6
+
7
+ /**
8
+ * @type {import('@remix-run/dev').AppConfig}
9
+ */
10
+ export default {
11
+ ignoredRouteFiles: ["**/.*"],
12
+ // appDirectory: "app",
13
+ // assetsBuildDirectory: "public/build",
14
+ // serverBuildPath: "build/index.js",
15
+ // publicPath: "/build/",
16
+ watchPaths: () => createWatchPaths(__dirname),
17
+ };
@@ -11,10 +11,10 @@ function updateUnitTestConfig(tree, pathToRoot, unitTestRunner) {
11
11
  import '@testing-library/jest-dom/matchers';
12
12
  installGlobals();`);
13
13
  if (unitTestRunner === 'vitest') {
14
- const pathToViteConfig = (0, devkit_1.joinPathFragments)(pathToRoot, 'vite.config.ts');
15
- (0, testing_config_utils_1.updateViteTestIncludes)(tree, pathToViteConfig, './app/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}');
16
- (0, testing_config_utils_1.updateViteTestIncludes)(tree, pathToViteConfig, './tests/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}');
17
- (0, testing_config_utils_1.updateViteTestSetup)(tree, pathToViteConfig, 'test-setup.ts');
14
+ const pathToViteConfig = (0, devkit_1.joinPathFragments)(pathToRoot, 'vitest.config.ts');
15
+ (0, testing_config_utils_1.updateVitestTestIncludes)(tree, pathToViteConfig, './app/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}');
16
+ (0, testing_config_utils_1.updateVitestTestIncludes)(tree, pathToViteConfig, './tests/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}');
17
+ (0, testing_config_utils_1.updateVitestTestSetup)(tree, pathToViteConfig, 'test-setup.ts');
18
18
  }
19
19
  else if (unitTestRunner === 'jest') {
20
20
  const pathToJestConfig = (0, devkit_1.joinPathFragments)(pathToRoot, 'jest.config.ts');
@@ -23,10 +23,6 @@
23
23
  "project": {
24
24
  "type": "string",
25
25
  "description": "The name of the project.",
26
- "$default": {
27
- "$source": "projectName"
28
- },
29
- "x-prompt": "What project contains the route file that this ErrorBoundary is for?",
30
26
  "pattern": "^[a-zA-Z].*$",
31
27
  "x-deprecated": "Provide the `path` option instead and use the `as-provided` format. The project will be determined from the path provided. It will be removed in Nx v18."
32
28
  },
@@ -0,0 +1,4 @@
1
+ import { type Tree, GeneratorCallback } from '@nx/devkit';
2
+ import { type Schema } from './schema';
3
+ export declare function remixInitGenerator(tree: Tree, options: Schema): Promise<GeneratorCallback>;
4
+ export default remixInitGenerator;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.remixInitGenerator = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const versions_1 = require("../../utils/versions");
6
+ function addPlugin(tree) {
7
+ const nxJson = (0, devkit_1.readNxJson)(tree);
8
+ nxJson.plugins ??= [];
9
+ for (const plugin of nxJson.plugins) {
10
+ if (typeof plugin === 'string'
11
+ ? plugin === '@nx/remix/plugin'
12
+ : plugin.plugin === '@nx/remix/plugin') {
13
+ return;
14
+ }
15
+ }
16
+ nxJson.plugins.push({
17
+ plugin: '@nx/remix/plugin',
18
+ options: {
19
+ buildTargetName: 'build',
20
+ serveTargetName: 'serve',
21
+ startTargetName: 'start',
22
+ typecheckTargetName: 'typecheck',
23
+ },
24
+ });
25
+ (0, devkit_1.updateNxJson)(tree, nxJson);
26
+ }
27
+ async function remixInitGenerator(tree, options) {
28
+ const tasks = [];
29
+ if (!options.skipPackageJson) {
30
+ const installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {
31
+ '@remix-run/serve': versions_1.remixVersion,
32
+ }, {
33
+ '@remix-run/dev': versions_1.remixVersion,
34
+ });
35
+ tasks.push(installTask);
36
+ }
37
+ if (process.env.NX_PCV3 === 'true') {
38
+ addPlugin(tree);
39
+ }
40
+ if (!options.skipFormat) {
41
+ await (0, devkit_1.formatFiles)(tree);
42
+ }
43
+ return (0, devkit_1.runTasksInSerial)(...tasks);
44
+ }
45
+ exports.remixInitGenerator = remixInitGenerator;
46
+ exports.default = remixInitGenerator;
@@ -0,0 +1,4 @@
1
+ export interface Schema {
2
+ skipFormat?: boolean;
3
+ skipPackageJson?: boolean;
4
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "$id": "NxRemixInit",
4
+ "title": "Init Remix Plugin",
5
+ "description": "Initialize the Remix Plugin.",
6
+ "cli": "nx",
7
+ "type": "object",
8
+ "properties": {
9
+ "skipFormat": {
10
+ "description": "Skip formatting files.",
11
+ "type": "boolean",
12
+ "default": false
13
+ },
14
+ "skipPackageJson": {
15
+ "description": "Do not add dependencies to `package.json`.",
16
+ "type": "boolean",
17
+ "default": false
18
+ }
19
+ },
20
+ "required": []
21
+ }
@@ -16,7 +16,7 @@ function addUnitTestingSetup(tree, options) {
16
16
  installGlobals();`);
17
17
  if (options.unitTestRunner === 'vitest') {
18
18
  const pathToVitestConfig = (0, devkit_1.joinPathFragments)(options.projectRoot, `vite.config.ts`);
19
- (0, testing_config_utils_1.updateViteTestSetup)(tree, pathToVitestConfig, './src/test-setup.ts');
19
+ (0, testing_config_utils_1.updateVitestTestSetup)(tree, pathToVitestConfig, './src/test-setup.ts');
20
20
  }
21
21
  else if (options.unitTestRunner === 'jest') {
22
22
  const pathToJestConfig = (0, devkit_1.joinPathFragments)(options.projectRoot, `jest.config.ts`);
@@ -21,10 +21,6 @@
21
21
  "project": {
22
22
  "type": "string",
23
23
  "description": "The name of the project.",
24
- "$default": {
25
- "$source": "projectName"
26
- },
27
- "x-prompt": "What project is this route for?",
28
24
  "pattern": "^[a-zA-Z].*$",
29
25
  "x-deprecated": "Provide the `path` option instead and use the `as-provided` format. The project will be determined from the path provided. It will be removed in Nx v18."
30
26
  }
@@ -21,10 +21,6 @@
21
21
  "project": {
22
22
  "type": "string",
23
23
  "description": "The name of the project.",
24
- "$default": {
25
- "$source": "projectName"
26
- },
27
- "x-prompt": "What project is this route for?",
28
24
  "pattern": "^[a-zA-Z].*$",
29
25
  "x-deprecated": "Provide the `path` option instead and use the `as-provided` format. The project will be determined from the path provided. It will be removed in Nx v18."
30
26
  }
@@ -28,10 +28,6 @@
28
28
  "project": {
29
29
  "type": "string",
30
30
  "description": "The name of the project.",
31
- "$default": {
32
- "$source": "projectName"
33
- },
34
- "x-prompt": "What project is this route for?",
35
31
  "pattern": "^[a-zA-Z].*$",
36
32
  "x-deprecated": "Provide the `path` option instead and use the `as-provided` format. The project will be determined from the path provided. It will be removed in Nx v18."
37
33
  },
@@ -70,6 +70,7 @@ async function default_1(tree, options) {
70
70
  await (0, style_impl_1.default)(tree, {
71
71
  project: projectName,
72
72
  path: routeFilePath,
73
+ nameAndDirectoryFormat: 'as-provided',
73
74
  });
74
75
  }
75
76
  await (0, devkit_1.formatFiles)(tree);
@@ -28,10 +28,6 @@
28
28
  "project": {
29
29
  "type": "string",
30
30
  "description": "The name of the project.",
31
- "$default": {
32
- "$source": "projectName"
33
- },
34
- "x-prompt": "What project is this route for?",
35
31
  "pattern": "^[a-zA-Z].*$",
36
32
  "x-deprecated": "Provide the `path` option instead and use the `as-provided` format. The project will be determined from the path provided. It will be removed in Nx v18."
37
33
  },
@@ -60,17 +60,23 @@ export default function App() {
60
60
  `;
61
61
 
62
62
  exports[`setup-tailwind generator should add a js tailwind config to an application correctly 4`] = `
63
- "/**
63
+ "import { createWatchPaths } from '@nx/remix';
64
+ import { dirname } from 'path';
65
+ import { fileURLToPath } from 'url';
66
+
67
+ const __dirname = dirname(fileURLToPath(import.meta.url));
68
+
69
+ /**
64
70
  * @type {import('@remix-run/dev').AppConfig}
65
71
  */
66
- module.exports = {
72
+ export default {
67
73
  tailwind: true,
68
74
  ignoredRouteFiles: ['**/.*'],
69
75
  // appDirectory: "app",
70
76
  // assetsBuildDirectory: "public/build",
71
77
  // serverBuildPath: "build/index.js",
72
78
  // publicPath: "/build/",
73
- watchPaths: () => require('@nx/remix').createWatchPaths(__dirname),
79
+ watchPaths: () => createWatchPaths(__dirname),
74
80
  };
75
81
  "
76
82
  `;
@@ -140,17 +146,23 @@ export default function App() {
140
146
  `;
141
147
 
142
148
  exports[`setup-tailwind generator should add a tailwind config to an application correctly 4`] = `
143
- "/**
149
+ "import { createWatchPaths } from '@nx/remix';
150
+ import { dirname } from 'path';
151
+ import { fileURLToPath } from 'url';
152
+
153
+ const __dirname = dirname(fileURLToPath(import.meta.url));
154
+
155
+ /**
144
156
  * @type {import('@remix-run/dev').AppConfig}
145
157
  */
146
- module.exports = {
158
+ export default {
147
159
  tailwind: true,
148
160
  ignoredRouteFiles: ['**/.*'],
149
161
  // appDirectory: "app",
150
162
  // assetsBuildDirectory: "public/build",
151
163
  // serverBuildPath: "build/index.js",
152
164
  // publicPath: "/build/",
153
- watchPaths: () => require('@nx/remix').createWatchPaths(__dirname),
165
+ watchPaths: () => createWatchPaths(__dirname),
154
166
  };
155
167
  "
156
168
  `;
@@ -1,15 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateRemixConfig = void 0;
4
- const devkit_1 = require("@nx/devkit");
5
4
  const tsquery_1 = require("@phenomnomnominal/tsquery");
5
+ const remix_config_1 = require("../../../utils/remix-config");
6
6
  function updateRemixConfig(tree, projectRoot) {
7
- const pathToRemixConfig = (0, devkit_1.joinPathFragments)(projectRoot, 'remix.config.cjs');
8
- if (!tree.exists(pathToRemixConfig)) {
9
- throw new Error(`Could not find "${pathToRemixConfig}". Please ensure a "remix.config.cjs" exists at the root of your project.`);
10
- }
7
+ const pathToRemixConfig = (0, remix_config_1.getRemixConfigPathFromProjectRoot)(tree, projectRoot);
11
8
  const fileContents = tree.read(pathToRemixConfig, 'utf-8');
12
- const REMIX_CONFIG_OBJECT_SELECTOR = 'PropertyAccessExpression:has(Identifier[name=module], Identifier[name=exports])~ObjectLiteralExpression';
9
+ const REMIX_CONFIG_OBJECT_SELECTOR = 'ObjectLiteralExpression';
13
10
  const ast = tsquery_1.tsquery.ast(fileContents);
14
11
  const nodes = (0, tsquery_1.tsquery)(ast, REMIX_CONFIG_OBJECT_SELECTOR, {
15
12
  visitAllChildren: true,
@@ -28,10 +28,6 @@
28
28
  "project": {
29
29
  "type": "string",
30
30
  "description": "The name of the project.",
31
- "$default": {
32
- "$source": "projectName"
33
- },
34
- "x-prompt": "What project is this route in?",
35
31
  "pattern": "^[a-zA-Z].*$",
36
32
  "x-deprecated": "Provide the `path` option instead and use the `as-provided` format. The project will be determined from the path provided. It will be removed in Nx v18."
37
33
  }
@@ -0,0 +1,2 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export declare function updateDependencies(tree: Tree): import("@nx/devkit").GeneratorCallback;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateDependencies = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const versions_1 = require("../../utils/versions");
6
+ function updateDependencies(tree) {
7
+ return (0, devkit_1.addDependenciesToPackageJson)(tree, {
8
+ '@remix-run/node': versions_1.remixVersion,
9
+ '@remix-run/react': versions_1.remixVersion,
10
+ isbot: versions_1.isbotVersion,
11
+ react: versions_1.reactVersion,
12
+ 'react-dom': versions_1.reactDomVersion,
13
+ }, {
14
+ '@remix-run/eslint-config': versions_1.remixVersion,
15
+ '@types/react': versions_1.typesReactVersion,
16
+ '@types/react-dom': versions_1.typesReactDomVersion,
17
+ eslint: versions_1.eslintVersion,
18
+ typescript: versions_1.typescriptVersion,
19
+ });
20
+ }
21
+ exports.updateDependencies = updateDependencies;
@@ -0,0 +1,111 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`@nx/remix/plugin non-root project should create nodes 1`] = `
4
+ {
5
+ "projects": {
6
+ "my-app": {
7
+ "root": "my-app",
8
+ "targets": {
9
+ "build": {
10
+ "cache": true,
11
+ "dependsOn": [
12
+ "^build",
13
+ ],
14
+ "executor": "@nx/remix:build",
15
+ "inputs": [
16
+ "production",
17
+ "^production",
18
+ ],
19
+ "options": {
20
+ "outputPath": "{workspaceRoot}/dist",
21
+ },
22
+ "outputs": [
23
+ "{options.outputPath}",
24
+ ],
25
+ },
26
+ "serve": {
27
+ "executor": "@nx/remix:serve",
28
+ "options": {
29
+ "command": "npx remix-serve build/index.js",
30
+ },
31
+ },
32
+ "start": {
33
+ "command": "npx remix-serve build/index.js",
34
+ "dependsOn": [
35
+ "build",
36
+ ],
37
+ "options": {
38
+ "cwd": "my-app",
39
+ },
40
+ },
41
+ "tsc": {
42
+ "cache": true,
43
+ "command": "tsc",
44
+ "inputs": [
45
+ "production",
46
+ "^production",
47
+ ],
48
+ "options": {
49
+ "cwd": "my-app",
50
+ },
51
+ },
52
+ },
53
+ },
54
+ },
55
+ }
56
+ `;
57
+
58
+ exports[`@nx/remix/plugin root project should create nodes 1`] = `
59
+ {
60
+ "projects": {
61
+ ".": {
62
+ "root": ".",
63
+ "targets": {
64
+ "build": {
65
+ "cache": true,
66
+ "dependsOn": [
67
+ "^build",
68
+ ],
69
+ "executor": "@nx/remix:build",
70
+ "inputs": [
71
+ "production",
72
+ "^production",
73
+ ],
74
+ "options": {
75
+ "outputPath": "{workspaceRoot}/dist",
76
+ },
77
+ "outputs": [
78
+ "{options.outputPath}",
79
+ ],
80
+ },
81
+ "serve": {
82
+ "executor": "@nx/remix:serve",
83
+ "options": {
84
+ "command": "npx remix-serve build/index.js",
85
+ },
86
+ },
87
+ "start": {
88
+ "command": "npx remix-serve build/index.js",
89
+ "dependsOn": [
90
+ "build",
91
+ ],
92
+ "options": {
93
+ "cwd": ".",
94
+ },
95
+ },
96
+ "typecheck": {
97
+ "cache": true,
98
+ "command": "tsc",
99
+ "inputs": [
100
+ "production",
101
+ "^production",
102
+ ],
103
+ "options": {
104
+ "cwd": ".",
105
+ },
106
+ },
107
+ },
108
+ },
109
+ },
110
+ }
111
+ `;
@@ -0,0 +1,9 @@
1
+ import { type CreateDependencies, type CreateNodes } from '@nx/devkit';
2
+ export declare const createDependencies: CreateDependencies;
3
+ export interface RemixPluginOptions {
4
+ buildTargetName?: string;
5
+ serveTargetName?: string;
6
+ startTargetName?: string;
7
+ typecheckTargetName?: string;
8
+ }
9
+ export declare const createNodes: CreateNodes<RemixPluginOptions>;
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createNodes = exports.createDependencies = void 0;
4
+ const cache_directory_1 = require("nx/src/utils/cache-directory");
5
+ const devkit_1 = require("@nx/devkit");
6
+ const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
7
+ const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
8
+ const js_1 = require("@nx/js");
9
+ const path_1 = require("path");
10
+ const fs_1 = require("fs");
11
+ const cachePath = (0, path_1.join)(cache_directory_1.projectGraphCacheDirectory, 'remix.hash');
12
+ const targetsCache = (0, fs_1.existsSync)(cachePath) ? readTargetsCache() : {};
13
+ const calculatedTargets = {};
14
+ function readTargetsCache() {
15
+ return (0, devkit_1.readJsonFile)(cachePath);
16
+ }
17
+ function writeTargetsToCache(targets) {
18
+ (0, devkit_1.writeJsonFile)(cachePath, targets);
19
+ }
20
+ const createDependencies = () => {
21
+ writeTargetsToCache(calculatedTargets);
22
+ return [];
23
+ };
24
+ exports.createDependencies = createDependencies;
25
+ exports.createNodes = [
26
+ '**/remix.config.{js,cjs,mjs}',
27
+ async (configFilePath, options, context) => {
28
+ const projectRoot = (0, path_1.dirname)(configFilePath);
29
+ const fullyQualifiedProjectRoot = (0, path_1.join)(context.workspaceRoot, projectRoot);
30
+ // Do not create a project if package.json and project.json isn't there
31
+ const siblingFiles = (0, fs_1.readdirSync)(fullyQualifiedProjectRoot);
32
+ if (!siblingFiles.includes('package.json') &&
33
+ !siblingFiles.includes('project.json')) {
34
+ return {};
35
+ }
36
+ options = normalizeOptions(options);
37
+ const hash = (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, context, [
38
+ (0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot)),
39
+ ]);
40
+ const targets = targetsCache[hash]
41
+ ? targetsCache[hash]
42
+ : await buildRemixTargets(configFilePath, projectRoot, options, context);
43
+ calculatedTargets[hash] = targets;
44
+ return {
45
+ projects: {
46
+ [projectRoot]: {
47
+ root: projectRoot,
48
+ targets,
49
+ },
50
+ },
51
+ };
52
+ },
53
+ ];
54
+ async function buildRemixTargets(configFilePath, projectRoot, options, context) {
55
+ const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
56
+ const serverBuildPath = await getServerBuildPath(configFilePath, context.workspaceRoot);
57
+ const targets = {};
58
+ targets[options.buildTargetName] = buildTarget(options.buildTargetName, namedInputs);
59
+ targets[options.serveTargetName] = serveTarget(serverBuildPath);
60
+ targets[options.startTargetName] = startTarget(projectRoot, serverBuildPath, options.buildTargetName);
61
+ targets[options.typecheckTargetName] = typecheckTarget(projectRoot, namedInputs);
62
+ return targets;
63
+ }
64
+ function buildTarget(buildTargetName, namedInputs) {
65
+ return {
66
+ cache: true,
67
+ dependsOn: [`^${buildTargetName}`],
68
+ inputs: [
69
+ ...('production' in namedInputs
70
+ ? ['production', '^production']
71
+ : ['default', '^default']),
72
+ ],
73
+ outputs: ['{options.outputPath}'],
74
+ executor: '@nx/remix:build',
75
+ options: {
76
+ outputPath: '{workspaceRoot}/dist',
77
+ },
78
+ };
79
+ }
80
+ function serveTarget(serverBuildPath) {
81
+ return {
82
+ executor: '@nx/remix:serve',
83
+ options: {
84
+ command: `npx remix-serve ${serverBuildPath}`,
85
+ },
86
+ };
87
+ }
88
+ function startTarget(projectRoot, serverBuildPath, buildTargetName) {
89
+ return {
90
+ dependsOn: [buildTargetName],
91
+ command: `npx remix-serve ${serverBuildPath}`,
92
+ options: {
93
+ cwd: projectRoot,
94
+ },
95
+ };
96
+ }
97
+ function typecheckTarget(projectRoot, namedInputs) {
98
+ return {
99
+ cache: true,
100
+ inputs: [
101
+ ...('production' in namedInputs
102
+ ? ['production', '^production']
103
+ : ['default', '^default']),
104
+ ],
105
+ command: 'tsc',
106
+ options: {
107
+ cwd: projectRoot,
108
+ },
109
+ };
110
+ }
111
+ async function getServerBuildPath(configFilePath, workspaceRoot) {
112
+ const configPath = (0, path_1.join)(workspaceRoot, configFilePath);
113
+ let appConfig = {};
114
+ try {
115
+ let appConfigModule;
116
+ try {
117
+ appConfigModule = await Function(`return import("${configPath}?t=${Date.now()}")`)();
118
+ }
119
+ catch {
120
+ appConfigModule = require(configPath);
121
+ }
122
+ appConfig = appConfigModule?.default || appConfigModule;
123
+ }
124
+ catch (error) {
125
+ throw new Error(`Error loading Remix config at ${configFilePath}\n${String(error)}`);
126
+ }
127
+ return appConfig.serverBuildPath ?? 'build/index.js';
128
+ }
129
+ function normalizeOptions(options) {
130
+ options ??= {};
131
+ options.buildTargetName ??= 'build';
132
+ options.serveTargetName ??= 'serve';
133
+ options.startTargetName ??= 'start';
134
+ options.typecheckTargetName ??= 'typecheck';
135
+ return options;
136
+ }
@@ -1,4 +1,5 @@
1
1
  import { Tree } from '@nx/devkit';
2
2
  import type { AppConfig } from '@remix-run/dev';
3
3
  export declare function getRemixConfigPath(tree: Tree, projectName: string): string;
4
+ export declare function getRemixConfigPathFromProjectRoot(tree: Tree, projectRoot: string): string;
4
5
  export declare function getRemixConfigValues(tree: Tree, projectName: string): Promise<AppConfig>;
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRemixConfigValues = exports.getRemixConfigPath = void 0;
3
+ exports.getRemixConfigValues = exports.getRemixConfigPathFromProjectRoot = exports.getRemixConfigPath = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  function getRemixConfigPath(tree, projectName) {
6
6
  const project = (0, devkit_1.readProjectConfiguration)(tree, projectName);
7
7
  if (!project)
8
8
  throw new Error(`Project does not exist: ${projectName}`);
9
- for (const ext of ['.cjs', '.js']) {
9
+ for (const ext of ['.mjs', '.cjs', '.js']) {
10
10
  const configPath = (0, devkit_1.joinPathFragments)(project.root, `remix.config${ext}`);
11
11
  if (tree.exists(configPath)) {
12
12
  return configPath;
@@ -14,8 +14,32 @@ function getRemixConfigPath(tree, projectName) {
14
14
  }
15
15
  }
16
16
  exports.getRemixConfigPath = getRemixConfigPath;
17
+ function getRemixConfigPathFromProjectRoot(tree, projectRoot) {
18
+ let pathToRemixConfig;
19
+ for (const ext of ['.js', '.mjs', '.cjs']) {
20
+ pathToRemixConfig = (0, devkit_1.joinPathFragments)(projectRoot, `remix.config${ext}`);
21
+ if (tree.exists(pathToRemixConfig)) {
22
+ return pathToRemixConfig;
23
+ }
24
+ }
25
+ throw new Error(`Could not find a Remix Config File. Please ensure a "remix.config.js" file exists at the root of your project.`);
26
+ }
27
+ exports.getRemixConfigPathFromProjectRoot = getRemixConfigPathFromProjectRoot;
28
+ const _remixConfigCache = {};
17
29
  async function getRemixConfigValues(tree, projectName) {
18
- const remixConfigPath = getRemixConfigPath(tree, projectName);
19
- return eval(tree.read(remixConfigPath, 'utf-8'));
30
+ const remixConfigPath = (0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, getRemixConfigPath(tree, projectName));
31
+ const cacheKey = `${projectName}/${remixConfigPath}`;
32
+ let appConfig = _remixConfigCache[cacheKey];
33
+ if (!appConfig) {
34
+ try {
35
+ const importedConfig = await Function(`return import("${remixConfigPath}?t=${Date.now()}")`)();
36
+ appConfig = (importedConfig?.default || importedConfig);
37
+ }
38
+ catch {
39
+ appConfig = require(remixConfigPath);
40
+ }
41
+ _remixConfigCache[cacheKey] = appConfig;
42
+ }
43
+ return appConfig;
20
44
  }
21
45
  exports.getRemixConfigValues = getRemixConfigValues;
@@ -1,4 +1,4 @@
1
1
  import { type Tree } from '@nx/devkit';
2
- export declare function updateViteTestSetup(tree: Tree, pathToViteConfig: string, pathToTestSetup: string): void;
2
+ export declare function updateVitestTestSetup(tree: Tree, pathToVitestConfig: string, pathToTestSetup: string): void;
3
3
  export declare function updateJestTestSetup(tree: Tree, pathToJestConfig: string, pathToTestSetup: string): void;
4
- export declare function updateViteTestIncludes(tree: Tree, pathToViteConfig: string, includesString: string): void;
4
+ export declare function updateVitestTestIncludes(tree: Tree, pathToVitestConfig: string, includesString: string): void;
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateViteTestIncludes = exports.updateJestTestSetup = exports.updateViteTestSetup = void 0;
3
+ exports.updateVitestTestIncludes = exports.updateJestTestSetup = exports.updateVitestTestSetup = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
6
6
  let tsModule;
7
- function updateViteTestSetup(tree, pathToViteConfig, pathToTestSetup) {
7
+ function updateVitestTestSetup(tree, pathToVitestConfig, pathToTestSetup) {
8
8
  if (!tsModule) {
9
9
  tsModule = (0, ensure_typescript_1.ensureTypescript)();
10
10
  }
11
11
  const { tsquery } = require('@phenomnomnominal/tsquery');
12
- const fileContents = tree.read(pathToViteConfig, 'utf-8');
12
+ const fileContents = tree.read(pathToVitestConfig, 'utf-8');
13
13
  const ast = tsquery.ast(fileContents);
14
14
  const TEST_SETUPFILES_SELECTOR = 'PropertyAssignment:has(Identifier[name=test]) PropertyAssignment:has(Identifier[name=setupFiles])';
15
15
  const nodes = tsquery(ast, TEST_SETUPFILES_SELECTOR, {
@@ -31,9 +31,9 @@ function updateViteTestSetup(tree, pathToViteConfig, pathToTestSetup) {
31
31
  updatedFileContents = (0, devkit_1.stripIndents) `${fileContents.slice(0, arrayNodes[0].getStart() + 1)}'${pathToTestSetup}',${fileContents.slice(arrayNodes[0].getStart() + 1)}`;
32
32
  }
33
33
  }
34
- tree.write(pathToViteConfig, updatedFileContents);
34
+ tree.write(pathToVitestConfig, updatedFileContents);
35
35
  }
36
- exports.updateViteTestSetup = updateViteTestSetup;
36
+ exports.updateVitestTestSetup = updateVitestTestSetup;
37
37
  function updateJestTestSetup(tree, pathToJestConfig, pathToTestSetup) {
38
38
  if (!tsModule) {
39
39
  tsModule = (0, ensure_typescript_1.ensureTypescript)();
@@ -62,18 +62,18 @@ function updateJestTestSetup(tree, pathToJestConfig, pathToTestSetup) {
62
62
  }
63
63
  }
64
64
  exports.updateJestTestSetup = updateJestTestSetup;
65
- function updateViteTestIncludes(tree, pathToViteConfig, includesString) {
65
+ function updateVitestTestIncludes(tree, pathToVitestConfig, includesString) {
66
66
  if (!tsModule) {
67
67
  tsModule = (0, ensure_typescript_1.ensureTypescript)();
68
68
  }
69
69
  const { tsquery } = require('@phenomnomnominal/tsquery');
70
- const fileContents = tree.read(pathToViteConfig, 'utf-8');
70
+ const fileContents = tree.read(pathToVitestConfig, 'utf-8');
71
71
  const ast = tsquery.ast(fileContents);
72
72
  const TEST_INCLUDE_SELECTOR = 'PropertyAssignment:has(Identifier[name=test]) PropertyAssignment:has(Identifier[name=include])';
73
73
  const nodes = tsquery(ast, TEST_INCLUDE_SELECTOR, { visitAllChildren: true });
74
74
  if (nodes.length !== 0) {
75
75
  const updatedFileContents = (0, devkit_1.stripIndents) `${fileContents.slice(0, nodes[0].getStart())}include: ["${includesString}"]${fileContents.slice(nodes[0].getEnd())}`;
76
- tree.write(pathToViteConfig, updatedFileContents);
76
+ tree.write(pathToVitestConfig, updatedFileContents);
77
77
  }
78
78
  }
79
- exports.updateViteTestIncludes = updateViteTestIncludes;
79
+ exports.updateVitestTestIncludes = updateVitestTestIncludes;
@@ -1,11 +0,0 @@
1
- /**
2
- * @type {import('@remix-run/dev').AppConfig}
3
- */
4
- module.exports = {
5
- ignoredRouteFiles: ["**/.*"],
6
- // appDirectory: "app",
7
- // assetsBuildDirectory: "public/build",
8
- // serverBuildPath: "build/index.js",
9
- // publicPath: "/build/",
10
- watchPaths: () => require("@nx/remix").createWatchPaths(__dirname),
11
- };