@nx/remix 21.0.0-beta.1 → 21.0.0-beta.3

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 (29) hide show
  1. package/package.json +4 -4
  2. package/src/generators/application/__snapshots__/application.impl.spec.ts.snap +24 -15
  3. package/src/generators/application/application.impl.js +16 -3
  4. package/src/generators/application/files/common/tests/routes/_index.spec.tsx__tmpl__ +3 -2
  5. package/src/generators/application/files/ts-solution/package.json__tmpl__ +2 -5
  6. package/src/generators/application/lib/add-e2e.js +24 -23
  7. package/src/generators/application/lib/ignore-vite-temp-files.d.ts +3 -0
  8. package/src/generators/application/lib/ignore-vite-temp-files.js +60 -0
  9. package/src/generators/application/lib/index.d.ts +1 -1
  10. package/src/generators/application/lib/index.js +1 -1
  11. package/src/generators/application/lib/normalize-options.d.ts +1 -0
  12. package/src/generators/application/lib/normalize-options.js +9 -9
  13. package/src/generators/application/lib/update-unit-test-config.js +1 -0
  14. package/src/generators/application/schema.d.ts +1 -0
  15. package/src/generators/application/schema.json +4 -0
  16. package/src/generators/library/__snapshots__/library.impl.spec.ts.snap +6 -3
  17. package/src/generators/library/lib/add-tsconfig-entry-points.js +6 -8
  18. package/src/generators/library/lib/normalize-options.js +5 -6
  19. package/src/generators/library/lib/update-buildable-config.js +1 -1
  20. package/src/generators/library/library.impl.js +7 -2
  21. package/src/generators/library/schema.d.ts +1 -0
  22. package/src/generators/library/schema.json +4 -0
  23. package/src/generators/storybook-configuration/__snapshots__/storybook-configuration.impl.spec.ts.snap +3 -3
  24. package/src/plugins/__snapshots__/plugin.spec.ts.snap +23 -0
  25. package/src/plugins/plugin.js +2 -0
  26. package/src/utils/versions.d.ts +2 -1
  27. package/src/utils/versions.js +3 -2
  28. package/src/generators/application/lib/add-vite-temp-files-to-gitignore.d.ts +0 -2
  29. package/src/generators/application/lib/add-vite-temp-files-to-gitignore.js +0 -18
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/remix",
3
- "version": "21.0.0-beta.1",
3
+ "version": "21.0.0-beta.3",
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, Playwright, 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",
@@ -29,9 +29,9 @@
29
29
  "migrations": "./migrations.json"
30
30
  },
31
31
  "dependencies": {
32
- "@nx/devkit": "21.0.0-beta.1",
33
- "@nx/js": "21.0.0-beta.1",
34
- "@nx/react": "21.0.0-beta.1",
32
+ "@nx/devkit": "21.0.0-beta.3",
33
+ "@nx/js": "21.0.0-beta.3",
34
+ "@nx/react": "21.0.0-beta.3",
35
35
  "tslib": "^2.3.1",
36
36
  "@phenomnomnominal/tsquery": "~5.0.1"
37
37
  },
@@ -182,7 +182,7 @@ export default defineConfig({
182
182
  webServer: {
183
183
  command: 'npx nx run test:serve-static',
184
184
  url: 'http://localhost:3000',
185
- reuseExistingServer: !process.env.CI,
185
+ reuseExistingServer: true,
186
186
  cwd: workspaceRoot,
187
187
  },
188
188
  projects: [
@@ -252,7 +252,7 @@ import react from '@vitejs/plugin-react';
252
252
  import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
253
253
  import { nxCopyAssetsPlugin } from '@nx/vite/plugins/nx-copy-assets.plugin';
254
254
 
255
- export default defineConfig({
255
+ export default defineConfig(() => ({
256
256
  root: __dirname,
257
257
  cacheDir: '../node_modules/.vite/test',
258
258
  plugins: [react(), nxViteTsPaths(), nxCopyAssetsPlugin(['*.md'])],
@@ -269,10 +269,10 @@ export default defineConfig({
269
269
  reporters: ['default'],
270
270
  coverage: {
271
271
  reportsDirectory: '../coverage/test',
272
- provider: 'v8',
272
+ provider: 'v8' as const,
273
273
  },
274
274
  },
275
- });
275
+ }));
276
276
  "
277
277
  `;
278
278
 
@@ -429,7 +429,8 @@ installGlobals();
429
429
 
430
430
  exports[`Remix Application Standalone Project Repo --unitTestRunner should generate the correct files for testing using jest 3`] = `
431
431
  "import { createRemixStub } from '@remix-run/testing';
432
- import { render, screen, waitFor } from '@testing-library/react';
432
+ import { render } from '@testing-library/react';
433
+ import { screen } from '@testing-library/dom';
433
434
  import Index from '../../app/routes/_index';
434
435
 
435
436
  test('renders loader data', async () => {
@@ -442,7 +443,7 @@ test('renders loader data', async () => {
442
443
 
443
444
  render(<RemixStub />);
444
445
 
445
- await waitFor(() => screen.findByText('Hello there,'));
446
+ await screen.findByText('Hello there,');
446
447
  });
447
448
  "
448
449
  `;
@@ -454,7 +455,7 @@ import react from '@vitejs/plugin-react';
454
455
  import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
455
456
  import { nxCopyAssetsPlugin } from '@nx/vite/plugins/nx-copy-assets.plugin';
456
457
 
457
- export default defineConfig({
458
+ export default defineConfig(() => ({
458
459
  root: __dirname,
459
460
  cacheDir: './node_modules/.vite/test',
460
461
  plugins: [react(), nxViteTsPaths(), nxCopyAssetsPlugin(['*.md'])],
@@ -471,16 +472,17 @@ export default defineConfig({
471
472
  reporters: ['default'],
472
473
  coverage: {
473
474
  reportsDirectory: './coverage/test',
474
- provider: 'v8',
475
+ provider: 'v8' as const,
475
476
  },
476
477
  },
477
- });
478
+ }));
478
479
  "
479
480
  `;
480
481
 
481
482
  exports[`Remix Application Standalone Project Repo --unitTestRunner should generate the correct files for testing using vitest 2`] = `
482
483
  "import { createRemixStub } from '@remix-run/testing';
483
- import { render, screen, waitFor } from '@testing-library/react';
484
+ import { render } from '@testing-library/react';
485
+ import { screen } from '@testing-library/dom';
484
486
  import Index from '../../app/routes/_index';
485
487
 
486
488
  test('renders loader data', async () => {
@@ -493,7 +495,7 @@ test('renders loader data', async () => {
493
495
 
494
496
  render(<RemixStub />);
495
497
 
496
- await waitFor(() => screen.findByText('Hello there,'));
498
+ await screen.findByText('Hello there,');
497
499
  });
498
500
  "
499
501
  `;
@@ -606,7 +608,8 @@ export default function Index() {
606
608
 
607
609
  exports[`Remix Application Standalone Project Repo should create the application correctly 3`] = `
608
610
  "import { createRemixStub } from '@remix-run/testing';
609
- import { render, screen, waitFor } from '@testing-library/react';
611
+ import { render } from '@testing-library/react';
612
+ import { screen } from '@testing-library/dom';
610
613
  import Index from '../../app/routes/_index';
611
614
 
612
615
  test('renders loader data', async () => {
@@ -619,7 +622,7 @@ test('renders loader data', async () => {
619
622
 
620
623
  render(<RemixStub />);
621
624
 
622
- await waitFor(() => screen.findByText('Hello there,'));
625
+ await screen.findByText('Hello there,');
623
626
  });
624
627
  "
625
628
  `;
@@ -656,7 +659,13 @@ export default defineConfig({
656
659
  exports[`Remix Application Standalone Project Repo should create the application correctly 5`] = `
657
660
  "{
658
661
  "root": true,
659
- "ignorePatterns": ["!**/*", "build", "public/build"],
662
+ "ignorePatterns": [
663
+ "!**/*",
664
+ "build",
665
+ "public/build",
666
+ "**/vite.config.*.timestamp*",
667
+ "**/vitest.config.*.timestamp*"
668
+ ],
660
669
  "plugins": ["@nx"],
661
670
  "overrides": [
662
671
  {
@@ -703,7 +712,7 @@ export default defineConfig({
703
712
  webServer: {
704
713
  command: 'npx nx run test:serve-static',
705
714
  url: 'http://localhost:3000',
706
- reuseExistingServer: !process.env.CI,
715
+ reuseExistingServer: true,
707
716
  cwd: workspaceRoot,
708
717
  },
709
718
  projects: [
@@ -17,6 +17,7 @@ const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields");
17
17
  function remixApplicationGenerator(tree, options) {
18
18
  return remixApplicationGeneratorInternal(tree, {
19
19
  addPlugin: true,
20
+ useProjectJson: true,
20
21
  ...options,
21
22
  });
22
23
  }
@@ -40,9 +41,9 @@ async function remixApplicationGeneratorInternal(tree, _options) {
40
41
  // If we are using the new TS solution
41
42
  // We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
42
43
  if (options.isUsingTsSolutionConfig) {
43
- (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(tree, options.projectRoot);
44
+ await (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(tree, options.projectRoot);
44
45
  }
45
- if (!options.isUsingTsSolutionConfig) {
46
+ if (options.useProjectJson) {
46
47
  (0, devkit_1.addProjectConfiguration)(tree, options.projectName, {
47
48
  root: options.projectRoot,
48
49
  sourceRoot: `${options.projectRoot}`,
@@ -82,6 +83,18 @@ async function remixApplicationGeneratorInternal(tree, _options) {
82
83
  if (options.isUsingTsSolutionConfig) {
83
84
  (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files/ts-solution'), options.projectRoot, vars);
84
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
+ }
85
98
  if (options.unitTestRunner !== 'none') {
86
99
  if (options.unitTestRunner === 'vitest') {
87
100
  const { vitestGenerator, createOrEditViteConfig } = (0, devkit_1.ensurePackage)('@nx/vite', (0, versions_1.getPackageVersion)(tree, 'nx'));
@@ -193,7 +206,7 @@ export default {...nxPreset};
193
206
  }
194
207
  }
195
208
  tasks.push(await (0, lib_1.addE2E)(tree, options));
196
- (0, lib_1.addViteTempFilesToGitIgnore)(tree);
209
+ await (0, lib_1.ignoreViteTempFiles)(tree, options.projectRoot);
197
210
  (0, ts_solution_setup_1.updateTsconfigFiles)(tree, options.projectRoot, 'tsconfig.app.json', {
198
211
  jsx: 'react-jsx',
199
212
  module: 'esnext',
@@ -1,5 +1,6 @@
1
1
  import { createRemixStub } from '@remix-run/testing';
2
- import { render, screen, waitFor } from '@testing-library/react';
2
+ import { render } from '@testing-library/react';
3
+ import { screen } from '@testing-library/dom';
3
4
  import Index from '../../app/routes/_index';
4
5
 
5
6
  test('renders loader data', async () => {
@@ -12,5 +13,5 @@ test('renders loader data', async () => {
12
13
 
13
14
  render(<RemixStub />);
14
15
 
15
- await waitFor(() => screen.findByText('Hello there,'));
16
+ await screen.findByText('Hello there,');
16
17
  });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "private": true,
3
- "name": "<%= projectName %>",
3
+ "name": "<%= importPath %>",
4
4
  "scripts": {},
5
5
  "type": "module",
6
6
  "dependencies": {
@@ -19,8 +19,5 @@
19
19
  "engines": {
20
20
  "node": ">=20"
21
21
  },
22
- "sideEffects": false<% if (isUsingTsSolutionConfig && parsedTags?.length) { %>,
23
- "nx": {
24
- "tags": <%- JSON.stringify(parsedTags) %>
25
- }<% } %>
22
+ "sideEffects": false
26
23
  }
@@ -6,7 +6,6 @@ const versions_1 = require("../../../utils/versions");
6
6
  const find_plugin_for_config_file_1 = require("@nx/devkit/src/utils/find-plugin-for-config-file");
7
7
  const target_defaults_utils_1 = require("@nx/devkit/src/generators/target-defaults-utils");
8
8
  const e2e_web_server_info_utils_1 = require("@nx/devkit/src/generators/e2e-web-server-info-utils");
9
- const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
10
9
  async function addE2E(tree, options) {
11
10
  const hasRemixPlugin = (0, devkit_1.readNxJson)(tree).plugins?.find((p) => typeof p === 'string'
12
11
  ? p === '@nx/remix/plugin'
@@ -14,17 +13,15 @@ async function addE2E(tree, options) {
14
13
  let e2eWebsServerInfo = await getRemixE2EWebServerInfo(tree, options.projectName, (0, devkit_1.joinPathFragments)(options.projectRoot, 'remix.config.js'), options.addPlugin ?? Boolean(hasRemixPlugin));
15
14
  if (options.e2eTestRunner === 'cypress') {
16
15
  const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', (0, versions_1.getPackageVersion)(tree, 'nx'));
17
- if ((0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree)) {
18
- (0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), {
19
- name: options.e2eProjectName,
20
- version: '0.0.1',
21
- private: true,
22
- nx: {
23
- projectType: 'application',
24
- sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
25
- implicitDependencies: [options.projectName],
26
- },
27
- });
16
+ const packageJson = {
17
+ name: options.e2eProjectName,
18
+ version: '0.0.1',
19
+ private: true,
20
+ };
21
+ if (!options.useProjectJson) {
22
+ packageJson.nx = {
23
+ implicitDependencies: [options.projectName],
24
+ };
28
25
  }
29
26
  else {
30
27
  (0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
@@ -36,6 +33,9 @@ async function addE2E(tree, options) {
36
33
  implicitDependencies: [options.projectName],
37
34
  });
38
35
  }
36
+ if (!options.useProjectJson || options.isUsingTsSolutionConfig) {
37
+ (0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), packageJson);
38
+ }
39
39
  const e2eTask = await configurationGenerator(tree, {
40
40
  project: options.e2eProjectName,
41
41
  directory: 'src',
@@ -71,17 +71,15 @@ async function addE2E(tree, options) {
71
71
  }
72
72
  else if (options.e2eTestRunner === 'playwright') {
73
73
  const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', (0, versions_1.getPackageVersion)(tree, 'nx'));
74
- if ((0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree)) {
75
- (0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), {
76
- name: options.e2eProjectName,
77
- version: '0.0.1',
78
- private: true,
79
- nx: {
80
- projectType: 'application',
81
- sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
82
- implicitDependencies: [options.projectName],
83
- },
84
- });
74
+ const packageJson = {
75
+ name: options.e2eProjectName,
76
+ version: '0.0.1',
77
+ private: true,
78
+ };
79
+ if (!options.useProjectJson) {
80
+ packageJson.nx = {
81
+ implicitDependencies: [options.projectName],
82
+ };
85
83
  }
86
84
  else {
87
85
  (0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
@@ -93,6 +91,9 @@ async function addE2E(tree, options) {
93
91
  implicitDependencies: [options.projectName],
94
92
  });
95
93
  }
94
+ if (!options.useProjectJson || options.isUsingTsSolutionConfig) {
95
+ (0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), packageJson);
96
+ }
96
97
  const e2eTask = await configurationGenerator(tree, {
97
98
  project: options.e2eProjectName,
98
99
  skipFormat: true,
@@ -0,0 +1,3 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export declare function ignoreViteTempFiles(tree: Tree, projectRoot?: string | undefined): Promise<void>;
3
+ export declare function isEslintInstalled(tree: Tree): boolean;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ignoreViteTempFiles = ignoreViteTempFiles;
4
+ exports.isEslintInstalled = isEslintInstalled;
5
+ const devkit_1 = require("@nx/devkit");
6
+ const versions_1 = require("../../../utils/versions");
7
+ async function ignoreViteTempFiles(tree, projectRoot) {
8
+ addViteTempFilesToGitIgnore(tree);
9
+ await ignoreViteTempFilesInEslintConfig(tree, projectRoot);
10
+ }
11
+ function addViteTempFilesToGitIgnore(tree) {
12
+ let gitIgnoreContents = tree.exists('.gitignore')
13
+ ? tree.read('.gitignore', 'utf-8')
14
+ : '';
15
+ if (!/^vite\.config\.\*\.timestamp\*$/m.test(gitIgnoreContents)) {
16
+ gitIgnoreContents = (0, devkit_1.stripIndents) `${gitIgnoreContents}
17
+ vite.config.*.timestamp*`;
18
+ }
19
+ if (!/^vitest\.config\.\*\.timestamp\*$/m.test(gitIgnoreContents)) {
20
+ gitIgnoreContents = (0, devkit_1.stripIndents) `${gitIgnoreContents}
21
+ vitest.config.*.timestamp*`;
22
+ }
23
+ tree.write('.gitignore', gitIgnoreContents);
24
+ }
25
+ async function ignoreViteTempFilesInEslintConfig(tree, projectRoot) {
26
+ if (!isEslintInstalled(tree)) {
27
+ return;
28
+ }
29
+ (0, devkit_1.ensurePackage)('@nx/eslint', (0, versions_1.getPackageVersion)(tree, 'nx'));
30
+ const { addIgnoresToLintConfig, isEslintConfigSupported } = await Promise.resolve().then(() => require('@nx/eslint/src/generators/utils/eslint-file'));
31
+ if (!isEslintConfigSupported(tree)) {
32
+ return;
33
+ }
34
+ const { useFlatConfig } = await Promise.resolve().then(() => require('@nx/eslint/src/utils/flat-config'));
35
+ const isUsingFlatConfig = useFlatConfig(tree);
36
+ if (!projectRoot && !isUsingFlatConfig) {
37
+ // root eslintrc files ignore all files and the root eslintrc files add
38
+ // back all the project files, so we only add the ignores to the project
39
+ // eslintrc files
40
+ return;
41
+ }
42
+ // for flat config, we update the root config file
43
+ const directory = isUsingFlatConfig ? '' : projectRoot ?? '';
44
+ addIgnoresToLintConfig(tree, directory, [
45
+ '**/vite.config.*.timestamp*',
46
+ '**/vitest.config.*.timestamp*',
47
+ ]);
48
+ }
49
+ function isEslintInstalled(tree) {
50
+ try {
51
+ require('eslint');
52
+ return true;
53
+ }
54
+ catch { }
55
+ // it might not be installed yet, but it might be in the tree pending install
56
+ const { devDependencies, dependencies } = tree.exists('package.json')
57
+ ? (0, devkit_1.readJson)(tree, 'package.json')
58
+ : {};
59
+ return !!devDependencies?.['eslint'] || !!dependencies?.['eslint'];
60
+ }
@@ -1,4 +1,4 @@
1
1
  export * from './normalize-options';
2
2
  export * from './update-unit-test-config';
3
3
  export * from './add-e2e';
4
- export * from './add-vite-temp-files-to-gitignore';
4
+ export * from './ignore-vite-temp-files';
@@ -4,4 +4,4 @@ const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./normalize-options"), exports);
5
5
  tslib_1.__exportStar(require("./update-unit-test-config"), exports);
6
6
  tslib_1.__exportStar(require("./add-e2e"), exports);
7
- tslib_1.__exportStar(require("./add-vite-temp-files-to-gitignore"), exports);
7
+ tslib_1.__exportStar(require("./ignore-vite-temp-files"), exports);
@@ -3,6 +3,7 @@ import { type NxRemixGeneratorSchema } from '../schema';
3
3
  export interface NormalizedSchema extends NxRemixGeneratorSchema {
4
4
  projectName: string;
5
5
  projectRoot: string;
6
+ importPath: string;
6
7
  e2eProjectName: string;
7
8
  e2eProjectRoot: string;
8
9
  parsedTags: string[];
@@ -5,10 +5,9 @@ const devkit_1 = require("@nx/devkit");
5
5
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
6
6
  const eslint_1 = require("@nx/eslint");
7
7
  const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
8
- const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
9
8
  async function normalizeOptions(tree, options) {
10
- await (0, project_name_and_root_utils_1.ensureProjectName)(tree, options, 'application');
11
- const { projectName, projectRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
9
+ await (0, project_name_and_root_utils_1.ensureRootProjectName)(options, 'application');
10
+ const { projectName, projectRoot, importPath } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
12
11
  name: options.name,
13
12
  projectType: 'application',
14
13
  directory: options.directory,
@@ -19,23 +18,24 @@ async function normalizeOptions(tree, options) {
19
18
  const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
20
19
  nxJson.useInferencePlugins !== false;
21
20
  options.addPlugin ??= addPluginDefault;
22
- const e2eProjectName = options.rootProject ? 'e2e' : `${projectName}-e2e`;
21
+ const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree);
22
+ const appProjectName = !isUsingTsSolutionConfig || options.name ? projectName : importPath;
23
+ const e2eProjectName = options.rootProject ? 'e2e' : `${appProjectName}-e2e`;
23
24
  const e2eProjectRoot = options.rootProject ? 'e2e' : `${projectRoot}-e2e`;
24
25
  const parsedTags = options.tags
25
26
  ? options.tags.split(',').map((s) => s.trim())
26
27
  : [];
27
- const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree);
28
28
  return {
29
29
  ...options,
30
30
  linter: options.linter ?? eslint_1.Linter.EsLint,
31
- projectName: isUsingTsSolutionConfig
32
- ? (0, get_import_path_1.getImportPath)(tree, projectName)
33
- : projectName,
31
+ projectName: appProjectName,
34
32
  projectRoot,
33
+ importPath,
35
34
  e2eProjectName,
36
35
  e2eProjectRoot,
37
36
  parsedTags,
38
- useTsSolution: options.useTsSolution ?? isUsingTsSolutionConfig,
37
+ useTsSolution: isUsingTsSolutionConfig,
39
38
  isUsingTsSolutionConfig,
39
+ useProjectJson: options.useProjectJson ?? !isUsingTsSolutionConfig,
40
40
  };
41
41
  }
@@ -46,6 +46,7 @@ function updateUnitTestConfig(tree, pathToRoot, unitTestRunner, rootProject) {
46
46
  });
47
47
  return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
48
48
  '@testing-library/jest-dom': versions_1.testingLibraryJestDomVersion,
49
+ '@testing-library/dom': versions_1.testingLibraryDomVersion,
49
50
  '@testing-library/react': versions_1.testingLibraryReactVersion,
50
51
  '@testing-library/user-event': versions_1.testingLibraryUserEventsVersion,
51
52
  '@remix-run/node': (0, versions_1.getRemixVersion)(tree),
@@ -14,4 +14,5 @@ export interface NxRemixGeneratorSchema {
14
14
  nxCloudToken?: string;
15
15
  useTsSolution?: boolean;
16
16
  formatter?: 'prettier' | 'none';
17
+ useProjectJson?: boolean;
17
18
  }
@@ -57,6 +57,10 @@
57
57
  "type": "boolean",
58
58
  "x-priority": "internal",
59
59
  "default": false
60
+ },
61
+ "useProjectJson": {
62
+ "type": "boolean",
63
+ "description": "Use a `project.json` configuration file instead of inlining the Nx configuration in the `package.json` file."
60
64
  }
61
65
  },
62
66
  "required": ["directory"]
@@ -28,7 +28,7 @@ import react from '@vitejs/plugin-react';
28
28
  import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
29
29
  import { nxCopyAssetsPlugin } from '@nx/vite/plugins/nx-copy-assets.plugin';
30
30
 
31
- export default defineConfig({
31
+ export default defineConfig(() => ({
32
32
  root: __dirname,
33
33
  cacheDir: '../node_modules/.vite/test',
34
34
  plugins: [react(), nxViteTsPaths(), nxCopyAssetsPlugin(['*.md'])],
@@ -43,9 +43,12 @@ export default defineConfig({
43
43
  environment: 'jsdom',
44
44
  include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
45
45
  reporters: ['default'],
46
- coverage: { reportsDirectory: '../coverage/test', provider: 'v8' },
46
+ coverage: {
47
+ reportsDirectory: '../coverage/test',
48
+ provider: 'v8' as const,
49
+ },
47
50
  },
48
- });
51
+ }));
49
52
  "
50
53
  `;
51
54
 
@@ -3,19 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addTsconfigEntryPoints = addTsconfigEntryPoints;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const js_1 = require("@nx/js");
6
- const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
6
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
7
7
  function addTsconfigEntryPoints(tree, options) {
8
8
  const { root: projectRoot, sourceRoot } = (0, devkit_1.readProjectConfiguration)(tree, options.projectName);
9
- const serverFilePath = (0, devkit_1.joinPathFragments)(...(sourceRoot ? [sourceRoot] : [projectRoot, 'src']), 'server.ts');
9
+ const projectSourceRoot = (0, ts_solution_setup_1.getProjectSourceRoot)(tree, sourceRoot, projectRoot);
10
+ const serverFilePath = (0, devkit_1.joinPathFragments)(projectSourceRoot, 'server.ts');
10
11
  tree.write(serverFilePath, `// This file should be used to export ONLY server-code from the library.`);
11
12
  const baseTsConfig = (0, js_1.getRootTsConfigPathInTree)(tree);
12
- // Use same logic as `determineProjectNameAndRootOptions` to get the import path
13
- const importPath = (0, project_name_and_root_utils_1.resolveImportPath)(tree, options.name, projectRoot);
14
13
  (0, devkit_1.updateJson)(tree, baseTsConfig, (json) => {
15
- if (json.compilerOptions.paths && json.compilerOptions.paths[importPath]) {
16
- json.compilerOptions.paths[(0, devkit_1.joinPathFragments)(importPath, 'server')] = [
17
- serverFilePath,
18
- ];
14
+ if (json.compilerOptions.paths &&
15
+ json.compilerOptions.paths[options.importPath]) {
16
+ json.compilerOptions.paths[(0, devkit_1.joinPathFragments)(options.importPath, 'server')] = [serverFilePath];
19
17
  }
20
18
  return json;
21
19
  });
@@ -4,10 +4,9 @@ exports.normalizeOptions = normalizeOptions;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
6
6
  const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
7
- const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
8
7
  async function normalizeOptions(tree, options) {
9
- await (0, project_name_and_root_utils_1.ensureProjectName)(tree, options, 'application');
10
- const { projectName, projectRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
8
+ await (0, project_name_and_root_utils_1.ensureRootProjectName)(options, 'application');
9
+ const { projectName, projectRoot, importPath } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
11
10
  name: options.name,
12
11
  projectType: 'library',
13
12
  directory: options.directory,
@@ -20,10 +19,10 @@ async function normalizeOptions(tree, options) {
20
19
  return {
21
20
  ...options,
22
21
  unitTestRunner: options.unitTestRunner ?? 'vitest',
23
- projectName: isUsingTsSolutionConfig
24
- ? (0, get_import_path_1.getImportPath)(tree, projectName)
25
- : projectName,
22
+ projectName: isUsingTsSolutionConfig && !options.name ? importPath : projectName,
26
23
  projectRoot,
24
+ importPath,
27
25
  isUsingTsSolutionConfig,
26
+ useProjectJson: options.useProjectJson ?? !isUsingTsSolutionConfig,
28
27
  };
29
28
  }
@@ -13,7 +13,7 @@ function updateBuildableConfig(tree, options) {
13
13
  format: ['cjs'],
14
14
  outputPath: (0, devkit_1.joinPathFragments)(project.root, 'dist'),
15
15
  };
16
- (0, devkit_1.updateProjectConfiguration)(tree, options.name, project);
16
+ (0, devkit_1.updateProjectConfiguration)(tree, options.projectName, project);
17
17
  // Point to nested dist for yarn/npm/pnpm workspaces
18
18
  (0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(project.root, 'package.json'), (json) => {
19
19
  json.main = './dist/index.cjs.js';
@@ -9,13 +9,17 @@ const lib_1 = require("./lib");
9
9
  const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
10
10
  const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields");
11
11
  async function remixLibraryGenerator(tree, schema) {
12
- return remixLibraryGeneratorInternal(tree, { addPlugin: false, ...schema });
12
+ return remixLibraryGeneratorInternal(tree, {
13
+ addPlugin: false,
14
+ useProjectJson: true,
15
+ ...schema,
16
+ });
13
17
  }
14
18
  async function remixLibraryGeneratorInternal(tree, schema) {
15
19
  const tasks = [];
16
20
  const options = await (0, lib_1.normalizeOptions)(tree, schema);
17
21
  if (options.isUsingTsSolutionConfig) {
18
- (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(tree, options.projectRoot);
22
+ await (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(tree, options.projectRoot);
19
23
  }
20
24
  const jsInitTask = await (0, js_1.initGenerator)(tree, {
21
25
  js: options.js,
@@ -36,6 +40,7 @@ async function remixLibraryGeneratorInternal(tree, schema) {
36
40
  buildable: options.buildable,
37
41
  bundler: options.bundler,
38
42
  addPlugin: options.addPlugin,
43
+ useProjectJson: options.useProjectJson,
39
44
  });
40
45
  tasks.push(libGenTask);
41
46
  if (options.unitTestRunner && options.unitTestRunner !== 'none') {
@@ -14,4 +14,5 @@ export interface NxRemixGeneratorSchema {
14
14
  js?: boolean;
15
15
  skipFormat?: boolean;
16
16
  addPlugin?: boolean;
17
+ useProjectJson?: boolean;
17
18
  }
@@ -81,6 +81,10 @@
81
81
  "default": false,
82
82
  "description": "Generate a buildable library that uses rollup to bundle.",
83
83
  "x-deprecated": "Use the `bundler` option for greater control (none, vite, rollup)."
84
+ },
85
+ "useProjectJson": {
86
+ "type": "boolean",
87
+ "description": "Use a `project.json` configuration file instead of inlining the Nx configuration in the `package.json` file."
84
88
  }
85
89
  },
86
90
  "required": ["directory"]
@@ -92,7 +92,7 @@ import react from '@vitejs/plugin-react';
92
92
  import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
93
93
  import { nxCopyAssetsPlugin } from '@nx/vite/plugins/nx-copy-assets.plugin';
94
94
 
95
- export default defineConfig({
95
+ export default defineConfig(() => ({
96
96
  root: __dirname,
97
97
  cacheDir: '../../node_modules/.vite/libs/storybook-test',
98
98
  plugins: [react(), nxViteTsPaths(), nxCopyAssetsPlugin(['*.md'])],
@@ -109,10 +109,10 @@ export default defineConfig({
109
109
  reporters: ['default'],
110
110
  coverage: {
111
111
  reportsDirectory: '../../coverage/libs/storybook-test',
112
- provider: 'v8',
112
+ provider: 'v8' as const,
113
113
  },
114
114
  },
115
- });
115
+ }));
116
116
  "
117
117
  `;
118
118
 
@@ -40,12 +40,14 @@ exports[`@nx/remix/plugin Remix Classic Compiler non-root project should create
40
40
  },
41
41
  "dev": {
42
42
  "command": "remix dev --manual",
43
+ "continuous": true,
43
44
  "options": {
44
45
  "cwd": "my-app",
45
46
  },
46
47
  },
47
48
  "serve-static": {
48
49
  "command": "remix-serve build/index.js",
50
+ "continuous": true,
49
51
  "dependsOn": [
50
52
  "build",
51
53
  ],
@@ -55,6 +57,7 @@ exports[`@nx/remix/plugin Remix Classic Compiler non-root project should create
55
57
  },
56
58
  "start": {
57
59
  "command": "remix-serve build/index.js",
60
+ "continuous": true,
58
61
  "dependsOn": [
59
62
  "build",
60
63
  ],
@@ -64,6 +67,7 @@ exports[`@nx/remix/plugin Remix Classic Compiler non-root project should create
64
67
  },
65
68
  "static-serve": {
66
69
  "command": "remix-serve build/index.js",
70
+ "continuous": true,
67
71
  "dependsOn": [
68
72
  "build",
69
73
  ],
@@ -103,6 +107,7 @@ exports[`@nx/remix/plugin Remix Classic Compiler non-root project should create
103
107
  },
104
108
  "watch-deps": {
105
109
  "command": "npx nx watch --projects my-app --includeDependentProjects -- npx nx build-deps my-app",
110
+ "continuous": true,
106
111
  "dependsOn": [
107
112
  "build-deps",
108
113
  ],
@@ -155,12 +160,14 @@ exports[`@nx/remix/plugin Remix Classic Compiler non-root project should infer w
155
160
  },
156
161
  "dev": {
157
162
  "command": "remix dev --manual",
163
+ "continuous": true,
158
164
  "options": {
159
165
  "cwd": "my-app",
160
166
  },
161
167
  },
162
168
  "serve-static": {
163
169
  "command": "remix-serve build/index.js",
170
+ "continuous": true,
164
171
  "dependsOn": [
165
172
  "build",
166
173
  ],
@@ -170,6 +177,7 @@ exports[`@nx/remix/plugin Remix Classic Compiler non-root project should infer w
170
177
  },
171
178
  "start": {
172
179
  "command": "remix-serve build/index.js",
180
+ "continuous": true,
173
181
  "dependsOn": [
174
182
  "build",
175
183
  ],
@@ -179,6 +187,7 @@ exports[`@nx/remix/plugin Remix Classic Compiler non-root project should infer w
179
187
  },
180
188
  "static-serve": {
181
189
  "command": "remix-serve build/index.js",
190
+ "continuous": true,
182
191
  "dependsOn": [
183
192
  "build",
184
193
  ],
@@ -218,6 +227,7 @@ exports[`@nx/remix/plugin Remix Classic Compiler non-root project should infer w
218
227
  },
219
228
  "watch-deps": {
220
229
  "command": "npx nx watch --projects my-app --includeDependentProjects -- npx nx build-deps my-app",
230
+ "continuous": true,
221
231
  "dependsOn": [
222
232
  "build-deps",
223
233
  ],
@@ -265,12 +275,14 @@ exports[`@nx/remix/plugin Remix Classic Compiler root project should create node
265
275
  },
266
276
  "dev": {
267
277
  "command": "remix dev --manual",
278
+ "continuous": true,
268
279
  "options": {
269
280
  "cwd": ".",
270
281
  },
271
282
  },
272
283
  "serve-static": {
273
284
  "command": "remix-serve build/index.js",
285
+ "continuous": true,
274
286
  "dependsOn": [
275
287
  "build",
276
288
  ],
@@ -280,6 +292,7 @@ exports[`@nx/remix/plugin Remix Classic Compiler root project should create node
280
292
  },
281
293
  "start": {
282
294
  "command": "remix-serve build/index.js",
295
+ "continuous": true,
283
296
  "dependsOn": [
284
297
  "build",
285
298
  ],
@@ -289,6 +302,7 @@ exports[`@nx/remix/plugin Remix Classic Compiler root project should create node
289
302
  },
290
303
  "static-serve": {
291
304
  "command": "remix-serve build/index.js",
305
+ "continuous": true,
292
306
  "dependsOn": [
293
307
  "build",
294
308
  ],
@@ -373,12 +387,14 @@ exports[`@nx/remix/plugin Remix Vite Compiler non-root project should create nod
373
387
  },
374
388
  "dev": {
375
389
  "command": "remix vite:dev",
390
+ "continuous": true,
376
391
  "options": {
377
392
  "cwd": "my-app",
378
393
  },
379
394
  },
380
395
  "serve-static": {
381
396
  "command": "remix-serve build/server/index.js",
397
+ "continuous": true,
382
398
  "dependsOn": [
383
399
  "build",
384
400
  ],
@@ -388,6 +404,7 @@ exports[`@nx/remix/plugin Remix Vite Compiler non-root project should create nod
388
404
  },
389
405
  "start": {
390
406
  "command": "remix-serve build/server/index.js",
407
+ "continuous": true,
391
408
  "dependsOn": [
392
409
  "build",
393
410
  ],
@@ -397,6 +414,7 @@ exports[`@nx/remix/plugin Remix Vite Compiler non-root project should create nod
397
414
  },
398
415
  "static-serve": {
399
416
  "command": "remix-serve build/server/index.js",
417
+ "continuous": true,
400
418
  "dependsOn": [
401
419
  "build",
402
420
  ],
@@ -436,6 +454,7 @@ exports[`@nx/remix/plugin Remix Vite Compiler non-root project should create nod
436
454
  },
437
455
  "watch-deps": {
438
456
  "command": "npx nx watch --projects my-app --includeDependentProjects -- npx nx build-deps my-app",
457
+ "continuous": true,
439
458
  "dependsOn": [
440
459
  "build-deps",
441
460
  ],
@@ -482,12 +501,14 @@ exports[`@nx/remix/plugin Remix Vite Compiler root project should create nodes 1
482
501
  },
483
502
  "dev": {
484
503
  "command": "remix vite:dev",
504
+ "continuous": true,
485
505
  "options": {
486
506
  "cwd": ".",
487
507
  },
488
508
  },
489
509
  "serve-static": {
490
510
  "command": "remix-serve build/server/index.js",
511
+ "continuous": true,
491
512
  "dependsOn": [
492
513
  "build",
493
514
  ],
@@ -497,6 +518,7 @@ exports[`@nx/remix/plugin Remix Vite Compiler root project should create nodes 1
497
518
  },
498
519
  "start": {
499
520
  "command": "remix-serve build/server/index.js",
521
+ "continuous": true,
500
522
  "dependsOn": [
501
523
  "build",
502
524
  ],
@@ -506,6 +528,7 @@ exports[`@nx/remix/plugin Remix Vite Compiler root project should create nodes 1
506
528
  },
507
529
  "static-serve": {
508
530
  "command": "remix-serve build/server/index.js",
531
+ "continuous": true,
509
532
  "dependsOn": [
510
533
  "build",
511
534
  ],
@@ -127,6 +127,7 @@ function buildTarget(buildTargetName, projectRoot, buildDirectory, assetsBuildDi
127
127
  }
128
128
  function devTarget(serverBuildPath, projectRoot, remixCompiler, isUsingTsSolutionSetup) {
129
129
  const devTarget = {
130
+ continuous: true,
130
131
  command: remixCompiler === RemixCompiler.IsVte
131
132
  ? 'remix vite:dev'
132
133
  : 'remix dev --manual',
@@ -146,6 +147,7 @@ function startTarget(projectRoot, serverBuildPath, buildTargetName, remixCompile
146
147
  }
147
148
  const startTarget = {
148
149
  dependsOn: [buildTargetName],
150
+ continuous: true,
149
151
  command: `remix-serve ${serverPath}`,
150
152
  options: {
151
153
  cwd: projectRoot,
@@ -1,6 +1,6 @@
1
1
  import { Tree } from '@nx/devkit';
2
2
  export declare const nxVersion: any;
3
- export declare const remixVersion = "^2.14.0";
3
+ export declare const remixVersion = "^2.15.0";
4
4
  export declare const isbotVersion = "^4.4.0";
5
5
  export declare const reactVersion = "^18.2.0";
6
6
  export declare const reactDomVersion = "^18.2.0";
@@ -13,6 +13,7 @@ export declare const postcssVersion = "^8.4.38";
13
13
  export declare const autoprefixerVersion = "^10.4.19";
14
14
  export declare const testingLibraryReactVersion = "^14.1.2";
15
15
  export declare const testingLibraryJestDomVersion = "6.4.2";
16
+ export declare const testingLibraryDomVersion = "^10.4.0";
16
17
  export declare const testingLibraryUserEventsVersion = "^14.5.2";
17
18
  export declare const viteVersion = "^5.0.0";
18
19
  export declare function getRemixVersion(tree: Tree): string;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.viteVersion = exports.testingLibraryUserEventsVersion = exports.testingLibraryJestDomVersion = exports.testingLibraryReactVersion = exports.autoprefixerVersion = exports.postcssVersion = exports.tailwindVersion = exports.typescriptVersion = exports.eslintVersion = exports.typesReactDomVersion = exports.typesReactVersion = exports.reactDomVersion = exports.reactVersion = exports.isbotVersion = exports.remixVersion = exports.nxVersion = void 0;
3
+ exports.viteVersion = exports.testingLibraryUserEventsVersion = exports.testingLibraryDomVersion = exports.testingLibraryJestDomVersion = exports.testingLibraryReactVersion = exports.autoprefixerVersion = exports.postcssVersion = exports.tailwindVersion = exports.typescriptVersion = exports.eslintVersion = exports.typesReactDomVersion = exports.typesReactVersion = exports.reactDomVersion = exports.reactVersion = exports.isbotVersion = exports.remixVersion = exports.nxVersion = void 0;
4
4
  exports.getRemixVersion = getRemixVersion;
5
5
  exports.getPackageVersion = getPackageVersion;
6
6
  const devkit_1 = require("@nx/devkit");
7
7
  exports.nxVersion = require('../../package.json').version;
8
- exports.remixVersion = '^2.14.0';
8
+ exports.remixVersion = '^2.15.0';
9
9
  exports.isbotVersion = '^4.4.0';
10
10
  exports.reactVersion = '^18.2.0';
11
11
  exports.reactDomVersion = '^18.2.0';
@@ -19,6 +19,7 @@ exports.autoprefixerVersion = '^10.4.19';
19
19
  exports.testingLibraryReactVersion = '^14.1.2';
20
20
  // TODO(colum): Unpin this when @testing-library/jest-dom pushes a fix
21
21
  exports.testingLibraryJestDomVersion = '6.4.2';
22
+ exports.testingLibraryDomVersion = '^10.4.0';
22
23
  exports.testingLibraryUserEventsVersion = '^14.5.2';
23
24
  exports.viteVersion = '^5.0.0';
24
25
  function getRemixVersion(tree) {
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export declare function addViteTempFilesToGitIgnore(tree: Tree): void;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addViteTempFilesToGitIgnore = addViteTempFilesToGitIgnore;
4
- const devkit_1 = require("@nx/devkit");
5
- function addViteTempFilesToGitIgnore(tree) {
6
- let newGitIgnoreContents = `vite.config.*.timestamp*`;
7
- if (tree.exists('.gitignore')) {
8
- const gitIgnoreContents = tree.read('.gitignore', 'utf-8');
9
- if (!gitIgnoreContents.includes(newGitIgnoreContents)) {
10
- newGitIgnoreContents = (0, devkit_1.stripIndents) `${gitIgnoreContents}
11
- ${newGitIgnoreContents}`;
12
- tree.write('.gitignore', newGitIgnoreContents);
13
- }
14
- }
15
- else {
16
- tree.write('.gitignore', newGitIgnoreContents);
17
- }
18
- }