@react-router/dev 0.0.0-experimental-3f102fccb → 0.0.0-experimental-89dc2043e
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/CHANGELOG.md +149 -1
- package/dist/cli/dev.d.ts +22 -0
- package/dist/cli/dev.js +155 -0
- package/dist/cli/index.js +73 -132
- package/dist/config.d.ts +3 -0
- package/dist/config.js +1 -1
- package/dist/routes.js +1 -1
- package/dist/vite/cloudflare.js +1 -1
- package/dist/vite.js +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,152 @@
|
|
|
1
|
-
# `@
|
|
1
|
+
# `@react-router/dev`
|
|
2
|
+
|
|
3
|
+
## 7.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Ensure typegen file watcher is cleaned up when Vite dev server restarts ([#12331](https://github.com/remix-run/react-router/pull/12331))
|
|
8
|
+
- Updated dependencies:
|
|
9
|
+
- `react-router@7.0.1`
|
|
10
|
+
- `@react-router/node@7.0.1`
|
|
11
|
+
- `@react-router/serve@7.0.1`
|
|
12
|
+
|
|
13
|
+
## 7.0.0
|
|
14
|
+
|
|
15
|
+
### Major Changes
|
|
16
|
+
|
|
17
|
+
- For Remix consumers migrating to React Router, the `vitePlugin` and `cloudflareDevProxyVitePlugin` exports have been renamed and moved. ([#11904](https://github.com/remix-run/react-router/pull/11904))
|
|
18
|
+
|
|
19
|
+
```diff
|
|
20
|
+
-import {
|
|
21
|
+
- vitePlugin as remix,
|
|
22
|
+
- cloudflareDevProxyVitePlugin,
|
|
23
|
+
-} from "@remix/dev";
|
|
24
|
+
|
|
25
|
+
+import { reactRouter } from "@react-router/dev/vite";
|
|
26
|
+
+import { cloudflareDevProxy } from "@react-router/dev/vite/cloudflare";
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
- Remove single_fetch future flag. ([#11522](https://github.com/remix-run/react-router/pull/11522))
|
|
30
|
+
|
|
31
|
+
- update minimum node version to 18 ([#11690](https://github.com/remix-run/react-router/pull/11690))
|
|
32
|
+
|
|
33
|
+
- Add `exports` field to all packages ([#11675](https://github.com/remix-run/react-router/pull/11675))
|
|
34
|
+
|
|
35
|
+
- node package no longer re-exports from react-router ([#11702](https://github.com/remix-run/react-router/pull/11702))
|
|
36
|
+
|
|
37
|
+
- For Remix consumers migrating to React Router who used the Vite plugin's `buildEnd` hook, the resolved `reactRouterConfig` object no longer contains a `publicPath` property since this belongs to Vite, not React Router. ([#11575](https://github.com/remix-run/react-router/pull/11575))
|
|
38
|
+
|
|
39
|
+
- For Remix consumers migrating to React Router, the Vite plugin's `manifest` option has been removed. ([#11573](https://github.com/remix-run/react-router/pull/11573))
|
|
40
|
+
|
|
41
|
+
The `manifest` option been superseded by the more powerful `buildEnd` hook since it's passed the `buildManifest` argument. You can still write the build manifest to disk if needed, but you'll most likely find it more convenient to write any logic depending on the build manifest within the `buildEnd` hook itself.
|
|
42
|
+
|
|
43
|
+
If you were using the `manifest` option, you can replace it with a `buildEnd` hook that writes the manifest to disk like this:
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
// react-router.config.ts
|
|
47
|
+
import type { Config } from "@react-router/dev/config";
|
|
48
|
+
import { writeFile } from "node:fs/promises";
|
|
49
|
+
|
|
50
|
+
export default {
|
|
51
|
+
async buildEnd({ buildManifest }) {
|
|
52
|
+
await writeFile(
|
|
53
|
+
"build/manifest.json",
|
|
54
|
+
JSON.stringify(buildManifest, null, 2),
|
|
55
|
+
"utf-8"
|
|
56
|
+
);
|
|
57
|
+
},
|
|
58
|
+
} satisfies Config;
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
- Consolidate types previously duplicated across `@remix-run/router`, `@remix-run/server-runtime`, and `@remix-run/react` now that they all live in `react-router` ([#12177](https://github.com/remix-run/react-router/pull/12177))
|
|
62
|
+
|
|
63
|
+
- Examples: `LoaderFunction`, `LoaderFunctionArgs`, `ActionFunction`, `ActionFunctionArgs`, `DataFunctionArgs`, `RouteManifest`, `LinksFunction`, `Route`, `EntryRoute`
|
|
64
|
+
- The `RouteManifest` type used by the "remix" code is now slightly stricter because it is using the former `@remix-run/router` `RouteManifest`
|
|
65
|
+
- `Record<string, Route> -> Record<string, Route | undefined>`
|
|
66
|
+
- Removed `AppData` type in favor of inlining `unknown` in the few locations it was used
|
|
67
|
+
- Removed `ServerRuntimeMeta*` types in favor of the `Meta*` types they were duplicated from
|
|
68
|
+
|
|
69
|
+
- Update default `isbot` version to v5 and drop support for `isbot@3` ([#11770](https://github.com/remix-run/react-router/pull/11770))
|
|
70
|
+
|
|
71
|
+
- If you have `isbot@4` or `isbot@5` in your `package.json`:
|
|
72
|
+
- You do not need to make any changes
|
|
73
|
+
- If you have `isbot@3` in your `package.json` and you have your own `entry.server.tsx` file in your repo
|
|
74
|
+
- You do not need to make any changes
|
|
75
|
+
- You can upgrade to `isbot@5` independent of the React Router v7 upgrade
|
|
76
|
+
- If you have `isbot@3` in your `package.json` and you do not have your own `entry.server.tsx` file in your repo
|
|
77
|
+
- You are using the internal default entry provided by React Router v7 and you will need to upgrade to `isbot@5` in your `package.json`
|
|
78
|
+
|
|
79
|
+
- Drop support for Node 18, update minimum Node vestion to 20 ([#12171](https://github.com/remix-run/react-router/pull/12171))
|
|
80
|
+
|
|
81
|
+
- Remove `installGlobals()` as this should no longer be necessary
|
|
82
|
+
|
|
83
|
+
- For Remix consumers migrating to React Router, Vite manifests (i.e. `.vite/manifest.json`) are now written within each build subdirectory, e.g. `build/client/.vite/manifest.json` and `build/server/.vite/manifest.json` instead of `build/.vite/client-manifest.json` and `build/.vite/server-manifest.json`. This means that the build output is now much closer to what you'd expect from a typical Vite project. ([#11573](https://github.com/remix-run/react-router/pull/11573))
|
|
84
|
+
|
|
85
|
+
Originally the Remix Vite plugin moved all Vite manifests to a root-level `build/.vite` directory to avoid accidentally serving them in production, particularly from the client build. This was later improved with additional logic that deleted these Vite manifest files at the end of the build process unless Vite's `build.manifest` had been enabled within the app's Vite config. This greatly reduced the risk of accidentally serving the Vite manifests in production since they're only present when explicitly asked for. As a result, we can now assume that consumers will know that they need to manage these additional files themselves, and React Router can safely generate a more standard Vite build output.
|
|
86
|
+
|
|
87
|
+
### Minor Changes
|
|
88
|
+
|
|
89
|
+
- Params, loader data, and action data as props for route component exports ([#11961](https://github.com/remix-run/react-router/pull/11961))
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
export default function Component({ params, loaderData, actionData }) {}
|
|
93
|
+
|
|
94
|
+
export function HydrateFallback({ params }) {}
|
|
95
|
+
export function ErrorBoundary({ params, loaderData, actionData }) {}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
- Remove internal entry.server.spa.tsx implementation ([#11681](https://github.com/remix-run/react-router/pull/11681))
|
|
99
|
+
|
|
100
|
+
- Add `prefix` route config helper to `@react-router/dev/routes` ([#12094](https://github.com/remix-run/react-router/pull/12094))
|
|
101
|
+
|
|
102
|
+
- ### Typesafety improvements ([#12019](https://github.com/remix-run/react-router/pull/12019))
|
|
103
|
+
|
|
104
|
+
React Router now generates types for each of your route modules.
|
|
105
|
+
You can access those types by importing them from `./+types.<route filename without extension>`.
|
|
106
|
+
For example:
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
// app/routes/product.tsx
|
|
110
|
+
import type * as Route from "./+types.product";
|
|
111
|
+
|
|
112
|
+
export function loader({ params }: Route.LoaderArgs) {}
|
|
113
|
+
|
|
114
|
+
export default function Component({ loaderData }: Route.ComponentProps) {}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
This initial implementation targets type inference for:
|
|
118
|
+
|
|
119
|
+
- `Params` : Path parameters from your routing config in `routes.ts` including file-based routing
|
|
120
|
+
- `LoaderData` : Loader data from `loader` and/or `clientLoader` within your route module
|
|
121
|
+
- `ActionData` : Action data from `action` and/or `clientAction` within your route module
|
|
122
|
+
|
|
123
|
+
In the future, we plan to add types for the rest of the route module exports: `meta`, `links`, `headers`, `shouldRevalidate`, etc.
|
|
124
|
+
We also plan to generate types for typesafe `Link`s:
|
|
125
|
+
|
|
126
|
+
```tsx
|
|
127
|
+
<Link to="/products/:id" params={{ id: 1 }} />
|
|
128
|
+
// ^^^^^^^^^^^^^ ^^^^^^^^^
|
|
129
|
+
// typesafe `to` and `params` based on the available routes in your app
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Check out our docs for more:
|
|
133
|
+
|
|
134
|
+
- [_Explanations > Type Safety_](https://reactrouter.com/dev/guides/explanation/type-safety)
|
|
135
|
+
- [_How-To > Setting up type safety_](https://reactrouter.com/dev/guides/how-to/setting-up-type-safety)
|
|
136
|
+
|
|
137
|
+
### Patch Changes
|
|
138
|
+
|
|
139
|
+
- Enable prerendering for resource routes ([#12200](https://github.com/remix-run/react-router/pull/12200))
|
|
140
|
+
- chore: warn instead of error for min node version in CLI ([#12270](https://github.com/remix-run/react-router/pull/12270))
|
|
141
|
+
- chore: re-enable development warnings through a `development` exports condition. ([#12269](https://github.com/remix-run/react-router/pull/12269))
|
|
142
|
+
- include root "react-dom" module for optimization ([#12060](https://github.com/remix-run/react-router/pull/12060))
|
|
143
|
+
- resolve config directory relative to flat output file structure ([#12187](https://github.com/remix-run/react-router/pull/12187))
|
|
144
|
+
- if we are in SAP mode, always render the `index.html` for hydration ([#12268](https://github.com/remix-run/react-router/pull/12268))
|
|
145
|
+
- fix(react-router): (v7) fix static prerender of non-ascii characters ([#12161](https://github.com/remix-run/react-router/pull/12161))
|
|
146
|
+
- Updated dependencies:
|
|
147
|
+
- `react-router@7.0.0`
|
|
148
|
+
- `@react-router/serve@7.0.0`
|
|
149
|
+
- `@react-router/node@7.0.0`
|
|
2
150
|
|
|
3
151
|
## 2.9.0
|
|
4
152
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as Vite from 'vite';
|
|
2
|
+
|
|
3
|
+
interface ViteDevOptions {
|
|
4
|
+
clearScreen?: boolean;
|
|
5
|
+
config?: string;
|
|
6
|
+
cors?: boolean;
|
|
7
|
+
force?: boolean;
|
|
8
|
+
host?: boolean | string;
|
|
9
|
+
logLevel?: Vite.LogLevel;
|
|
10
|
+
mode?: string;
|
|
11
|
+
open?: boolean | string;
|
|
12
|
+
port?: number;
|
|
13
|
+
strictPort?: boolean;
|
|
14
|
+
profile?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type DevScriptArgs = {
|
|
18
|
+
root: string;
|
|
19
|
+
viteDevOptions: ViteDevOptions;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type { DevScriptArgs };
|
package/dist/cli/dev.js
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-89dc2043e
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
"use strict";
|
|
12
|
+
var __create = Object.create;
|
|
13
|
+
var __defProp = Object.defineProperty;
|
|
14
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
15
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
16
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
17
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
27
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
28
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
29
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
30
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
31
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
32
|
+
mod
|
|
33
|
+
));
|
|
34
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
|
+
|
|
36
|
+
// cli/dev.ts
|
|
37
|
+
var dev_exports = {};
|
|
38
|
+
module.exports = __toCommonJS(dev_exports);
|
|
39
|
+
var import_exit_hook = __toESM(require("exit-hook"));
|
|
40
|
+
|
|
41
|
+
// vite/profiler.ts
|
|
42
|
+
var import_node_fs = __toESM(require("fs"));
|
|
43
|
+
var import_node_path = __toESM(require("path"));
|
|
44
|
+
var import_picocolors = __toESM(require("picocolors"));
|
|
45
|
+
var getSession = () => global.__reactRouter_profile_session;
|
|
46
|
+
var start = async (callback) => {
|
|
47
|
+
let inspector = await import("inspector").then((r) => r.default);
|
|
48
|
+
let session = global.__reactRouter_profile_session = new inspector.Session();
|
|
49
|
+
session.connect();
|
|
50
|
+
session.post("Profiler.enable", () => {
|
|
51
|
+
session.post("Profiler.start", callback);
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
var profileCount = 0;
|
|
55
|
+
var stop = (log) => {
|
|
56
|
+
let session = getSession();
|
|
57
|
+
if (!session) return;
|
|
58
|
+
return new Promise((res, rej) => {
|
|
59
|
+
session.post("Profiler.stop", (err, { profile }) => {
|
|
60
|
+
if (err) return rej(err);
|
|
61
|
+
let outPath = import_node_path.default.resolve(`./react-router-${profileCount++}.cpuprofile`);
|
|
62
|
+
import_node_fs.default.writeFileSync(outPath, JSON.stringify(profile));
|
|
63
|
+
log(
|
|
64
|
+
import_picocolors.default.yellow(
|
|
65
|
+
`CPU profile written to ${import_picocolors.default.white(import_picocolors.default.dim(outPath))}`
|
|
66
|
+
)
|
|
67
|
+
);
|
|
68
|
+
global.__reactRouter_profile_session = void 0;
|
|
69
|
+
res();
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// vite/dev.ts
|
|
75
|
+
var import_picocolors2 = __toESM(require("picocolors"));
|
|
76
|
+
|
|
77
|
+
// invariant.ts
|
|
78
|
+
function invariant(value, message) {
|
|
79
|
+
if (value === false || value === null || typeof value === "undefined") {
|
|
80
|
+
console.error(
|
|
81
|
+
"The following error is a bug in React Router; please open an issue! https://github.com/remix-run/react-router/issues/new/choose"
|
|
82
|
+
);
|
|
83
|
+
throw new Error(message);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// vite/import-vite-esm-sync.ts
|
|
88
|
+
var vite;
|
|
89
|
+
async function preloadViteEsm() {
|
|
90
|
+
vite = await import("vite");
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// vite/dev.ts
|
|
94
|
+
async function dev(root, {
|
|
95
|
+
clearScreen,
|
|
96
|
+
config: configFile,
|
|
97
|
+
cors,
|
|
98
|
+
force,
|
|
99
|
+
host,
|
|
100
|
+
logLevel,
|
|
101
|
+
mode,
|
|
102
|
+
open,
|
|
103
|
+
port,
|
|
104
|
+
strictPort
|
|
105
|
+
}) {
|
|
106
|
+
await preloadViteEsm();
|
|
107
|
+
let vite2 = await import("vite");
|
|
108
|
+
let server = await vite2.createServer({
|
|
109
|
+
root,
|
|
110
|
+
mode,
|
|
111
|
+
configFile,
|
|
112
|
+
server: { open, cors, host, port, strictPort },
|
|
113
|
+
optimizeDeps: { force },
|
|
114
|
+
clearScreen,
|
|
115
|
+
logLevel
|
|
116
|
+
});
|
|
117
|
+
if (!server.config.plugins.find((plugin) => plugin.name === "react-router")) {
|
|
118
|
+
console.error(
|
|
119
|
+
import_picocolors2.default.red("React Router Vite plugin not found in Vite config")
|
|
120
|
+
);
|
|
121
|
+
process.exit(1);
|
|
122
|
+
}
|
|
123
|
+
await server.listen();
|
|
124
|
+
server.printUrls();
|
|
125
|
+
let customShortcuts = [
|
|
126
|
+
{
|
|
127
|
+
key: "p",
|
|
128
|
+
description: "start/stop the profiler",
|
|
129
|
+
async action(server2) {
|
|
130
|
+
if (getSession()) {
|
|
131
|
+
await stop(server2.config.logger.info);
|
|
132
|
+
} else {
|
|
133
|
+
await start(() => {
|
|
134
|
+
server2.config.logger.info("Profiler started");
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
];
|
|
140
|
+
server.bindCLIShortcuts({ print: true, customShortcuts });
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// cli/dev.ts
|
|
144
|
+
async function dev2(root, options = {}) {
|
|
145
|
+
if (options.profile) {
|
|
146
|
+
await start();
|
|
147
|
+
}
|
|
148
|
+
(0, import_exit_hook.default)(() => stop(console.info));
|
|
149
|
+
await dev(root, options);
|
|
150
|
+
}
|
|
151
|
+
(async () => {
|
|
152
|
+
let args = JSON.parse(process.argv[2]);
|
|
153
|
+
invariant(typeof args === "object", "dev script args must be an object");
|
|
154
|
+
await dev2(args.root, args.viteDevOptions);
|
|
155
|
+
})();
|
package/dist/cli/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* @react-router/dev v0.0.0-experimental-
|
|
3
|
+
* @react-router/dev v0.0.0-experimental-89dc2043e
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) Remix Software Inc.
|
|
6
6
|
*
|
|
@@ -991,45 +991,6 @@ if (import.meta.hot && !inWebWorker) {
|
|
|
991
991
|
}
|
|
992
992
|
});
|
|
993
993
|
|
|
994
|
-
// vite/profiler.ts
|
|
995
|
-
var import_node_fs3, import_node_path, import_picocolors4, getSession, start, profileCount, stop;
|
|
996
|
-
var init_profiler = __esm({
|
|
997
|
-
"vite/profiler.ts"() {
|
|
998
|
-
"use strict";
|
|
999
|
-
import_node_fs3 = __toESM(require("fs"));
|
|
1000
|
-
import_node_path = __toESM(require("path"));
|
|
1001
|
-
import_picocolors4 = __toESM(require("picocolors"));
|
|
1002
|
-
getSession = () => global.__reactRouter_profile_session;
|
|
1003
|
-
start = async (callback) => {
|
|
1004
|
-
let inspector = await import("inspector").then((r) => r.default);
|
|
1005
|
-
let session = global.__reactRouter_profile_session = new inspector.Session();
|
|
1006
|
-
session.connect();
|
|
1007
|
-
session.post("Profiler.enable", () => {
|
|
1008
|
-
session.post("Profiler.start", callback);
|
|
1009
|
-
});
|
|
1010
|
-
};
|
|
1011
|
-
profileCount = 0;
|
|
1012
|
-
stop = (log) => {
|
|
1013
|
-
let session = getSession();
|
|
1014
|
-
if (!session) return;
|
|
1015
|
-
return new Promise((res, rej) => {
|
|
1016
|
-
session.post("Profiler.stop", (err2, { profile }) => {
|
|
1017
|
-
if (err2) return rej(err2);
|
|
1018
|
-
let outPath = import_node_path.default.resolve(`./react-router-${profileCount++}.cpuprofile`);
|
|
1019
|
-
import_node_fs3.default.writeFileSync(outPath, JSON.stringify(profile));
|
|
1020
|
-
log(
|
|
1021
|
-
import_picocolors4.default.yellow(
|
|
1022
|
-
`CPU profile written to ${import_picocolors4.default.white(import_picocolors4.default.dim(outPath))}`
|
|
1023
|
-
)
|
|
1024
|
-
);
|
|
1025
|
-
global.__reactRouter_profile_session = void 0;
|
|
1026
|
-
res();
|
|
1027
|
-
});
|
|
1028
|
-
});
|
|
1029
|
-
};
|
|
1030
|
-
}
|
|
1031
|
-
});
|
|
1032
|
-
|
|
1033
994
|
// vite/build.ts
|
|
1034
995
|
var build_exports = {};
|
|
1035
996
|
__export(build_exports, {
|
|
@@ -1255,80 +1216,18 @@ var init_build = __esm({
|
|
|
1255
1216
|
}
|
|
1256
1217
|
});
|
|
1257
1218
|
|
|
1258
|
-
// vite/dev.ts
|
|
1259
|
-
var dev_exports = {};
|
|
1260
|
-
__export(dev_exports, {
|
|
1261
|
-
dev: () => dev
|
|
1262
|
-
});
|
|
1263
|
-
async function dev(root, {
|
|
1264
|
-
clearScreen,
|
|
1265
|
-
config: configFile,
|
|
1266
|
-
cors,
|
|
1267
|
-
force,
|
|
1268
|
-
host,
|
|
1269
|
-
logLevel,
|
|
1270
|
-
mode,
|
|
1271
|
-
open,
|
|
1272
|
-
port,
|
|
1273
|
-
strictPort
|
|
1274
|
-
}) {
|
|
1275
|
-
await preloadViteEsm();
|
|
1276
|
-
let vite2 = await import("vite");
|
|
1277
|
-
let server = await vite2.createServer({
|
|
1278
|
-
root,
|
|
1279
|
-
mode,
|
|
1280
|
-
configFile,
|
|
1281
|
-
server: { open, cors, host, port, strictPort },
|
|
1282
|
-
optimizeDeps: { force },
|
|
1283
|
-
clearScreen,
|
|
1284
|
-
logLevel
|
|
1285
|
-
});
|
|
1286
|
-
if (!server.config.plugins.find((plugin2) => plugin2.name === "react-router")) {
|
|
1287
|
-
console.error(
|
|
1288
|
-
import_picocolors6.default.red("React Router Vite plugin not found in Vite config")
|
|
1289
|
-
);
|
|
1290
|
-
process.exit(1);
|
|
1291
|
-
}
|
|
1292
|
-
await server.listen();
|
|
1293
|
-
server.printUrls();
|
|
1294
|
-
let customShortcuts = [
|
|
1295
|
-
{
|
|
1296
|
-
key: "p",
|
|
1297
|
-
description: "start/stop the profiler",
|
|
1298
|
-
async action(server2) {
|
|
1299
|
-
if (getSession()) {
|
|
1300
|
-
await stop(server2.config.logger.info);
|
|
1301
|
-
} else {
|
|
1302
|
-
await start(() => {
|
|
1303
|
-
server2.config.logger.info("Profiler started");
|
|
1304
|
-
});
|
|
1305
|
-
}
|
|
1306
|
-
}
|
|
1307
|
-
}
|
|
1308
|
-
];
|
|
1309
|
-
server.bindCLIShortcuts({ print: true, customShortcuts });
|
|
1310
|
-
}
|
|
1311
|
-
var import_picocolors6;
|
|
1312
|
-
var init_dev = __esm({
|
|
1313
|
-
"vite/dev.ts"() {
|
|
1314
|
-
"use strict";
|
|
1315
|
-
import_picocolors6 = __toESM(require("picocolors"));
|
|
1316
|
-
init_import_vite_esm_sync();
|
|
1317
|
-
init_profiler();
|
|
1318
|
-
}
|
|
1319
|
-
});
|
|
1320
|
-
|
|
1321
1219
|
// cli/run.ts
|
|
1322
1220
|
var import_arg = __toESM(require("arg"));
|
|
1323
1221
|
var import_semver = __toESM(require("semver"));
|
|
1324
|
-
var
|
|
1222
|
+
var import_picocolors7 = __toESM(require("picocolors"));
|
|
1325
1223
|
|
|
1326
1224
|
// cli/commands.ts
|
|
1327
1225
|
var path7 = __toESM(require("path"));
|
|
1328
1226
|
var import_fs_extra2 = __toESM(require("fs-extra"));
|
|
1329
1227
|
var import_package_json2 = __toESM(require("@npmcli/package-json"));
|
|
1330
|
-
var
|
|
1331
|
-
var
|
|
1228
|
+
var import_picocolors6 = __toESM(require("picocolors"));
|
|
1229
|
+
var import_execa = __toESM(require("execa"));
|
|
1230
|
+
init_invariant();
|
|
1332
1231
|
|
|
1333
1232
|
// config/format.ts
|
|
1334
1233
|
function formatRoutes(routeManifest, format) {
|
|
@@ -1407,8 +1306,40 @@ function transpile(tsx, options = {}) {
|
|
|
1407
1306
|
return import_prettier.default.format(mjs.code, { parser: "babel" });
|
|
1408
1307
|
}
|
|
1409
1308
|
|
|
1309
|
+
// vite/profiler.ts
|
|
1310
|
+
var import_node_fs3 = __toESM(require("fs"));
|
|
1311
|
+
var import_node_path = __toESM(require("path"));
|
|
1312
|
+
var import_picocolors4 = __toESM(require("picocolors"));
|
|
1313
|
+
var getSession = () => global.__reactRouter_profile_session;
|
|
1314
|
+
var start = async (callback) => {
|
|
1315
|
+
let inspector = await import("inspector").then((r) => r.default);
|
|
1316
|
+
let session = global.__reactRouter_profile_session = new inspector.Session();
|
|
1317
|
+
session.connect();
|
|
1318
|
+
session.post("Profiler.enable", () => {
|
|
1319
|
+
session.post("Profiler.start", callback);
|
|
1320
|
+
});
|
|
1321
|
+
};
|
|
1322
|
+
var profileCount = 0;
|
|
1323
|
+
var stop = (log) => {
|
|
1324
|
+
let session = getSession();
|
|
1325
|
+
if (!session) return;
|
|
1326
|
+
return new Promise((res, rej) => {
|
|
1327
|
+
session.post("Profiler.stop", (err2, { profile }) => {
|
|
1328
|
+
if (err2) return rej(err2);
|
|
1329
|
+
let outPath = import_node_path.default.resolve(`./react-router-${profileCount++}.cpuprofile`);
|
|
1330
|
+
import_node_fs3.default.writeFileSync(outPath, JSON.stringify(profile));
|
|
1331
|
+
log(
|
|
1332
|
+
import_picocolors4.default.yellow(
|
|
1333
|
+
`CPU profile written to ${import_picocolors4.default.white(import_picocolors4.default.dim(outPath))}`
|
|
1334
|
+
)
|
|
1335
|
+
);
|
|
1336
|
+
global.__reactRouter_profile_session = void 0;
|
|
1337
|
+
res();
|
|
1338
|
+
});
|
|
1339
|
+
});
|
|
1340
|
+
};
|
|
1341
|
+
|
|
1410
1342
|
// cli/commands.ts
|
|
1411
|
-
init_profiler();
|
|
1412
1343
|
init_typegen();
|
|
1413
1344
|
init_import_vite_esm_sync();
|
|
1414
1345
|
async function routes(reactRouterRoot, flags = {}) {
|
|
@@ -1418,7 +1349,7 @@ async function routes(reactRouterRoot, flags = {}) {
|
|
|
1418
1349
|
});
|
|
1419
1350
|
if (!ctx) {
|
|
1420
1351
|
console.error(
|
|
1421
|
-
|
|
1352
|
+
import_picocolors6.default.red("React Router Vite plugin not found in Vite config")
|
|
1422
1353
|
);
|
|
1423
1354
|
process.exit(1);
|
|
1424
1355
|
}
|
|
@@ -1439,13 +1370,23 @@ async function build2(root, options = {}) {
|
|
|
1439
1370
|
await stop(console.info);
|
|
1440
1371
|
}
|
|
1441
1372
|
}
|
|
1442
|
-
async function
|
|
1443
|
-
let
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1373
|
+
async function dev(root, viteDevOptions = {}) {
|
|
1374
|
+
let devScriptPath = path7.resolve(__dirname, "./dev.js");
|
|
1375
|
+
invariant(
|
|
1376
|
+
import_fs_extra2.default.existsSync(devScriptPath),
|
|
1377
|
+
`dev script not found at ${devScriptPath}`
|
|
1378
|
+
);
|
|
1379
|
+
let args = { root, viteDevOptions };
|
|
1380
|
+
let { NODE_OPTIONS } = process.env;
|
|
1381
|
+
if (!NODE_OPTIONS?.includes("--conditions")) {
|
|
1382
|
+
NODE_OPTIONS = `${NODE_OPTIONS ?? ""} --conditions=development`.trim();
|
|
1383
|
+
}
|
|
1384
|
+
(0, import_execa.default)(process.execPath, [devScriptPath, JSON.stringify(args)], {
|
|
1385
|
+
env: { ...process.env, NODE_OPTIONS },
|
|
1386
|
+
stdin: "inherit",
|
|
1387
|
+
stdout: "inherit",
|
|
1388
|
+
stderr: "inherit"
|
|
1389
|
+
});
|
|
1449
1390
|
await new Promise(() => {
|
|
1450
1391
|
});
|
|
1451
1392
|
}
|
|
@@ -1472,14 +1413,14 @@ async function generateEntry(entry, reactRouterRoot, flags = {}) {
|
|
|
1472
1413
|
let entriesArray = Array.from(entries);
|
|
1473
1414
|
let list = conjunctionListFormat.format(entriesArray);
|
|
1474
1415
|
console.error(
|
|
1475
|
-
|
|
1416
|
+
import_picocolors6.default.red(`Invalid entry file. Valid entry files are ${list}`)
|
|
1476
1417
|
);
|
|
1477
1418
|
return;
|
|
1478
1419
|
}
|
|
1479
1420
|
let pkgJson = await import_package_json2.default.load(rootDirectory);
|
|
1480
1421
|
let deps = pkgJson.content.dependencies ?? {};
|
|
1481
1422
|
if (!deps["@react-router/node"]) {
|
|
1482
|
-
console.error(
|
|
1423
|
+
console.error(import_picocolors6.default.red(`No default server entry detected.`));
|
|
1483
1424
|
return;
|
|
1484
1425
|
}
|
|
1485
1426
|
let defaultsDirectory = path7.resolve(
|
|
@@ -1509,7 +1450,7 @@ async function generateEntry(entry, reactRouterRoot, flags = {}) {
|
|
|
1509
1450
|
await import_fs_extra2.default.writeFile(outputFile2, contents, "utf-8");
|
|
1510
1451
|
}
|
|
1511
1452
|
console.log(
|
|
1512
|
-
|
|
1453
|
+
import_picocolors6.default.blue(
|
|
1513
1454
|
`Entry file ${entry} created at ${path7.relative(
|
|
1514
1455
|
rootDirectory,
|
|
1515
1456
|
outputFile2
|
|
@@ -1523,7 +1464,7 @@ async function checkForEntry(rootDirectory, appDirectory, entries2) {
|
|
|
1523
1464
|
let exists = await import_fs_extra2.default.pathExists(entryPath);
|
|
1524
1465
|
if (exists) {
|
|
1525
1466
|
let relative8 = path7.relative(rootDirectory, entryPath);
|
|
1526
|
-
console.error(
|
|
1467
|
+
console.error(import_picocolors6.default.red(`Entry file ${relative8} already exists.`));
|
|
1527
1468
|
return process.exit(1);
|
|
1528
1469
|
}
|
|
1529
1470
|
}
|
|
@@ -1554,14 +1495,14 @@ async function typegen(root, flags) {
|
|
|
1554
1495
|
|
|
1555
1496
|
// cli/run.ts
|
|
1556
1497
|
var helpText = `
|
|
1557
|
-
${
|
|
1498
|
+
${import_picocolors7.default.blueBright("react-router")}
|
|
1558
1499
|
|
|
1559
|
-
${
|
|
1560
|
-
$ react-router build [${
|
|
1561
|
-
$ react-router dev [${
|
|
1562
|
-
$ react-router routes [${
|
|
1500
|
+
${import_picocolors7.default.underline("Usage")}:
|
|
1501
|
+
$ react-router build [${import_picocolors7.default.yellowBright("projectDir")}]
|
|
1502
|
+
$ react-router dev [${import_picocolors7.default.yellowBright("projectDir")}]
|
|
1503
|
+
$ react-router routes [${import_picocolors7.default.yellowBright("projectDir")}]
|
|
1563
1504
|
|
|
1564
|
-
${
|
|
1505
|
+
${import_picocolors7.default.underline("Options")}:
|
|
1565
1506
|
--help, -h Print this help message and exit
|
|
1566
1507
|
--version, -v Print the CLI version and exit
|
|
1567
1508
|
--no-color Disable ANSI colors in console output
|
|
@@ -1597,22 +1538,22 @@ ${import_picocolors8.default.blueBright("react-router")}
|
|
|
1597
1538
|
\`typegen\` Options:
|
|
1598
1539
|
--watch Automatically regenerate types whenever route config (\`routes.ts\`) or route modules change
|
|
1599
1540
|
|
|
1600
|
-
${
|
|
1541
|
+
${import_picocolors7.default.underline("Build your project")}:
|
|
1601
1542
|
|
|
1602
1543
|
$ react-router build
|
|
1603
1544
|
|
|
1604
|
-
${
|
|
1545
|
+
${import_picocolors7.default.underline("Run your project locally in development")}:
|
|
1605
1546
|
|
|
1606
1547
|
$ react-router dev
|
|
1607
1548
|
|
|
1608
|
-
${
|
|
1549
|
+
${import_picocolors7.default.underline("Show all routes in your app")}:
|
|
1609
1550
|
|
|
1610
1551
|
$ react-router routes
|
|
1611
1552
|
$ react-router routes my-app
|
|
1612
1553
|
$ react-router routes --json
|
|
1613
1554
|
$ react-router routes --config vite.react-router.config.ts
|
|
1614
1555
|
|
|
1615
|
-
${
|
|
1556
|
+
${import_picocolors7.default.underline("Reveal the used entry point")}:
|
|
1616
1557
|
|
|
1617
1558
|
$ react-router reveal entry.client
|
|
1618
1559
|
$ react-router reveal entry.server
|
|
@@ -1620,7 +1561,7 @@ ${import_picocolors8.default.blueBright("react-router")}
|
|
|
1620
1561
|
$ react-router reveal entry.server --no-typescript
|
|
1621
1562
|
$ react-router reveal entry.server --config vite.react-router.config.ts
|
|
1622
1563
|
|
|
1623
|
-
${
|
|
1564
|
+
${import_picocolors7.default.underline("Generate types for route modules")}:
|
|
1624
1565
|
|
|
1625
1566
|
$ react-router typegen
|
|
1626
1567
|
$ react-router typegen --watch
|
|
@@ -1706,13 +1647,13 @@ async function run2(argv = process.argv.slice(2)) {
|
|
|
1706
1647
|
break;
|
|
1707
1648
|
}
|
|
1708
1649
|
case "dev":
|
|
1709
|
-
await
|
|
1650
|
+
await dev(input[1], flags);
|
|
1710
1651
|
break;
|
|
1711
1652
|
case "typegen":
|
|
1712
1653
|
await typegen(input[1], flags);
|
|
1713
1654
|
break;
|
|
1714
1655
|
default:
|
|
1715
|
-
await
|
|
1656
|
+
await dev(input[0], flags);
|
|
1716
1657
|
}
|
|
1717
1658
|
}
|
|
1718
1659
|
|
package/dist/config.d.ts
CHANGED
|
@@ -45,6 +45,9 @@ type BuildEndHook = (args: {
|
|
|
45
45
|
reactRouterConfig: ResolvedReactRouterConfig;
|
|
46
46
|
viteConfig: Vite.ResolvedConfig;
|
|
47
47
|
}) => void | Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Config to be exported via the default export from `react-router.config.ts`.
|
|
50
|
+
*/
|
|
48
51
|
type ReactRouterConfig = {
|
|
49
52
|
/**
|
|
50
53
|
* The path to the `app` directory, relative to the root directory. Defaults
|
package/dist/config.js
CHANGED
package/dist/routes.js
CHANGED
package/dist/vite/cloudflare.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-89dc2043e",
|
|
4
4
|
"description": "Dev tools and CLI for React Router",
|
|
5
5
|
"homepage": "https://reactrouter.com",
|
|
6
6
|
"bugs": {
|
|
@@ -67,6 +67,7 @@
|
|
|
67
67
|
"chokidar": "^4.0.0",
|
|
68
68
|
"dedent": "^1.5.3",
|
|
69
69
|
"es-module-lexer": "^1.3.1",
|
|
70
|
+
"execa": "5.1.1",
|
|
70
71
|
"exit-hook": "2.2.1",
|
|
71
72
|
"fs-extra": "^10.0.0",
|
|
72
73
|
"gunzip-maybe": "^1.4.2",
|
|
@@ -81,7 +82,7 @@
|
|
|
81
82
|
"set-cookie-parser": "^2.6.0",
|
|
82
83
|
"valibot": "^0.41.0",
|
|
83
84
|
"vite-node": "^1.6.0",
|
|
84
|
-
"@react-router/node": "0.0.0-experimental-
|
|
85
|
+
"@react-router/node": "0.0.0-experimental-89dc2043e"
|
|
85
86
|
},
|
|
86
87
|
"devDependencies": {
|
|
87
88
|
"@types/babel__core": "^7.20.5",
|
|
@@ -100,7 +101,6 @@
|
|
|
100
101
|
"@types/set-cookie-parser": "^2.4.1",
|
|
101
102
|
"dotenv": "^16.0.0",
|
|
102
103
|
"esbuild-register": "^3.3.2",
|
|
103
|
-
"execa": "5.1.1",
|
|
104
104
|
"express": "^4.19.2",
|
|
105
105
|
"fast-glob": "3.2.11",
|
|
106
106
|
"strip-ansi": "^6.0.1",
|
|
@@ -110,15 +110,15 @@
|
|
|
110
110
|
"vite": "^5.1.0",
|
|
111
111
|
"wireit": "0.14.9",
|
|
112
112
|
"wrangler": "^3.28.2",
|
|
113
|
-
"@react-router/serve": "0.0.0-experimental-
|
|
114
|
-
"react-router": "^0.0.0-experimental-
|
|
113
|
+
"@react-router/serve": "0.0.0-experimental-89dc2043e",
|
|
114
|
+
"react-router": "^0.0.0-experimental-89dc2043e"
|
|
115
115
|
},
|
|
116
116
|
"peerDependencies": {
|
|
117
117
|
"typescript": "^5.1.0",
|
|
118
118
|
"vite": "^5.1.0",
|
|
119
119
|
"wrangler": "^3.28.2",
|
|
120
|
-
"@react-router/serve": "^0.0.0-experimental-
|
|
121
|
-
"react-router": "^0.0.0-experimental-
|
|
120
|
+
"@react-router/serve": "^0.0.0-experimental-89dc2043e",
|
|
121
|
+
"react-router": "^0.0.0-experimental-89dc2043e"
|
|
122
122
|
},
|
|
123
123
|
"peerDependenciesMeta": {
|
|
124
124
|
"@react-router/serve": {
|