@nx/remix 18.0.3 → 18.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/remix",
3
- "version": "18.0.3",
3
+ "version": "18.0.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,12 +28,12 @@
28
28
  "migrations": "./migrations.json"
29
29
  },
30
30
  "dependencies": {
31
- "@nx/devkit": "18.0.3",
32
- "@nx/js": "18.0.3",
33
- "@nx/react": "18.0.3",
31
+ "@nx/devkit": "18.0.5",
32
+ "@nx/js": "18.0.5",
33
+ "@nx/react": "18.0.5",
34
34
  "tslib": "^2.3.1",
35
35
  "@phenomnomnominal/tsquery": "~5.0.1",
36
- "@nrwl/remix": "18.0.3"
36
+ "@nrwl/remix": "18.0.5"
37
37
  },
38
38
  "peerDependencies": {},
39
39
  "publishConfig": {
@@ -53,7 +53,7 @@ async function buildExecutor(options, context) {
53
53
  packageJson.scripts ??= {};
54
54
  // Don't override existing custom script since project may have its own server.
55
55
  if (!packageJson.scripts.start) {
56
- packageJson.scripts['start'] = 'remix-serve ./build';
56
+ packageJson.scripts['start'] = 'remix-serve ./build/index.js';
57
57
  }
58
58
  updatePackageJson(packageJson, context);
59
59
  (0, devkit_1.writeJsonFile)(`${options.outputPath}/package.json`, packageJson);
@@ -323,9 +323,8 @@ export default {
323
323
  exports[`Remix Application Integrated Repo --projectNameAndRootFormat=as-provided --unitTestRunner should generate the correct files for testing using jest 2`] = `
324
324
  "/* eslint-disable */
325
325
  export default {
326
- setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
327
326
  displayName: 'test',
328
- preset: '../jest.preset.cjs',
327
+ preset: '../jest.preset.js',
329
328
  transform: {
330
329
  '^.+\\\\.[tj]sx?$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
331
330
  },
@@ -406,6 +405,39 @@ installGlobals();
406
405
  "
407
406
  `;
408
407
 
408
+ exports[`Remix Application Integrated Repo --projectNameAndRootFormat=as-provided --unitTestRunner should generate the correct files for testing using vitest 4`] = `
409
+ "{
410
+ "extends": "./tsconfig.json",
411
+ "compilerOptions": {
412
+ "outDir": "../dist/out-tsc",
413
+ "types": [
414
+ "vitest/globals",
415
+ "vitest/importMeta",
416
+ "vite/client",
417
+ "node",
418
+ "vitest"
419
+ ]
420
+ },
421
+ "include": [
422
+ "vite.config.ts",
423
+ "vitest.config.ts",
424
+ "app/**/*.ts",
425
+ "app/**/*.tsx",
426
+ "app/**/*.js",
427
+ "app/**/*.jsx",
428
+ "tests/**/*.spec.ts",
429
+ "tests/**/*.test.ts",
430
+ "tests/**/*.spec.tsx",
431
+ "tests/**/*.test.tsx",
432
+ "tests/**/*.spec.js",
433
+ "tests/**/*.test.js",
434
+ "tests/**/*.spec.jsx",
435
+ "tests/**/*.test.jsx"
436
+ ]
437
+ }
438
+ "
439
+ `;
440
+
409
441
  exports[`Remix Application Integrated Repo --projectNameAndRootFormat=as-provided should create the application correctly 1`] = `
410
442
  "import { createWatchPaths } from '@nx/remix';
411
443
  import { dirname } from 'path';
@@ -801,9 +833,8 @@ export default {
801
833
  exports[`Remix Application Integrated Repo --projectNameAndRootFormat=derived --unitTestRunner should generate the correct files for testing using jest 2`] = `
802
834
  "/* eslint-disable */
803
835
  export default {
804
- setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
805
836
  displayName: 'test',
806
- preset: '../../jest.preset.cjs',
837
+ preset: '../../jest.preset.js',
807
838
  transform: {
808
839
  '^.+\\\\.[tj]sx?$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
809
840
  },
@@ -884,6 +915,39 @@ installGlobals();
884
915
  "
885
916
  `;
886
917
 
918
+ exports[`Remix Application Integrated Repo --projectNameAndRootFormat=derived --unitTestRunner should generate the correct files for testing using vitest 4`] = `
919
+ "{
920
+ "extends": "./tsconfig.json",
921
+ "compilerOptions": {
922
+ "outDir": "../../dist/out-tsc",
923
+ "types": [
924
+ "vitest/globals",
925
+ "vitest/importMeta",
926
+ "vite/client",
927
+ "node",
928
+ "vitest"
929
+ ]
930
+ },
931
+ "include": [
932
+ "vite.config.ts",
933
+ "vitest.config.ts",
934
+ "app/**/*.ts",
935
+ "app/**/*.tsx",
936
+ "app/**/*.js",
937
+ "app/**/*.jsx",
938
+ "tests/**/*.spec.ts",
939
+ "tests/**/*.test.ts",
940
+ "tests/**/*.spec.tsx",
941
+ "tests/**/*.test.tsx",
942
+ "tests/**/*.spec.js",
943
+ "tests/**/*.test.js",
944
+ "tests/**/*.spec.jsx",
945
+ "tests/**/*.test.jsx"
946
+ ]
947
+ }
948
+ "
949
+ `;
950
+
887
951
  exports[`Remix Application Integrated Repo --projectNameAndRootFormat=derived should create the application correctly 1`] = `
888
952
  "import { createWatchPaths } from '@nx/remix';
889
953
  import { dirname } from 'path';
@@ -1183,6 +1247,39 @@ test('renders loader data', async () => {
1183
1247
  `;
1184
1248
 
1185
1249
  exports[`Remix Application Standalone Project Repo --unitTestRunner should generate the correct files for testing using vitest 4`] = `
1250
+ "{
1251
+ "extends": "./tsconfig.json",
1252
+ "compilerOptions": {
1253
+ "outDir": "./dist/out-tsc",
1254
+ "types": [
1255
+ "vitest/globals",
1256
+ "vitest/importMeta",
1257
+ "vite/client",
1258
+ "node",
1259
+ "vitest"
1260
+ ]
1261
+ },
1262
+ "include": [
1263
+ "vite.config.ts",
1264
+ "vitest.config.ts",
1265
+ "app/**/*.ts",
1266
+ "app/**/*.tsx",
1267
+ "app/**/*.js",
1268
+ "app/**/*.jsx",
1269
+ "tests/**/*.spec.ts",
1270
+ "tests/**/*.test.ts",
1271
+ "tests/**/*.spec.tsx",
1272
+ "tests/**/*.test.tsx",
1273
+ "tests/**/*.spec.js",
1274
+ "tests/**/*.test.js",
1275
+ "tests/**/*.spec.jsx",
1276
+ "tests/**/*.test.jsx"
1277
+ ]
1278
+ }
1279
+ "
1280
+ `;
1281
+
1282
+ exports[`Remix Application Standalone Project Repo --unitTestRunner should generate the correct files for testing using vitest 5`] = `
1186
1283
  "import { installGlobals } from '@remix-run/node';
1187
1284
  import '@testing-library/jest-dom/matchers';
1188
1285
  installGlobals();
@@ -129,7 +129,7 @@ async function remixApplicationGeneratorInternal(tree, _options) {
129
129
  }
130
130
  tasks.push(jestTask);
131
131
  }
132
- const pkgInstallTask = (0, lib_1.updateUnitTestConfig)(tree, options.projectRoot, options.unitTestRunner);
132
+ const pkgInstallTask = (0, lib_1.updateUnitTestConfig)(tree, options.projectRoot, options.unitTestRunner, options.rootProject);
133
133
  tasks.push(pkgInstallTask);
134
134
  }
135
135
  else {
@@ -735,7 +735,7 @@ export function NxWelcome({ title }: { title: string }) {
735
735
  You can activate distributed tasks executions and caching by
736
736
  running:
737
737
  </p>
738
- <pre>nx connect-to-nx-cloud</pre>
738
+ <pre>nx connect</pre>
739
739
  <a
740
740
  href="https://nx.app/?utm_source=nx-project"
741
741
  target="_blank"
@@ -1,2 +1,2 @@
1
1
  import { type Tree } from '@nx/devkit';
2
- export declare function updateUnitTestConfig(tree: Tree, pathToRoot: string, unitTestRunner: 'vitest' | 'jest'): import("@nx/devkit").GeneratorCallback;
2
+ export declare function updateUnitTestConfig(tree: Tree, pathToRoot: string, unitTestRunner: 'vitest' | 'jest', rootProject: boolean): import("@nx/devkit").GeneratorCallback;
@@ -4,7 +4,7 @@ exports.updateUnitTestConfig = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const testing_config_utils_1 = require("../../../utils/testing-config-utils");
6
6
  const versions_1 = require("../../../utils/versions");
7
- function updateUnitTestConfig(tree, pathToRoot, unitTestRunner) {
7
+ function updateUnitTestConfig(tree, pathToRoot, unitTestRunner, rootProject) {
8
8
  const pathToTestSetup = (0, devkit_1.joinPathFragments)(pathToRoot, `test-setup.ts`);
9
9
  tree.write(pathToTestSetup, (0, devkit_1.stripIndents) `
10
10
  import { installGlobals } from '@remix-run/node';
@@ -16,9 +16,9 @@ function updateUnitTestConfig(tree, pathToRoot, unitTestRunner) {
16
16
  (0, testing_config_utils_1.updateVitestTestIncludes)(tree, pathToViteConfig, './tests/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}');
17
17
  (0, testing_config_utils_1.updateVitestTestSetup)(tree, pathToViteConfig, 'test-setup.ts');
18
18
  }
19
- else if (unitTestRunner === 'jest') {
19
+ else if (unitTestRunner === 'jest' && rootProject) {
20
20
  const pathToJestConfig = (0, devkit_1.joinPathFragments)(pathToRoot, 'jest.config.ts');
21
- tree.rename('jest.preset.js', 'jest.preset.cjs');
21
+ tree.write('jest.preset.cjs', tree.read('jest.preset.js', 'utf-8'));
22
22
  (0, testing_config_utils_1.updateJestTestSetup)(tree, pathToJestConfig, `<rootDir>/test-setup.ts`);
23
23
  tree.write(pathToJestConfig, tree
24
24
  .read(pathToJestConfig, 'utf-8')
@@ -26,7 +26,7 @@ function updateUnitTestConfig(tree, pathToRoot, unitTestRunner) {
26
26
  }
27
27
  const pathToTsConfigSpec = (0, devkit_1.joinPathFragments)(pathToRoot, `tsconfig.spec.json`);
28
28
  (0, devkit_1.updateJson)(tree, pathToTsConfigSpec, (json) => {
29
- json.includes = [
29
+ json.include = [
30
30
  'vite.config.ts',
31
31
  'vitest.config.ts',
32
32
  'app/**/*.ts',
@@ -41,6 +41,7 @@ async function remixInitGeneratorInternal(tree, options) {
41
41
  }, undefined, options.keepExistingVersions);
42
42
  tasks.push(installTask);
43
43
  }
44
+ options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
44
45
  if (options.addPlugin) {
45
46
  addPlugin(tree);
46
47
  }
@@ -17,10 +17,11 @@ exports[`@nx/remix/plugin non-root project should create nodes 1`] = `
17
17
  "^production",
18
18
  ],
19
19
  "options": {
20
- "outputPath": "{workspaceRoot}/dist/my-app",
20
+ "outputPath": "my-app",
21
21
  },
22
22
  "outputs": [
23
- "{options.outputPath}",
23
+ "{workspaceRoot}/my-app/build",
24
+ "{workspaceRoot}/my-app/public/build",
24
25
  ],
25
26
  },
26
27
  "serve": {
@@ -72,10 +73,11 @@ exports[`@nx/remix/plugin root project should create nodes 1`] = `
72
73
  "^production",
73
74
  ],
74
75
  "options": {
75
- "outputPath": "{workspaceRoot}/dist",
76
+ "outputPath": ".",
76
77
  },
77
78
  "outputs": [
78
- "{options.outputPath}",
79
+ "{workspaceRoot}/build",
80
+ "{workspaceRoot}/public/build",
79
81
  ],
80
82
  },
81
83
  "serve": {
@@ -54,16 +54,21 @@ exports.createNodes = [
54
54
  ];
55
55
  async function buildRemixTargets(configFilePath, projectRoot, options, context, siblingFiles) {
56
56
  const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
57
- const serverBuildPath = await getServerBuildPath(configFilePath, context.workspaceRoot);
57
+ const { buildDirectory, assetsBuildDirectory, serverBuildPath } = await getBuildPaths(configFilePath, context.workspaceRoot);
58
58
  const targets = {};
59
- targets[options.buildTargetName] = buildTarget(options.buildTargetName, projectRoot, namedInputs);
59
+ targets[options.buildTargetName] = buildTarget(options.buildTargetName, projectRoot, buildDirectory, assetsBuildDirectory, namedInputs);
60
60
  targets[options.serveTargetName] = serveTarget(serverBuildPath);
61
61
  targets[options.startTargetName] = startTarget(projectRoot, serverBuildPath, options.buildTargetName);
62
62
  targets[options.typecheckTargetName] = typecheckTarget(projectRoot, namedInputs, siblingFiles);
63
63
  return targets;
64
64
  }
65
- function buildTarget(buildTargetName, projectRoot, namedInputs) {
66
- const pathToOutput = projectRoot === '.' ? '' : `/${projectRoot}`;
65
+ function buildTarget(buildTargetName, projectRoot, buildDirectory, assetsBuildDirectory, namedInputs) {
66
+ const serverBuildOutputPath = projectRoot === '.'
67
+ ? (0, devkit_1.joinPathFragments)(`{workspaceRoot}`, buildDirectory)
68
+ : (0, devkit_1.joinPathFragments)(`{workspaceRoot}`, projectRoot, buildDirectory);
69
+ const assetsBuildOutputPath = projectRoot === '.'
70
+ ? (0, devkit_1.joinPathFragments)(`{workspaceRoot}`, assetsBuildDirectory)
71
+ : (0, devkit_1.joinPathFragments)(`{workspaceRoot}`, projectRoot, assetsBuildDirectory);
67
72
  return {
68
73
  cache: true,
69
74
  dependsOn: [`^${buildTargetName}`],
@@ -72,10 +77,10 @@ function buildTarget(buildTargetName, projectRoot, namedInputs) {
72
77
  ? ['production', '^production']
73
78
  : ['default', '^default']),
74
79
  ],
75
- outputs: ['{options.outputPath}'],
80
+ outputs: [serverBuildOutputPath, assetsBuildOutputPath],
76
81
  executor: '@nx/remix:build',
77
82
  options: {
78
- outputPath: `{workspaceRoot}/dist${pathToOutput}`,
83
+ outputPath: projectRoot,
79
84
  },
80
85
  };
81
86
  }
@@ -112,10 +117,14 @@ function typecheckTarget(projectRoot, namedInputs, siblingFiles) {
112
117
  },
113
118
  };
114
119
  }
115
- async function getServerBuildPath(configFilePath, workspaceRoot) {
120
+ async function getBuildPaths(configFilePath, workspaceRoot) {
116
121
  const configPath = (0, path_1.join)(workspaceRoot, configFilePath);
117
122
  let appConfig = await (0, config_utils_1.loadConfigFile)(configPath);
118
- return appConfig.serverBuildPath ?? 'build/index.js';
123
+ return {
124
+ buildDirectory: 'build',
125
+ serverBuildPath: appConfig.serverBuildPath ?? 'build/index.js',
126
+ assetsBuildDirectory: appConfig.assetsBuildDirectory ?? 'public/build',
127
+ };
119
128
  }
120
129
  function normalizeOptions(options) {
121
130
  options ??= {};