@nx/react 0.0.0-pr-29464-ef5660f → 0.0.0-pr-29720-06f67e5

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 (51) hide show
  1. package/package.json +6 -6
  2. package/src/generators/application/application.js +9 -48
  3. package/src/generators/application/lib/add-e2e.js +24 -29
  4. package/src/generators/application/lib/add-linting.d.ts +0 -1
  5. package/src/generators/application/lib/add-linting.js +0 -38
  6. package/src/generators/application/lib/add-project.js +15 -31
  7. package/src/generators/application/lib/add-routing.js +1 -1
  8. package/src/generators/application/lib/bundlers/add-vite.js +6 -15
  9. package/src/generators/application/lib/create-application-files.js +4 -41
  10. package/src/generators/application/lib/install-common-dependencies.js +2 -13
  11. package/src/generators/application/lib/normalize-options.d.ts +2 -0
  12. package/src/generators/application/lib/normalize-options.js +20 -11
  13. package/src/generators/application/schema.d.ts +1 -5
  14. package/src/generators/application/schema.json +1 -10
  15. package/src/generators/host/host.js +3 -6
  16. package/src/generators/init/init.js +0 -23
  17. package/src/generators/init/schema.d.ts +0 -2
  18. package/src/generators/library/lib/add-rollup-build-target.d.ts +1 -3
  19. package/src/generators/library/lib/add-rollup-build-target.js +7 -6
  20. package/src/generators/library/lib/create-files.js +1 -2
  21. package/src/generators/library/lib/normalize-options.js +5 -8
  22. package/src/generators/library/library.js +15 -21
  23. package/src/generators/library/schema.d.ts +0 -2
  24. package/src/generators/library/schema.json +0 -4
  25. package/src/generators/remote/remote.js +9 -12
  26. package/src/utils/ast-utils.d.ts +1 -1
  27. package/src/utils/ast-utils.js +2 -2
  28. package/src/utils/versions.d.ts +1 -3
  29. package/src/utils/versions.js +3 -6
  30. package/router-plugin.d.ts +0 -1
  31. package/router-plugin.js +0 -5
  32. package/src/generators/application/files/react-router-ssr/common/app/app-nav.tsx__tmpl__ +0 -15
  33. package/src/generators/application/files/react-router-ssr/common/app/entry.client.tsx__tmpl__ +0 -18
  34. package/src/generators/application/files/react-router-ssr/common/app/entry.server.tsx__tmpl__ +0 -74
  35. package/src/generators/application/files/react-router-ssr/common/app/root.tsx__tmpl__ +0 -51
  36. package/src/generators/application/files/react-router-ssr/common/app/routes/about.tsx__tmpl__ +0 -7
  37. package/src/generators/application/files/react-router-ssr/common/app/routes.tsx__tmpl__ +0 -6
  38. package/src/generators/application/files/react-router-ssr/common/public/favicon.ico +0 -0
  39. package/src/generators/application/files/react-router-ssr/common/react-router.config.ts__tmpl__ +0 -5
  40. package/src/generators/application/files/react-router-ssr/common/tests/routes/_index.spec.tsx__tmpl__ +0 -16
  41. package/src/generators/application/files/react-router-ssr/common/tsconfig.app.json__tmpl__ +0 -23
  42. package/src/generators/application/files/react-router-ssr/common/tsconfig.json__tmpl__ +0 -27
  43. package/src/generators/application/files/react-router-ssr/non-root/.gitignore__tmpl__ +0 -5
  44. package/src/generators/application/files/react-router-ssr/non-root/package.json__tmpl__ +0 -24
  45. package/src/generators/application/files/react-router-ssr/nx-welcome/claimed/app/nx-welcome.tsx__tmpl__ +0 -866
  46. package/src/generators/application/files/react-router-ssr/nx-welcome/not-configured/app/nx-welcome.tsx__tmpl__ +0 -866
  47. package/src/generators/application/files/react-router-ssr/nx-welcome/unclaimed/app/nx-welcome.tsx__tmpl__ +0 -864
  48. package/src/generators/application/files/react-router-ssr/ts-solution/package.json__tmpl__ +0 -24
  49. package/src/generators/application/files/react-router-ssr/ts-solution/tsconfig.app.json__tmpl__ +0 -39
  50. package/src/plugins/router-plugin.d.ts +0 -10
  51. package/src/plugins/router-plugin.js +0 -219
@@ -19,10 +19,7 @@ const update_module_federation_tsconfig_1 = require("./lib/update-module-federat
19
19
  async function hostGenerator(host, schema) {
20
20
  const tasks = [];
21
21
  const options = {
22
- ...(await (0, normalize_options_1.normalizeOptions)(host, {
23
- ...schema,
24
- useProjectJson: true,
25
- })),
22
+ ...(await (0, normalize_options_1.normalizeOptions)(host, schema)),
26
23
  js: schema.js ?? false,
27
24
  typescriptConfiguration: schema.js
28
25
  ? false
@@ -42,7 +39,7 @@ async function hostGenerator(host, schema) {
42
39
  }
43
40
  });
44
41
  }
45
- await (0, project_name_and_root_utils_1.ensureRootProjectName)(options, 'application');
42
+ await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
46
43
  const initTask = await (0, application_1.default)(host, {
47
44
  ...options,
48
45
  directory: options.appProjectRoot,
@@ -50,7 +47,7 @@ async function hostGenerator(host, schema) {
50
47
  // The target use-case is loading remotes as child routes, thus always enable routing.
51
48
  routing: true,
52
49
  skipFormat: true,
53
- useProjectJson: true,
50
+ alwaysGenerateProjectJson: true,
54
51
  });
55
52
  tasks.push(initTask);
56
53
  const remotesWithPorts = [];
@@ -4,8 +4,6 @@ exports.reactInitGenerator = reactInitGenerator;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const versions_1 = require("../../utils/versions");
6
6
  const version_utils_1 = require("../../utils/version-utils");
7
- const add_plugin_1 = require("@nx/devkit/src/utils/add-plugin");
8
- const router_plugin_1 = require("../../plugins/router-plugin");
9
7
  async function reactInitGenerator(tree, schema) {
10
8
  const tasks = [];
11
9
  if (!schema.skipPackageJson) {
@@ -18,27 +16,6 @@ async function reactInitGenerator(tree, schema) {
18
16
  '@nx/react': versions_1.nxVersion,
19
17
  }, undefined, schema.keepExistingVersions));
20
18
  }
21
- const nxJson = (0, devkit_1.readNxJson)(tree);
22
- schema.addPlugin ??=
23
- process.env.NX_ADD_PLUGINS !== 'false' &&
24
- nxJson.useInferencePlugins !== false;
25
- if (schema.addPlugin) {
26
- await (0, add_plugin_1.addPlugin)(tree, await (0, devkit_1.createProjectGraphAsync)(), '@nx/react/router-plugin', router_plugin_1.createNodesV2, {
27
- buildTargetName: ['build', 'react-router:build', 'react-router-build'],
28
- devTargetName: ['dev', 'react-router:dev', 'react-router-dev'],
29
- startTargetName: ['start', 'react-router-serve', 'react-router-start'],
30
- watchDepsTargetName: [
31
- 'watch-deps',
32
- 'react-router:watch-deps',
33
- 'react-router-watch-deps',
34
- ],
35
- buildDepsTargetName: [
36
- 'build-deps',
37
- 'react-router:build-deps',
38
- 'react-router-build-deps',
39
- ],
40
- }, schema.updatePackageScripts);
41
- }
42
19
  if (!schema.skipFormat) {
43
20
  await (0, devkit_1.formatFiles)(tree);
44
21
  }
@@ -2,6 +2,4 @@ export interface InitSchema {
2
2
  skipFormat?: boolean;
3
3
  skipPackageJson?: boolean;
4
4
  keepExistingVersions?: boolean;
5
- updatePackageScripts?: boolean;
6
- addPlugin?: boolean;
7
5
  }
@@ -1,6 +1,4 @@
1
1
  import { Tree } from 'nx/src/generators/tree';
2
2
  import { GeneratorCallback } from '@nx/devkit';
3
3
  import { NormalizedSchema } from '../schema';
4
- export declare function addRollupBuildTarget(host: Tree, options: NormalizedSchema & {
5
- format?: Array<'esm' | 'cjs'>;
6
- }, external?: Set<String>): Promise<GeneratorCallback>;
4
+ export declare function addRollupBuildTarget(host: Tree, options: NormalizedSchema): Promise<GeneratorCallback>;
@@ -4,7 +4,7 @@ exports.addRollupBuildTarget = addRollupBuildTarget;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const maybe_js_1 = require("../../../utils/maybe-js");
6
6
  const versions_1 = require("../../../utils/versions");
7
- async function addRollupBuildTarget(host, options, external = new Set(['react', 'react-dom'])) {
7
+ async function addRollupBuildTarget(host, options) {
8
8
  const tasks = [];
9
9
  const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/rollup', versions_1.nxVersion);
10
10
  tasks.push(await configurationGenerator(host, {
@@ -19,11 +19,12 @@ async function addRollupBuildTarget(host, options, external = new Set(['react',
19
19
  '@svgr/rollup': versions_1.svgrRollupVersion,
20
20
  }));
21
21
  }
22
+ const external = ['react', 'react-dom'];
22
23
  if (options.style === '@emotion/styled') {
23
- external.add('@emotion/react/jsx-runtime');
24
+ external.push('@emotion/react/jsx-runtime');
24
25
  }
25
26
  else {
26
- external.add('react/jsx-runtime');
27
+ external.push('react/jsx-runtime');
27
28
  }
28
29
  const nxJson = (0, devkit_1.readNxJson)(host);
29
30
  const hasRollupPlugin = !!nxJson.plugins?.some((p) => typeof p === 'string'
@@ -43,8 +44,8 @@ module.exports = withNx(
43
44
  : (0, devkit_1.joinPathFragments)((0, devkit_1.offsetFromRoot)(options.projectRoot), 'dist', options.projectRoot)}',
44
45
  tsConfig: './tsconfig.lib.json',
45
46
  compiler: '${options.compiler ?? 'babel'}',
46
- external: ${JSON.stringify(Array.from(external))},
47
- format: ${JSON.stringify(options.format ?? ['esm'])},
47
+ external: ${JSON.stringify(external)},
48
+ format: ['esm'],
48
49
  assets:[{ input: '.', output: '.', glob: 'README.md'}],
49
50
  }, {
50
51
  // Provide additional rollup configuration here. See: https://rollupjs.org/configuration-options
@@ -73,7 +74,7 @@ module.exports = withNx(
73
74
  tsConfig: `${options.projectRoot}/tsconfig.lib.json`,
74
75
  project: `${options.projectRoot}/package.json`,
75
76
  entryFile: (0, maybe_js_1.maybeJs)(options, `${options.projectRoot}/src/index.ts`),
76
- external: Array.from(external),
77
+ external,
77
78
  rollupConfig: `@nx/react/plugins/bundle-rollup`,
78
79
  compiler: options.compiler ?? 'babel',
79
80
  assets: [
@@ -43,8 +43,7 @@ function createFiles(host, options) {
43
43
  });
44
44
  }
45
45
  if ((options.publishable || options.buildable) &&
46
- !options.isUsingTsSolutionConfig &&
47
- options.useProjectJson) {
46
+ !options.isUsingTsSolutionConfig) {
48
47
  if (options.bundler === 'vite') {
49
48
  (0, devkit_1.writeJson)(host, `${options.projectRoot}/package.json`, {
50
49
  name: options.importPath,
@@ -7,7 +7,7 @@ const assertion_1 = require("../../../utils/assertion");
7
7
  const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
8
8
  async function normalizeOptions(host, options) {
9
9
  const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
10
- await (0, project_name_and_root_utils_1.ensureRootProjectName)(options, 'library');
10
+ await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'library');
11
11
  const { projectName, names: projectNames, projectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
12
12
  name: options.name,
13
13
  projectType: 'library',
@@ -41,26 +41,23 @@ async function normalizeOptions(host, options) {
41
41
  bundler,
42
42
  fileName,
43
43
  routePath: `/${projectNames.projectSimpleName}`,
44
- name: isUsingTsSolutionConfig && !options.name ? importPath : projectName,
44
+ name: isUsingTsSolutionConfig ? importPath : projectName,
45
45
  projectRoot,
46
46
  parsedTags,
47
47
  importPath,
48
- useProjectJson: options.useProjectJson ?? !isUsingTsSolutionConfig,
49
48
  };
50
49
  // Libraries with a bundler or is publishable must also be buildable.
51
50
  normalized.buildable = Boolean(normalized.bundler !== 'none' || options.buildable || options.publishable);
52
51
  normalized.inSourceTests === normalized.minimal || normalized.inSourceTests;
53
52
  if (options.appProject) {
54
53
  const appProjectConfig = (0, devkit_1.getProjects)(host).get(options.appProject);
55
- const appProjectType = (0, ts_solution_setup_1.getProjectType)(host, appProjectConfig.root, appProjectConfig.projectType);
56
- if (appProjectType !== 'application') {
57
- throw new Error(`appProject expected type of "application" but got "${appProjectType}"`);
54
+ if (appProjectConfig.projectType !== 'application') {
55
+ throw new Error(`appProject expected type of "application" but got "${appProjectConfig.projectType}"`);
58
56
  }
59
- const appSourceRoot = (0, ts_solution_setup_1.getProjectSourceRoot)(host, appProjectConfig.sourceRoot, appProjectConfig.root);
60
57
  normalized.appMain =
61
58
  appProjectConfig.targets.build?.options?.main ??
62
59
  findMainEntry(host, appProjectConfig.root);
63
- normalized.appSourceRoot = (0, devkit_1.normalizePath)(appSourceRoot);
60
+ normalized.appSourceRoot = (0, devkit_1.normalizePath)(appProjectConfig.sourceRoot);
64
61
  // TODO(jack): We should use appEntryFile instead of appProject so users can directly set it rather than us inferring it.
65
62
  if (!normalized.appMain) {
66
63
  throw new Error(`Could not locate project main for ${options.appProject}`);
@@ -27,7 +27,6 @@ const add_release_config_1 = require("@nx/js/src/generators/library/utils/add-re
27
27
  async function libraryGenerator(host, schema) {
28
28
  return await libraryGeneratorInternal(host, {
29
29
  addPlugin: false,
30
- useProjectJson: true,
31
30
  ...schema,
32
31
  });
33
32
  }
@@ -39,6 +38,9 @@ async function libraryGeneratorInternal(host, schema) {
39
38
  });
40
39
  tasks.push(jsInitTask);
41
40
  const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
41
+ if (options.isUsingTsSolutionConfig) {
42
+ (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.projectRoot);
43
+ }
42
44
  if (options.publishable === true && !schema.importPath) {
43
45
  throw new Error(`For publishable libs you have to provide a proper "--importPath" which needs to be a valid npm package name (e.g. my-awesome-lib or @myorg/my-lib)`);
44
46
  }
@@ -50,20 +52,18 @@ async function libraryGeneratorInternal(host, schema) {
50
52
  skipFormat: true,
51
53
  });
52
54
  tasks.push(initTask);
53
- const packageJson = {
54
- name: options.importPath,
55
- version: '0.0.1',
56
- ...(0, determine_entry_fields_1.determineEntryFields)(options),
57
- files: options.publishable ? ['dist', '!**/*.tsbuildinfo'] : undefined,
58
- };
59
- if (!options.useProjectJson) {
60
- if (options.name !== options.importPath) {
61
- packageJson.nx = { name: options.name };
62
- }
63
- if (options.parsedTags?.length) {
64
- packageJson.nx ??= {};
65
- packageJson.nx.tags = options.parsedTags;
66
- }
55
+ if (options.isUsingTsSolutionConfig) {
56
+ (0, devkit_1.writeJson)(host, `${options.projectRoot}/package.json`, {
57
+ name: options.importPath ?? options.name,
58
+ version: '0.0.1',
59
+ ...(0, determine_entry_fields_1.determineEntryFields)(options),
60
+ nx: options.parsedTags?.length
61
+ ? {
62
+ tags: options.parsedTags,
63
+ }
64
+ : undefined,
65
+ files: options.publishable ? ['dist', '!**/*.tsbuildinfo'] : undefined,
66
+ });
67
67
  }
68
68
  else {
69
69
  (0, devkit_1.addProjectConfiguration)(host, options.name, {
@@ -74,13 +74,7 @@ async function libraryGeneratorInternal(host, schema) {
74
74
  targets: {},
75
75
  });
76
76
  }
77
- if (!options.useProjectJson || options.isUsingTsSolutionConfig) {
78
- (0, devkit_1.writeJson)(host, `${options.projectRoot}/package.json`, packageJson);
79
- }
80
77
  (0, create_files_1.createFiles)(host, options);
81
- if (options.isUsingTsSolutionConfig) {
82
- await (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.projectRoot);
83
- }
84
78
  const lintTask = await (0, add_linting_1.addLinting)(host, options);
85
79
  tasks.push(lintTask);
86
80
  // Set up build target
@@ -27,7 +27,6 @@ export interface Schema {
27
27
  minimal?: boolean;
28
28
  simpleName?: boolean;
29
29
  addPlugin?: boolean;
30
- useProjectJson?: boolean;
31
30
  }
32
31
 
33
32
  export interface NormalizedSchema extends Schema {
@@ -37,7 +36,6 @@ export interface NormalizedSchema extends Schema {
37
36
  projectRoot: string;
38
37
  routePath: string;
39
38
  parsedTags: string[];
40
- importPath: string;
41
39
  appMain?: string;
42
40
  appSourceRoot?: string;
43
41
  unitTestRunner: 'jest' | 'vitest' | 'none';
@@ -190,10 +190,6 @@
190
190
  "description": "Don't include the directory in the name of the module of the library.",
191
191
  "type": "boolean",
192
192
  "default": false
193
- },
194
- "useProjectJson": {
195
- "type": "boolean",
196
- "description": "Use a `project.json` configuration file instead of inlining the Nx configuration in the `package.json` file."
197
193
  }
198
194
  },
199
195
  "required": ["directory"]
@@ -48,10 +48,7 @@ function addModuleFederationFiles(host, options) {
48
48
  async function remoteGenerator(host, schema) {
49
49
  const tasks = [];
50
50
  const options = {
51
- ...(await (0, normalize_options_1.normalizeOptions)(host, {
52
- ...schema,
53
- useProjectJson: true,
54
- })),
51
+ ...(await (0, normalize_options_1.normalizeOptions)(host, schema)),
55
52
  // when js is set to true, we want to use the js configuration
56
53
  js: schema.js ?? false,
57
54
  typescriptConfiguration: schema.js
@@ -65,29 +62,29 @@ async function remoteGenerator(host, schema) {
65
62
  if (options.dynamic) {
66
63
  // Dynamic remotes generate with library { type: 'var' } by default.
67
64
  // We need to ensure that the remote name is a valid variable name.
68
- const isValidRemote = (0, js_1.isValidVariable)(options.projectName);
65
+ const isValidRemote = (0, js_1.isValidVariable)(options.name);
69
66
  if (!isValidRemote.isValid) {
70
- throw new Error(`Invalid remote name provided: ${options.projectName}. ${isValidRemote.message}`);
67
+ throw new Error(`Invalid remote name provided: ${options.name}. ${isValidRemote.message}`);
71
68
  }
72
69
  }
73
- await (0, project_name_and_root_utils_1.ensureRootProjectName)(options, 'application');
70
+ await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
74
71
  const REMOTE_NAME_REGEX = '^[a-zA-Z_$][a-zA-Z_$0-9]*$';
75
72
  const remoteNameRegex = new RegExp(REMOTE_NAME_REGEX);
76
- if (!remoteNameRegex.test(options.projectName)) {
77
- throw new Error((0, devkit_1.stripIndents) `Invalid remote name: ${options.projectName}. Remote project names must:
73
+ if (!remoteNameRegex.test(options.name)) {
74
+ throw new Error((0, devkit_1.stripIndents) `Invalid remote name: ${options.name}. Remote project names must:
78
75
  - Start with a letter, dollar sign ($) or underscore (_)
79
76
  - Followed by any valid character (letters, digits, underscores, or dollar signs)
80
77
  The regular expression used is ${REMOTE_NAME_REGEX}.`);
81
78
  }
82
79
  const initAppTask = await (0, application_1.default)(host, {
83
80
  ...options,
84
- name: options.projectName,
81
+ name: options.name,
85
82
  skipFormat: true,
86
- useProjectJson: true,
83
+ alwaysGenerateProjectJson: true,
87
84
  });
88
85
  tasks.push(initAppTask);
89
86
  if (options.host) {
90
- (0, update_host_with_remote_1.updateHostWithRemote)(host, options.host, options.projectName);
87
+ (0, update_host_with_remote_1.updateHostWithRemote)(host, options.host, options.name);
91
88
  }
92
89
  // Module federation requires bootstrap code to be dynamically imported.
93
90
  // Renaming original entry file so we can use `import(./bootstrap)` in
@@ -11,7 +11,7 @@ export declare function findComponentImportPath(componentName: string, source: t
11
11
  export declare function findElements(source: ts.SourceFile, tagName: string): ts.Node[];
12
12
  export declare function findClosestOpening(tagName: string, node: ts.Node): ts.Node;
13
13
  export declare function isTag(tagName: string, node: ts.Node): boolean;
14
- export declare function addInitialRoutes(sourcePath: string, source: ts.SourceFile, addBrowserRouter?: boolean): StringChange[];
14
+ export declare function addInitialRoutes(sourcePath: string, source: ts.SourceFile): StringChange[];
15
15
  export declare function addRoute(sourcePath: string, source: ts.SourceFile, options: {
16
16
  routePath: string;
17
17
  componentName: string;
@@ -234,7 +234,7 @@ function isTag(tagName, node) {
234
234
  }
235
235
  return false;
236
236
  }
237
- function addInitialRoutes(sourcePath, source, addBrowserRouter) {
237
+ function addInitialRoutes(sourcePath, source) {
238
238
  if (!tsModule) {
239
239
  tsModule = (0, ensure_typescript_1.ensureTypescript)();
240
240
  }
@@ -281,7 +281,7 @@ function addInitialRoutes(sourcePath, source, addBrowserRouter) {
281
281
  `,
282
282
  };
283
283
  return [
284
- ...addImport(source, `import { Route, Routes, Link ${addBrowserRouter ? ', BrowserRouter ' : ''}} from 'react-router-dom';`),
284
+ ...addImport(source, `import { Route, Routes, Link } from 'react-router-dom';`),
285
285
  insertRoutes,
286
286
  ];
287
287
  }
@@ -14,7 +14,7 @@ export declare const typesReactDomVersion = "19.0.0";
14
14
  export declare const typesReactIsV18Version = "18.3.0";
15
15
  export declare const typesReactIsVersion = "19.0.0";
16
16
  export declare const reactViteVersion = "^4.2.0";
17
- export declare const typesNodeVersion = "^20.0.0";
17
+ export declare const typesNodeVersion = "18.16.9";
18
18
  export declare const babelPresetReactVersion = "^7.14.5";
19
19
  export declare const babelCoreVersion = "^7.14.5";
20
20
  export declare const styledComponentsVersion = "5.3.6";
@@ -24,8 +24,6 @@ export declare const emotionReactVersion = "11.11.1";
24
24
  export declare const emotionBabelPlugin = "11.11.0";
25
25
  export declare const styledJsxVersion = "5.1.2";
26
26
  export declare const reactRouterDomVersion = "6.29.0";
27
- export declare const reactRouterVersion = "^7.2.0";
28
- export declare const reactRouterIsBotVersion = "^4.4.0";
29
27
  export declare const testingLibraryReactVersion = "16.1.0";
30
28
  export declare const testingLibraryDomVersion = "10.4.0";
31
29
  export declare const reduxjsToolkitVersion = "1.9.3";
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sassVersion = exports.lessVersion = exports.moduleFederationEnhancedVersion = exports.moduleFederationNodeVersion = exports.typesCorsVersion = exports.corsVersion = exports.isbotVersion = exports.typesExpressVersion = exports.expressVersion = exports.autoprefixerVersion = exports.tailwindcssVersion = exports.postcssVersion = exports.tsLibVersion = exports.babelPluginStyledComponentsVersion = exports.eslintPluginReactHooksVersion = exports.eslintPluginReactVersion = exports.eslintPluginJsxA11yVersion = exports.eslintPluginImportVersion = exports.reactReduxVersion = exports.reduxjsToolkitVersion = exports.testingLibraryDomVersion = exports.testingLibraryReactVersion = exports.reactRouterIsBotVersion = exports.reactRouterVersion = exports.reactRouterDomVersion = exports.styledJsxVersion = exports.emotionBabelPlugin = exports.emotionReactVersion = exports.emotionStyledVersion = exports.typesStyledComponentsVersion = exports.styledComponentsVersion = exports.babelCoreVersion = exports.babelPresetReactVersion = exports.typesNodeVersion = exports.reactViteVersion = exports.typesReactIsVersion = exports.typesReactIsV18Version = exports.typesReactDomVersion = exports.typesReactDomV18Version = exports.typesReactVersion = exports.typesReactV18Version = exports.babelLoaderVersion = exports.swcLoaderVersion = exports.reactIsV18Version = exports.reactIsVersion = exports.reactDomV18Version = exports.reactDomVersion = exports.reactV18Version = exports.reactVersion = exports.nxVersion = void 0;
4
- exports.swcPluginStyledComponentsVersion = exports.swcPluginEmotionVersion = exports.swcPluginStyledJsxVersion = exports.svgrRollupVersion = exports.rollupPluginUrlVersion = void 0;
3
+ exports.svgrRollupVersion = exports.rollupPluginUrlVersion = exports.sassVersion = exports.lessVersion = exports.moduleFederationEnhancedVersion = exports.moduleFederationNodeVersion = exports.typesCorsVersion = exports.corsVersion = exports.isbotVersion = exports.typesExpressVersion = exports.expressVersion = exports.autoprefixerVersion = exports.tailwindcssVersion = exports.postcssVersion = exports.tsLibVersion = exports.babelPluginStyledComponentsVersion = exports.eslintPluginReactHooksVersion = exports.eslintPluginReactVersion = exports.eslintPluginJsxA11yVersion = exports.eslintPluginImportVersion = exports.reactReduxVersion = exports.reduxjsToolkitVersion = exports.testingLibraryDomVersion = exports.testingLibraryReactVersion = exports.reactRouterDomVersion = exports.styledJsxVersion = exports.emotionBabelPlugin = exports.emotionReactVersion = exports.emotionStyledVersion = exports.typesStyledComponentsVersion = exports.styledComponentsVersion = exports.babelCoreVersion = exports.babelPresetReactVersion = exports.typesNodeVersion = exports.reactViteVersion = exports.typesReactIsVersion = exports.typesReactIsV18Version = exports.typesReactDomVersion = exports.typesReactDomV18Version = exports.typesReactVersion = exports.typesReactV18Version = exports.babelLoaderVersion = exports.swcLoaderVersion = exports.reactIsV18Version = exports.reactIsVersion = exports.reactDomV18Version = exports.reactDomVersion = exports.reactV18Version = exports.reactVersion = exports.nxVersion = void 0;
4
+ exports.swcPluginStyledComponentsVersion = exports.swcPluginEmotionVersion = exports.swcPluginStyledJsxVersion = void 0;
5
5
  exports.nxVersion = require('../../package.json').version;
6
6
  exports.reactVersion = '19.0.0';
7
7
  exports.reactV18Version = '18.3.1';
@@ -18,8 +18,7 @@ exports.typesReactDomVersion = '19.0.0';
18
18
  exports.typesReactIsV18Version = '18.3.0';
19
19
  exports.typesReactIsVersion = '19.0.0';
20
20
  exports.reactViteVersion = '^4.2.0';
21
- // Needed for React-Router
22
- exports.typesNodeVersion = '^20.0.0';
21
+ exports.typesNodeVersion = '18.16.9';
23
22
  exports.babelPresetReactVersion = '^7.14.5';
24
23
  exports.babelCoreVersion = '^7.14.5';
25
24
  exports.styledComponentsVersion = '5.3.6';
@@ -30,8 +29,6 @@ exports.emotionBabelPlugin = '11.11.0';
30
29
  // WARNING: This needs to be in sync with Next.js' dependency or else there might be issues.
31
30
  exports.styledJsxVersion = '5.1.2';
32
31
  exports.reactRouterDomVersion = '6.29.0';
33
- exports.reactRouterVersion = '^7.2.0';
34
- exports.reactRouterIsBotVersion = '^4.4.0';
35
32
  exports.testingLibraryReactVersion = '16.1.0';
36
33
  exports.testingLibraryDomVersion = '10.4.0';
37
34
  exports.reduxjsToolkitVersion = '1.9.3';
@@ -1 +0,0 @@
1
- export { createNodesV2, ReactRouterPluginOptions, } from './src/plugins/router-plugin';
package/router-plugin.js DELETED
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createNodesV2 = void 0;
4
- var router_plugin_1 = require("./src/plugins/router-plugin");
5
- Object.defineProperty(exports, "createNodesV2", { enumerable: true, get: function () { return router_plugin_1.createNodesV2; } });
@@ -1,15 +0,0 @@
1
- import * as React from "react";
2
- import { NavLink } from "react-router";
3
-
4
- export function AppNav() {
5
- return (
6
- <nav>
7
- <NavLink to="/" end>
8
- Home
9
- </NavLink>
10
- <NavLink to="/about" end>
11
- About
12
- </NavLink>
13
- </nav>
14
- );
15
- }
@@ -1,18 +0,0 @@
1
- /**
2
- * By default, React Router will handle hydrating your app on the client for you.
3
- * You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx react-router reveal` ✨
4
- * For more information, see https://reactrouter.com/explanation/special-files#entryclienttsx
5
- */
6
-
7
- import { HydratedRouter } from 'react-router/dom';
8
- import { startTransition, StrictMode } from "react";
9
- import { hydrateRoot } from "react-dom/client";
10
-
11
- startTransition(() => {
12
- hydrateRoot(
13
- document,
14
- <StrictMode>
15
- <HydratedRouter />
16
- </StrictMode>
17
- );
18
- });
@@ -1,74 +0,0 @@
1
- /**
2
- * By default, React Router will handle generating the HTTP Response for you.
3
- * You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨
4
- * For more information, see https://reactrouter.com/explanation/special-files#entryservertsx
5
- */
6
-
7
- import { PassThrough } from "node:stream";
8
-
9
- import type { AppLoadContext, EntryContext } from "react-router";
10
- import { createReadableStreamFromReadable } from "@react-router/node";
11
- import { ServerRouter } from "react-router";
12
- import { isbot } from "isbot";
13
- import type { RenderToPipeableStreamOptions } from "react-dom/server";
14
- import { renderToPipeableStream } from "react-dom/server";
15
-
16
- export const streamTimeout = 5_000;
17
-
18
- export default function handleRequest(
19
- request: Request,
20
- responseStatusCode: number,
21
- responseHeaders: Headers,
22
- routerContext: EntryContext,
23
- loadContext: AppLoadContext
24
- ) {
25
- return new Promise((resolve, reject) => {
26
- let shellRendered = false;
27
- const userAgent = request.headers.get("user-agent");
28
-
29
- // Ensure requests from bots and SPA Mode renders wait for all content to load before responding
30
- // https://react.dev/reference/react-dom/server/renderToPipeableStream#waiting-for-all-content-to-load-for-crawlers-and-static-generation
31
- const readyOption: keyof RenderToPipeableStreamOptions =
32
- (userAgent && isbot(userAgent)) || routerContext.isSpaMode
33
- ? "onAllReady"
34
- : "onShellReady";
35
-
36
- const { pipe, abort } = renderToPipeableStream(
37
- <ServerRouter context={routerContext} url={request.url} />,
38
- {
39
- [readyOption]() {
40
- shellRendered = true;
41
- const body = new PassThrough();
42
- const stream = createReadableStreamFromReadable(body);
43
-
44
- responseHeaders.set("Content-Type", "text/html");
45
-
46
- resolve(
47
- new Response(stream, {
48
- headers: responseHeaders,
49
- status: responseStatusCode,
50
- })
51
- );
52
-
53
- pipe(body);
54
- },
55
- onShellError(error: unknown) {
56
- reject(error);
57
- },
58
- onError(error: unknown) {
59
- responseStatusCode = 500;
60
- // Log streaming rendering errors from inside the shell. Don't log
61
- // errors encountered during initial shell rendering since they'll
62
- // reject and get logged in handleDocumentRequest.
63
- if (shellRendered) {
64
- console.error(error);
65
- }
66
- },
67
- }
68
- );
69
-
70
- // Abort the rendering stream after the `streamTimeout` so it has time to
71
- // flush down the rejected boundaries
72
- setTimeout(abort, streamTimeout + 1000);
73
- });
74
- }
@@ -1,51 +0,0 @@
1
- import {
2
- Links,
3
- Meta,
4
- Outlet,
5
- Scripts,
6
- ScrollRestoration,
7
- type MetaFunction,
8
- type LinksFunction
9
- } from "react-router";
10
-
11
- import { AppNav } from './app-nav'
12
-
13
- export const meta: MetaFunction = () => ([{
14
- title: "New Nx React Router App",
15
- }]);
16
-
17
- export const links: LinksFunction = () => [
18
- { rel: "preconnect", href: "https://fonts.googleapis.com" },
19
- {
20
- rel: "preconnect",
21
- href: "https://fonts.gstatic.com",
22
- crossOrigin: "anonymous",
23
- },
24
- {
25
- rel: "stylesheet",
26
- href: "https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap",
27
- },
28
- ];
29
-
30
- export function Layout({ children }: { children: React.ReactNode }) {
31
- return (
32
- <html lang="en">
33
- <head>
34
- <meta charSet="utf-8" />
35
- <meta name="viewport" content="width=device-width, initial-scale=1" />
36
- <Meta />
37
- <Links />
38
- </head>
39
- <body>
40
- <AppNav />
41
- {children}
42
- <ScrollRestoration />
43
- <Scripts />
44
- </body>
45
- </html>
46
- );
47
- }
48
-
49
- export default function App() {
50
- return <Outlet />;
51
- }
@@ -1,7 +0,0 @@
1
- export default function AboutComponent() {
2
- return (
3
- <div>
4
- <h1>About!!!</h1>
5
- </div>
6
- );
7
- }
@@ -1,6 +0,0 @@
1
- import { type RouteConfig, index, route } from "@react-router/dev/routes";
2
-
3
- export default [
4
- index('<%- js ? `./${fileName}.jsx` : `./${fileName}.tsx` %>'),
5
- route('about', './routes/about.tsx')
6
- ] satisfies RouteConfig;
@@ -1,5 +0,0 @@
1
- import type { Config } from "@react-router/dev/config";
2
-
3
- export default {
4
- ssr: true,
5
- } satisfies Config;
@@ -1,16 +0,0 @@
1
- import { createRoutesStub } from 'react-router';
2
- import { render, screen, waitFor } from '@testing-library/react';
3
- import App from '../../app/app';
4
-
5
- test('renders loader data', async () => {
6
- const ReactRouterStub = createRoutesStub([
7
- {
8
- path: '/',
9
- Component: App,
10
- },
11
- ]);
12
-
13
- render(<ReactRouterStub />);
14
-
15
- await waitFor(() => screen.findByText('Hello there,'));
16
- });
@@ -1,23 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "include": [
4
- "app/**/*.ts",
5
- "app/**/*.tsx",
6
- "app/**/*.js",
7
- "app/**/*.jsx",
8
- "**/.server/**/*.ts",
9
- "**/.server/**/*.tsx",
10
- "**/.client/**/*.ts",
11
- "**/.client/**/*.tsx"
12
- ],
13
- "exclude": [
14
- "tests/**/*.spec.ts",
15
- "tests/**/*.test.ts",
16
- "tests/**/*.spec.tsx",
17
- "tests/**/*.test.tsx",
18
- "tests/**/*.spec.js",
19
- "tests/**/*.test.js",
20
- "tests/**/*.spec.jsx",
21
- "tests/**/*.test.jsx"
22
- ]
23
- }