@react-router/dev 0.0.0-experimental-7de693505 → 0.0.0-experimental-12b260646
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/dist/cli/commands.d.ts +1 -0
- package/dist/cli/commands.js +12 -1
- package/dist/cli/detectPackageManager.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/run.js +8 -1
- package/dist/cli/useJavascript.js +1 -1
- package/dist/colors.js +1 -1
- package/dist/config/format.js +1 -1
- package/dist/config/routes.js +1 -1
- package/dist/invariant.js +1 -1
- package/dist/routes.js +1 -1
- package/dist/typescript/plugin.js +1 -1
- package/dist/typescript/typegen.d.ts +1 -1
- package/dist/typescript/typegen.js +22 -17
- package/dist/vite/babel.js +1 -1
- package/dist/vite/build.js +1 -1
- package/dist/vite/cloudflare-dev-proxy.js +1 -1
- package/dist/vite/cloudflare.js +1 -1
- package/dist/vite/combine-urls.js +1 -1
- package/dist/vite/config.js +1 -1
- package/dist/vite/dev.js +1 -1
- package/dist/vite/import-vite-esm-sync.js +1 -1
- package/dist/vite/node-adapter.js +1 -1
- package/dist/vite/plugin.js +1 -1
- package/dist/vite/profiler.js +1 -1
- package/dist/vite/remove-exports.js +1 -1
- package/dist/vite/resolve-file-url.js +1 -1
- package/dist/vite/styles.js +1 -1
- package/dist/vite/vite-node.js +1 -1
- package/dist/vite/vmod.js +1 -1
- package/dist/vite/with-props.js +1 -1
- package/dist/vite.js +1 -1
- package/package.json +6 -6
package/dist/cli/commands.d.ts
CHANGED
package/dist/cli/commands.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @react-router/dev v0.0.0-experimental-
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-12b260646
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -21,6 +21,7 @@ var format = require('../config/format.js');
|
|
|
21
21
|
var plugin = require('../vite/plugin.js');
|
|
22
22
|
var useJavascript = require('./useJavascript.js');
|
|
23
23
|
var profiler = require('../vite/profiler.js');
|
|
24
|
+
var typegen$1 = require('../typescript/typegen.js');
|
|
24
25
|
|
|
25
26
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
26
27
|
|
|
@@ -160,8 +161,18 @@ async function createClientEntry(rootDirectory, appDirectory, inputFile) {
|
|
|
160
161
|
let contents = await fse__default["default"].readFile(inputFile, "utf-8");
|
|
161
162
|
return contents;
|
|
162
163
|
}
|
|
164
|
+
async function typegen(root) {
|
|
165
|
+
let ctx = await plugin.loadPluginContext({
|
|
166
|
+
root
|
|
167
|
+
});
|
|
168
|
+
await typegen$1.writeAll({
|
|
169
|
+
rootDirectory: ctx.rootDirectory,
|
|
170
|
+
appDirectory: ctx.reactRouterConfig.appDirectory
|
|
171
|
+
}, ctx.reactRouterConfig.routes);
|
|
172
|
+
}
|
|
163
173
|
|
|
164
174
|
exports.build = build;
|
|
165
175
|
exports.dev = dev;
|
|
166
176
|
exports.generateEntry = generateEntry;
|
|
167
177
|
exports.routes = routes;
|
|
178
|
+
exports.typegen = typegen;
|
package/dist/cli/index.js
CHANGED
package/dist/cli/run.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @react-router/dev v0.0.0-experimental-
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-12b260646
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -86,6 +86,10 @@ ${colors.logoBlue("react-router")}
|
|
|
86
86
|
$ react-router reveal entry.client --no-typescript
|
|
87
87
|
$ react-router reveal entry.server --no-typescript
|
|
88
88
|
$ react-router reveal entry.server --config vite.react-router.config.ts
|
|
89
|
+
|
|
90
|
+
${colors.heading("Generate types for route modules")}:
|
|
91
|
+
|
|
92
|
+
$ react-router typegen
|
|
89
93
|
`;
|
|
90
94
|
/**
|
|
91
95
|
* Programmatic interface for running the react-router CLI with the given command line
|
|
@@ -171,6 +175,9 @@ async function run(argv = process.argv.slice(2)) {
|
|
|
171
175
|
case "dev":
|
|
172
176
|
await commands.dev(input[1], flags);
|
|
173
177
|
break;
|
|
178
|
+
case "typegen":
|
|
179
|
+
await commands.typegen(input[1]);
|
|
180
|
+
break;
|
|
174
181
|
default:
|
|
175
182
|
// `react-router ./my-project` is shorthand for `react-router dev ./my-project`
|
|
176
183
|
await commands.dev(input[0], flags);
|
package/dist/colors.js
CHANGED
package/dist/config/format.js
CHANGED
package/dist/config/routes.js
CHANGED
package/dist/invariant.js
CHANGED
package/dist/routes.js
CHANGED
|
@@ -5,5 +5,5 @@ type Context = {
|
|
|
5
5
|
};
|
|
6
6
|
export declare function getPath(ctx: Context, route: RouteManifestEntry): string;
|
|
7
7
|
export declare function watch(ctx: Context): Promise<void>;
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function writeAll(ctx: Context, routes: RouteManifest): Promise<void>;
|
|
9
9
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @react-router/dev v0.0.0-experimental-
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-12b260646
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -55,7 +55,9 @@ function getPath(ctx, route) {
|
|
|
55
55
|
async function watch(ctx) {
|
|
56
56
|
const appDirectory = Path__namespace.normalize(ctx.appDirectory);
|
|
57
57
|
const routesTsPath = Path__namespace.join(appDirectory, "routes.ts");
|
|
58
|
-
const routesViteNodeContext = await viteNode.createContext(
|
|
58
|
+
const routesViteNodeContext = await viteNode.createContext({
|
|
59
|
+
root: ctx.rootDirectory
|
|
60
|
+
});
|
|
59
61
|
async function getRoutes() {
|
|
60
62
|
routesViteNodeContext.devServer.moduleGraph.invalidateAll();
|
|
61
63
|
routesViteNodeContext.runner.moduleCache.clear();
|
|
@@ -63,7 +65,7 @@ async function watch(ctx) {
|
|
|
63
65
|
return routes.configRoutesToRouteManifest(result.routes);
|
|
64
66
|
}
|
|
65
67
|
const initialRoutes = await getRoutes();
|
|
66
|
-
await
|
|
68
|
+
await writeAll(ctx, initialRoutes);
|
|
67
69
|
const watcher = Chokidar__default["default"].watch(appDirectory, {
|
|
68
70
|
ignoreInitial: true
|
|
69
71
|
});
|
|
@@ -72,22 +74,23 @@ async function watch(ctx) {
|
|
|
72
74
|
const routes = await getRoutes();
|
|
73
75
|
const routeConfigChanged = Boolean(routesViteNodeContext.devServer.moduleGraph.getModuleById(path));
|
|
74
76
|
if (routeConfigChanged) {
|
|
75
|
-
await
|
|
77
|
+
await writeAll(ctx, routes);
|
|
76
78
|
return;
|
|
77
79
|
}
|
|
78
80
|
const isRoute = Object.values(routes).find(route => path === Path__namespace.join(ctx.appDirectory, route.file));
|
|
79
81
|
if (isRoute && (event === "add" || event === "unlink")) {
|
|
80
|
-
await
|
|
82
|
+
await writeAll(ctx, routes);
|
|
81
83
|
return;
|
|
82
84
|
}
|
|
83
85
|
});
|
|
84
86
|
}
|
|
85
|
-
async function
|
|
87
|
+
async function writeAll(ctx, routes) {
|
|
86
88
|
fs__default["default"].rmSync(getDirectory(ctx), {
|
|
87
89
|
recursive: true,
|
|
88
90
|
force: true
|
|
89
91
|
});
|
|
90
92
|
Object.values(routes).forEach(route => {
|
|
93
|
+
if (!fs__default["default"].existsSync(Path__namespace.join(ctx.appDirectory, route.file))) return;
|
|
91
94
|
const typesPath = getPath(ctx, route);
|
|
92
95
|
const content = getModule(routes, route);
|
|
93
96
|
fs__default["default"].mkdirSync(Path__namespace.dirname(typesPath), {
|
|
@@ -98,24 +101,26 @@ async function typegenAll(ctx, routes) {
|
|
|
98
101
|
}
|
|
99
102
|
function getModule(routes, route) {
|
|
100
103
|
return dedent__default["default"]`
|
|
101
|
-
//
|
|
104
|
+
// React Router generated types for route:
|
|
105
|
+
// ${route.file}
|
|
106
|
+
|
|
102
107
|
import * as T from "react-router/types"
|
|
103
108
|
|
|
104
109
|
export type Params = {${formattedParamsProperties(routes, route)}}
|
|
105
110
|
|
|
106
111
|
type Route = typeof import("./${Pathe__namespace.filename(route.file)}")
|
|
107
112
|
|
|
108
|
-
export type LoaderData = T.
|
|
109
|
-
export type ActionData = T.
|
|
113
|
+
export type LoaderData = T.CreateLoaderData<Route>
|
|
114
|
+
export type ActionData = T.CreateActionData<Route>
|
|
110
115
|
|
|
111
|
-
export type LoaderArgs = T.
|
|
112
|
-
export type ClientLoaderArgs = T.
|
|
113
|
-
export type ActionArgs = T.
|
|
114
|
-
export type ClientActionArgs = T.
|
|
116
|
+
export type LoaderArgs = T.CreateServerLoaderArgs<Params>
|
|
117
|
+
export type ClientLoaderArgs = T.CreateClientLoaderArgs<Params, Route>
|
|
118
|
+
export type ActionArgs = T.CreateServerActionArgs<Params>
|
|
119
|
+
export type ClientActionArgs = T.CreateClientActionArgs<Params, Route>
|
|
115
120
|
|
|
116
|
-
export type HydrateFallbackProps = T.
|
|
117
|
-
export type DefaultProps = T.
|
|
118
|
-
export type ErrorBoundaryProps = T.
|
|
121
|
+
export type HydrateFallbackProps = T.CreateHydrateFallbackProps<Params>
|
|
122
|
+
export type DefaultProps = T.CreateDefaultProps<Params, LoaderData, ActionData>
|
|
123
|
+
export type ErrorBoundaryProps = T.CreateErrorBoundaryProps<Params, LoaderData, ActionData>
|
|
119
124
|
`;
|
|
120
125
|
}
|
|
121
126
|
function formattedParamsProperties(routes, route) {
|
|
@@ -161,5 +166,5 @@ function parseParams(urlpath) {
|
|
|
161
166
|
}
|
|
162
167
|
|
|
163
168
|
exports.getPath = getPath;
|
|
164
|
-
exports.typegenAll = typegenAll;
|
|
165
169
|
exports.watch = watch;
|
|
170
|
+
exports.writeAll = writeAll;
|
package/dist/vite/babel.js
CHANGED
package/dist/vite/build.js
CHANGED
package/dist/vite/cloudflare.js
CHANGED
package/dist/vite/config.js
CHANGED
package/dist/vite/dev.js
CHANGED
package/dist/vite/plugin.js
CHANGED
package/dist/vite/profiler.js
CHANGED
package/dist/vite/styles.js
CHANGED
package/dist/vite/vite-node.js
CHANGED
package/dist/vite/vmod.js
CHANGED
package/dist/vite/with-props.js
CHANGED
package/dist/vite.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-router/dev",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-12b260646",
|
|
4
4
|
"description": "Dev tools and CLI for React Router",
|
|
5
5
|
"homepage": "https://reactrouter.com",
|
|
6
6
|
"bugs": {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"set-cookie-parser": "^2.6.0",
|
|
62
62
|
"valibot": "^0.41.0",
|
|
63
63
|
"vite-node": "^1.6.0",
|
|
64
|
-
"@react-router/node": "0.0.0-experimental-
|
|
64
|
+
"@react-router/node": "0.0.0-experimental-12b260646"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@types/babel__core": "^7.20.5",
|
|
@@ -87,15 +87,15 @@
|
|
|
87
87
|
"tiny-invariant": "^1.2.0",
|
|
88
88
|
"vite": "^5.1.0",
|
|
89
89
|
"wrangler": "^3.28.2",
|
|
90
|
-
"
|
|
91
|
-
"react-router": "
|
|
90
|
+
"react-router": "^0.0.0-experimental-12b260646",
|
|
91
|
+
"@react-router/serve": "0.0.0-experimental-12b260646"
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|
|
94
94
|
"typescript": "^5.1.0",
|
|
95
95
|
"vite": "^5.1.0",
|
|
96
96
|
"wrangler": "^3.28.2",
|
|
97
|
-
"@react-router/serve": "^0.0.0-experimental-
|
|
98
|
-
"react-router": "^0.0.0-experimental-
|
|
97
|
+
"@react-router/serve": "^0.0.0-experimental-12b260646",
|
|
98
|
+
"react-router": "^0.0.0-experimental-12b260646"
|
|
99
99
|
},
|
|
100
100
|
"peerDependenciesMeta": {
|
|
101
101
|
"@react-router/serve": {
|