@nx/react 0.0.0-pr-29993-0fbf3d3 → 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.
- package/package.json +6 -6
- package/src/generators/application/application.js +9 -48
- package/src/generators/application/lib/add-e2e.js +24 -29
- package/src/generators/application/lib/add-linting.d.ts +0 -1
- package/src/generators/application/lib/add-linting.js +0 -38
- package/src/generators/application/lib/add-project.js +15 -31
- package/src/generators/application/lib/add-routing.js +1 -1
- package/src/generators/application/lib/bundlers/add-vite.js +6 -15
- package/src/generators/application/lib/create-application-files.js +4 -41
- package/src/generators/application/lib/install-common-dependencies.js +2 -13
- package/src/generators/application/lib/normalize-options.d.ts +2 -0
- package/src/generators/application/lib/normalize-options.js +20 -11
- package/src/generators/application/schema.d.ts +1 -5
- package/src/generators/application/schema.json +1 -10
- package/src/generators/host/host.js +3 -6
- package/src/generators/init/init.js +0 -23
- package/src/generators/init/schema.d.ts +0 -2
- package/src/generators/library/lib/add-rollup-build-target.d.ts +1 -3
- package/src/generators/library/lib/add-rollup-build-target.js +7 -6
- package/src/generators/library/lib/create-files.js +1 -2
- package/src/generators/library/lib/normalize-options.js +5 -8
- package/src/generators/library/library.js +15 -21
- package/src/generators/library/schema.d.ts +0 -2
- package/src/generators/library/schema.json +0 -4
- package/src/generators/remote/remote.js +9 -12
- package/src/utils/ast-utils.d.ts +1 -1
- package/src/utils/ast-utils.js +2 -2
- package/src/utils/versions.d.ts +1 -3
- package/src/utils/versions.js +3 -6
- package/router-plugin.d.ts +0 -1
- package/router-plugin.js +0 -5
- package/src/generators/application/files/react-router-ssr/common/app/app-nav.tsx__tmpl__ +0 -15
- package/src/generators/application/files/react-router-ssr/common/app/entry.client.tsx__tmpl__ +0 -18
- package/src/generators/application/files/react-router-ssr/common/app/entry.server.tsx__tmpl__ +0 -74
- package/src/generators/application/files/react-router-ssr/common/app/root.tsx__tmpl__ +0 -51
- package/src/generators/application/files/react-router-ssr/common/app/routes/about.tsx__tmpl__ +0 -7
- package/src/generators/application/files/react-router-ssr/common/app/routes.tsx__tmpl__ +0 -6
- package/src/generators/application/files/react-router-ssr/common/public/favicon.ico +0 -0
- package/src/generators/application/files/react-router-ssr/common/react-router.config.ts__tmpl__ +0 -5
- package/src/generators/application/files/react-router-ssr/common/tests/routes/_index.spec.tsx__tmpl__ +0 -16
- package/src/generators/application/files/react-router-ssr/common/tsconfig.app.json__tmpl__ +0 -23
- package/src/generators/application/files/react-router-ssr/common/tsconfig.json__tmpl__ +0 -27
- package/src/generators/application/files/react-router-ssr/non-root/.gitignore__tmpl__ +0 -5
- package/src/generators/application/files/react-router-ssr/non-root/package.json__tmpl__ +0 -24
- package/src/generators/application/files/react-router-ssr/nx-welcome/claimed/app/nx-welcome.tsx__tmpl__ +0 -866
- package/src/generators/application/files/react-router-ssr/nx-welcome/not-configured/app/nx-welcome.tsx__tmpl__ +0 -866
- package/src/generators/application/files/react-router-ssr/nx-welcome/unclaimed/app/nx-welcome.tsx__tmpl__ +0 -864
- package/src/generators/application/files/react-router-ssr/ts-solution/package.json__tmpl__ +0 -24
- package/src/generators/application/files/react-router-ssr/ts-solution/tsconfig.app.json__tmpl__ +0 -39
- package/src/plugins/router-plugin.d.ts +0 -10
- package/src/plugins/router-plugin.js +0 -219
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "<%= projectName %>",
|
|
3
|
-
"private": true,
|
|
4
|
-
"type": "module",
|
|
5
|
-
"scripts": {},
|
|
6
|
-
"dependencies": {
|
|
7
|
-
"@react-router/node": "<%= reactRouterVersion %>",
|
|
8
|
-
"@react-router/serve": "<%= reactRouterVersion %>",
|
|
9
|
-
"isbot": "<%= reactRouterIsBotVersion %>",
|
|
10
|
-
"react": "<%= reactVersion %>",
|
|
11
|
-
"react-dom": "<%= reactVersion %>",
|
|
12
|
-
"react-router": "<%= reactRouterVersion %>"
|
|
13
|
-
},
|
|
14
|
-
"devDependencies": {
|
|
15
|
-
"@react-router/dev": "<%= reactRouterVersion %>",
|
|
16
|
-
"@types/node": "<%= typesNodeVersion %>",
|
|
17
|
-
"@types/react": "<%= reactVersion %>",
|
|
18
|
-
"@types/react-dom": "<%= reactVersion %>"
|
|
19
|
-
},
|
|
20
|
-
"engines": {
|
|
21
|
-
"node": ">=20"
|
|
22
|
-
},
|
|
23
|
-
"sideEffects": false,
|
|
24
|
-
}
|
package/src/generators/application/files/react-router-ssr/ts-solution/tsconfig.app.json__tmpl__
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "<%= offsetFromRoot %>tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "dist",
|
|
5
|
-
"lib": ["DOM", "DOM.Iterable", "ES2019"],
|
|
6
|
-
"types": ["@react-router/node", "vite/client"],
|
|
7
|
-
"isolatedModules": true,
|
|
8
|
-
"esModuleInterop": true,
|
|
9
|
-
"jsx": "react-jsx",
|
|
10
|
-
"module": "ESNext",
|
|
11
|
-
"moduleResolution": "Bundler",
|
|
12
|
-
"resolveJsonModule": true,
|
|
13
|
-
"target": "ES2022",
|
|
14
|
-
"strict": true,
|
|
15
|
-
"allowJs": true,
|
|
16
|
-
"skipLibCheck": true,
|
|
17
|
-
"forceConsistentCasingInFileNames": true
|
|
18
|
-
},
|
|
19
|
-
"include": [
|
|
20
|
-
"app/**/*.ts",
|
|
21
|
-
"app/**/*.tsx",
|
|
22
|
-
"app/**/*.js",
|
|
23
|
-
"app/**/*.jsx",
|
|
24
|
-
"**/.server/**/*.ts",
|
|
25
|
-
"**/.server/**/*.tsx",
|
|
26
|
-
"**/.client/**/*.ts",
|
|
27
|
-
"**/.client/**/*.tsx"
|
|
28
|
-
],
|
|
29
|
-
"exclude": [
|
|
30
|
-
"tests/**/*.spec.ts",
|
|
31
|
-
"tests/**/*.test.ts",
|
|
32
|
-
"tests/**/*.spec.tsx",
|
|
33
|
-
"tests/**/*.test.tsx",
|
|
34
|
-
"tests/**/*.spec.js",
|
|
35
|
-
"tests/**/*.test.js",
|
|
36
|
-
"tests/**/*.spec.jsx",
|
|
37
|
-
"tests/**/*.test.jsx"
|
|
38
|
-
]
|
|
39
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type CreateNodesV2 } from '@nx/devkit';
|
|
2
|
-
export interface ReactRouterPluginOptions {
|
|
3
|
-
buildTargetName?: string;
|
|
4
|
-
devTargetName?: string;
|
|
5
|
-
startTargetName?: string;
|
|
6
|
-
typecheckTargetName?: string;
|
|
7
|
-
buildDepsTargetName?: string;
|
|
8
|
-
watchDepsTargetName?: string;
|
|
9
|
-
}
|
|
10
|
-
export declare const createNodesV2: CreateNodesV2<ReactRouterPluginOptions>;
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createNodesV2 = void 0;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const path_1 = require("path");
|
|
6
|
-
const fs_1 = require("fs");
|
|
7
|
-
const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
|
|
8
|
-
const cache_directory_1 = require("nx/src/utils/cache-directory");
|
|
9
|
-
const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
|
|
10
|
-
const js_1 = require("@nx/js");
|
|
11
|
-
const devkit_internals_1 = require("nx/src/devkit-internals");
|
|
12
|
-
const util_1 = require("@nx/js/src/plugins/typescript/util");
|
|
13
|
-
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
14
|
-
const config_utils_1 = require("@nx/devkit/src/utils/config-utils");
|
|
15
|
-
const pmCommand = (0, devkit_1.getPackageManagerCommand)();
|
|
16
|
-
const reactRouterConfigBlob = '**/react-router.config.{ts,js,cjs,cts,mjs,mts}';
|
|
17
|
-
function readTargetsCache(cachePath) {
|
|
18
|
-
return process.env.NX_CACHE_PROJECT_GRAPH !== 'false' && (0, fs_1.existsSync)(cachePath)
|
|
19
|
-
? (0, devkit_1.readJsonFile)(cachePath)
|
|
20
|
-
: {};
|
|
21
|
-
}
|
|
22
|
-
function writeTargetsToCache(cachePath, results) {
|
|
23
|
-
(0, devkit_1.writeJsonFile)(cachePath, results);
|
|
24
|
-
}
|
|
25
|
-
exports.createNodesV2 = [
|
|
26
|
-
reactRouterConfigBlob,
|
|
27
|
-
async (configFiles, options, context) => {
|
|
28
|
-
const optionsHash = (0, devkit_internals_1.hashObject)(options);
|
|
29
|
-
const normalizedOptions = normalizeOptions(options);
|
|
30
|
-
const cachePath = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, `react-router-${optionsHash}.hash`);
|
|
31
|
-
const targetsCache = readTargetsCache(cachePath);
|
|
32
|
-
const isUsingTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)();
|
|
33
|
-
const { roots: projectRoots, configFiles: validConfigFiles } = configFiles.reduce((acc, configFile) => {
|
|
34
|
-
const potentialRoot = (0, path_1.dirname)(configFile);
|
|
35
|
-
if (checkIfConfigFileShouldBeProject(potentialRoot, context)) {
|
|
36
|
-
acc.roots.push(potentialRoot);
|
|
37
|
-
acc.configFiles.push(configFile);
|
|
38
|
-
}
|
|
39
|
-
return acc;
|
|
40
|
-
}, {
|
|
41
|
-
roots: [],
|
|
42
|
-
configFiles: [],
|
|
43
|
-
});
|
|
44
|
-
const lockfile = (0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot));
|
|
45
|
-
const hashes = await (0, calculate_hash_for_create_nodes_1.calculateHashesForCreateNodes)(projectRoots, { ...normalizedOptions, isUsingTsSolutionSetup }, context, projectRoots.map((_) => [lockfile]));
|
|
46
|
-
try {
|
|
47
|
-
return await (0, devkit_1.createNodesFromFiles)(async (configFile, _, context, idx) => {
|
|
48
|
-
const projectRoot = (0, path_1.dirname)(configFile);
|
|
49
|
-
const siblingFiles = (0, fs_1.readdirSync)((0, devkit_1.joinPathFragments)(context.workspaceRoot, projectRoot));
|
|
50
|
-
const hash = hashes[idx] + configFile;
|
|
51
|
-
const { projectType, metadata, targets } = (targetsCache[hash] ??=
|
|
52
|
-
await buildReactRouterTargets(configFile, projectRoot, normalizedOptions, context, siblingFiles, isUsingTsSolutionSetup));
|
|
53
|
-
const project = {
|
|
54
|
-
root: projectRoot,
|
|
55
|
-
targets,
|
|
56
|
-
metadata,
|
|
57
|
-
};
|
|
58
|
-
if (project.targets[normalizedOptions.buildTargetName]) {
|
|
59
|
-
project.projectType = projectType;
|
|
60
|
-
}
|
|
61
|
-
return {
|
|
62
|
-
projects: {
|
|
63
|
-
[projectRoot]: project,
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
}, validConfigFiles, options, context);
|
|
67
|
-
}
|
|
68
|
-
finally {
|
|
69
|
-
writeTargetsToCache(cachePath, targetsCache);
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
];
|
|
73
|
-
async function buildReactRouterTargets(configFilePath, projectRoot, options, context, siblingFiles, isUsingTsSolutionSetup) {
|
|
74
|
-
const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
|
|
75
|
-
const configPath = (0, path_1.join)(context.workspaceRoot, configFilePath);
|
|
76
|
-
if (require.cache[configPath])
|
|
77
|
-
(0, config_utils_1.clearRequireCache)();
|
|
78
|
-
const reactRouterConfig = await (0, config_utils_1.loadConfigFile)(configPath);
|
|
79
|
-
const isLibMode = reactRouterConfig?.ssr !== undefined && reactRouterConfig.ssr === false;
|
|
80
|
-
const { buildDirectory, serverBuildPath } = await getBuildPaths(reactRouterConfig, isLibMode);
|
|
81
|
-
const targets = {};
|
|
82
|
-
targets[options.buildTargetName] = await getBuildTargetConfig(options.buildTargetName, projectRoot, buildDirectory, serverBuildPath, namedInputs, isUsingTsSolutionSetup);
|
|
83
|
-
targets[options.devTargetName] = await devTarget(projectRoot, isUsingTsSolutionSetup);
|
|
84
|
-
if (serverBuildPath) {
|
|
85
|
-
targets[options.startTargetName] = await startTarget(projectRoot, serverBuildPath, options.buildTargetName, isUsingTsSolutionSetup);
|
|
86
|
-
}
|
|
87
|
-
targets[options.typecheckTargetName] = await typecheckTarget(projectRoot, options.typecheckTargetName, namedInputs, siblingFiles, isUsingTsSolutionSetup);
|
|
88
|
-
(0, util_1.addBuildAndWatchDepsTargets)(context.workspaceRoot, projectRoot, targets, options, pmCommand);
|
|
89
|
-
const metadata = {};
|
|
90
|
-
return {
|
|
91
|
-
targets,
|
|
92
|
-
metadata,
|
|
93
|
-
projectType: isLibMode ? 'library' : 'application',
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
async function getBuildTargetConfig(buildTargetName, projectRoot, buildDirectory, serverBuildDirectory, namedInputs, isUsingTsSolutionSetup) {
|
|
97
|
-
const basePath = projectRoot === '.'
|
|
98
|
-
? `{workspaceRoot}`
|
|
99
|
-
: (0, devkit_1.joinPathFragments)(`{workspaceRoot}`, projectRoot);
|
|
100
|
-
const outputs = [
|
|
101
|
-
(0, devkit_1.joinPathFragments)(basePath, buildDirectory),
|
|
102
|
-
...(serverBuildDirectory
|
|
103
|
-
? [(0, devkit_1.joinPathFragments)(basePath, serverBuildDirectory)]
|
|
104
|
-
: []),
|
|
105
|
-
];
|
|
106
|
-
const buildTarget = {
|
|
107
|
-
cache: true,
|
|
108
|
-
dependsOn: [`^${buildTargetName}`],
|
|
109
|
-
inputs: [
|
|
110
|
-
...('production' in namedInputs
|
|
111
|
-
? ['production', '^production']
|
|
112
|
-
: ['default', '^default']),
|
|
113
|
-
{ externalDependencies: ['@react-router/dev'] },
|
|
114
|
-
],
|
|
115
|
-
outputs,
|
|
116
|
-
command: 'react-router build',
|
|
117
|
-
options: { cwd: projectRoot },
|
|
118
|
-
};
|
|
119
|
-
if (isUsingTsSolutionSetup) {
|
|
120
|
-
buildTarget.syncGenerators = ['@nx/js:typescript-sync'];
|
|
121
|
-
}
|
|
122
|
-
return buildTarget;
|
|
123
|
-
}
|
|
124
|
-
async function getBuildPaths(reactRouterConfig, isLibMode) {
|
|
125
|
-
return {
|
|
126
|
-
buildDirectory: reactRouterConfig?.buildDirectory ?? 'build/client',
|
|
127
|
-
...(isLibMode
|
|
128
|
-
? undefined
|
|
129
|
-
: {
|
|
130
|
-
serverBuildPath: reactRouterConfig?.buildDirectory
|
|
131
|
-
? (0, path_1.join)((0, path_1.dirname)(reactRouterConfig.buildDirectory), `server`)
|
|
132
|
-
: 'build/server',
|
|
133
|
-
}),
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
async function devTarget(projectRoot, isUsingTsSolutionSetup) {
|
|
137
|
-
const devTarget = {
|
|
138
|
-
command: 'react-router dev',
|
|
139
|
-
options: { cwd: projectRoot },
|
|
140
|
-
};
|
|
141
|
-
if (isUsingTsSolutionSetup) {
|
|
142
|
-
devTarget.syncGenerators = ['@nx/js:typescript-sync'];
|
|
143
|
-
}
|
|
144
|
-
return devTarget;
|
|
145
|
-
}
|
|
146
|
-
async function startTarget(projectRoot, serverBuildPath, buildTargetName, isUsingTsSolutionSetup) {
|
|
147
|
-
const serverPath = serverBuildPath === 'build/server'
|
|
148
|
-
? `${serverBuildPath}/index.js`
|
|
149
|
-
: serverBuildPath;
|
|
150
|
-
const startTarget = {
|
|
151
|
-
dependsOn: [buildTargetName],
|
|
152
|
-
command: `react-router-serve ${serverPath}`,
|
|
153
|
-
options: { cwd: projectRoot },
|
|
154
|
-
};
|
|
155
|
-
if (isUsingTsSolutionSetup) {
|
|
156
|
-
startTarget.syncGenerators = ['@nx/js:typescript-sync'];
|
|
157
|
-
}
|
|
158
|
-
return startTarget;
|
|
159
|
-
}
|
|
160
|
-
async function typecheckTarget(projectRoot, typecheckTargetName, namedInputs, siblingFiles, isUsingTsSolutionSetup) {
|
|
161
|
-
const hasTsConfigAppJson = siblingFiles.includes('tsconfig.app.json');
|
|
162
|
-
const typecheckTarget = {
|
|
163
|
-
cache: true,
|
|
164
|
-
inputs: [
|
|
165
|
-
...('production' in namedInputs
|
|
166
|
-
? ['production', '^production']
|
|
167
|
-
: ['default', '^default']),
|
|
168
|
-
{ externalDependencies: ['typescript'] },
|
|
169
|
-
],
|
|
170
|
-
command: isUsingTsSolutionSetup
|
|
171
|
-
? `tsc --build --emitDeclarationOnly`
|
|
172
|
-
: `tsc${hasTsConfigAppJson ? ` -p tsconfig.app.json` : ``} --noEmit`,
|
|
173
|
-
options: {
|
|
174
|
-
cwd: projectRoot,
|
|
175
|
-
},
|
|
176
|
-
metadata: {
|
|
177
|
-
description: `Runs type-checking for the project.`,
|
|
178
|
-
technologies: ['typescript'],
|
|
179
|
-
help: {
|
|
180
|
-
command: isUsingTsSolutionSetup
|
|
181
|
-
? `${pmCommand.exec} tsc --build --help`
|
|
182
|
-
: `${pmCommand.exec} tsc${hasTsConfigAppJson ? ` -p tsconfig.app.json` : ``} --help`,
|
|
183
|
-
example: isUsingTsSolutionSetup
|
|
184
|
-
? { args: ['--force'] }
|
|
185
|
-
: { options: { noEmit: true } },
|
|
186
|
-
},
|
|
187
|
-
},
|
|
188
|
-
};
|
|
189
|
-
if (isUsingTsSolutionSetup) {
|
|
190
|
-
typecheckTarget.dependsOn = [`^${typecheckTargetName}`];
|
|
191
|
-
typecheckTarget.syncGenerators = ['@nx/js:typescript-sync'];
|
|
192
|
-
}
|
|
193
|
-
return typecheckTarget;
|
|
194
|
-
}
|
|
195
|
-
function normalizeOptions(options) {
|
|
196
|
-
options ??= {};
|
|
197
|
-
options.buildTargetName ??= 'build';
|
|
198
|
-
options.devTargetName ??= 'dev';
|
|
199
|
-
options.startTargetName ??= 'start';
|
|
200
|
-
options.typecheckTargetName ??= 'typecheck';
|
|
201
|
-
return options;
|
|
202
|
-
}
|
|
203
|
-
function checkIfConfigFileShouldBeProject(projectRoot, context) {
|
|
204
|
-
// Do not create a project if package.json and project.json isn't there.
|
|
205
|
-
const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
|
|
206
|
-
return hasRequiredConfigs(siblingFiles);
|
|
207
|
-
}
|
|
208
|
-
function hasRequiredConfigs(files) {
|
|
209
|
-
const lowerFiles = files.map((file) => file.toLowerCase());
|
|
210
|
-
// Check if vite.config.{ext} is present
|
|
211
|
-
const hasViteConfig = lowerFiles.some((file) => {
|
|
212
|
-
const parts = file.split('.');
|
|
213
|
-
return parts[0] === 'vite' && parts[1] === 'config' && parts.length > 2;
|
|
214
|
-
});
|
|
215
|
-
if (!hasViteConfig)
|
|
216
|
-
return false;
|
|
217
|
-
const hasProjectOrPackageJson = lowerFiles.includes('project.json') || lowerFiles.includes('package.json');
|
|
218
|
-
return hasProjectOrPackageJson;
|
|
219
|
-
}
|