@react-router/dev 7.0.0-pre.2 → 7.0.0-pre.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/cli/index.d.ts +2 -1
- package/dist/cli/index.js +1352 -8
- package/dist/routes.d.ts +4 -2
- package/dist/routes.js +181 -11
- package/dist/typescript/plugin.d.ts +5 -2
- package/dist/typescript/plugin.js +479 -31
- package/dist/vite/cloudflare.d.ts +1 -1
- package/dist/vite/cloudflare.js +171 -5
- package/dist/vite.d.ts +2 -2
- package/dist/vite.js +2394 -5
- package/package.json +28 -7
- package/dist/cli/commands.d.ts +0 -13
- package/dist/cli/commands.js +0 -179
- package/dist/cli/detectPackageManager.d.ts +0 -10
- package/dist/cli/detectPackageManager.js +0 -39
- package/dist/cli/run.d.ts +0 -5
- package/dist/cli/run.js +0 -188
- package/dist/cli/useJavascript.d.ts +0 -4
- package/dist/cli/useJavascript.js +0 -66
- package/dist/colors.d.ts +0 -17
- package/dist/colors.js +0 -49
- package/dist/config/format.d.ts +0 -5
- package/dist/config/format.js +0 -68
- package/dist/config/routes.d.ts +0 -129
- package/dist/config/routes.js +0 -253
- package/dist/config/serverModes.d.ts +0 -9
- package/dist/invariant.d.ts +0 -2
- package/dist/invariant.js +0 -20
- package/dist/manifest.d.ts +0 -28
- package/dist/typescript/typegen.d.ts +0 -10
- package/dist/typescript/typegen.js +0 -190
- package/dist/vite/babel.d.ts +0 -20
- package/dist/vite/babel.js +0 -49
- package/dist/vite/build.d.ts +0 -15
- package/dist/vite/build.js +0 -249
- package/dist/vite/cloudflare-dev-proxy.d.ts +0 -21
- package/dist/vite/cloudflare-dev-proxy.js +0 -89
- package/dist/vite/combine-urls-test.d.ts +0 -1
- package/dist/vite/combine-urls.d.ts +0 -1
- package/dist/vite/combine-urls.js +0 -20
- package/dist/vite/config.d.ts +0 -234
- package/dist/vite/config.js +0 -282
- package/dist/vite/dev.d.ts +0 -15
- package/dist/vite/dev.js +0 -81
- package/dist/vite/import-vite-esm-sync.d.ts +0 -4
- package/dist/vite/import-vite-esm-sync.js +0 -28
- package/dist/vite/node-adapter.d.ts +0 -6
- package/dist/vite/node-adapter.js +0 -90
- package/dist/vite/plugin.d.ts +0 -75
- package/dist/vite/plugin.js +0 -1301
- package/dist/vite/profiler.d.ts +0 -5
- package/dist/vite/profiler.js +0 -55
- package/dist/vite/remove-exports-test.d.ts +0 -1
- package/dist/vite/remove-exports.d.ts +0 -2
- package/dist/vite/remove-exports.js +0 -148
- package/dist/vite/resolve-file-url.d.ts +0 -3
- package/dist/vite/resolve-file-url.js +0 -53
- package/dist/vite/styles.d.ts +0 -14
- package/dist/vite/styles.js +0 -199
- package/dist/vite/vite-node.d.ts +0 -9
- package/dist/vite/vite-node.js +0 -57
- package/dist/vite/vmod.d.ts +0 -3
- package/dist/vite/vmod.js +0 -21
- package/dist/vite/with-props.d.ts +0 -4
- package/dist/vite/with-props.js +0 -151
- /package/dist/{vite/static → static}/refresh-utils.cjs +0 -0
package/dist/vite/config.d.ts
DELETED
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
import type * as Vite from "vite";
|
|
2
|
-
import type * as ViteNode from "./vite-node";
|
|
3
|
-
import { type RouteManifest, type RouteManifestEntry } from "../config/routes";
|
|
4
|
-
declare const excludedConfigPresetKeys: readonly ["presets"];
|
|
5
|
-
type ExcludedConfigPresetKey = (typeof excludedConfigPresetKeys)[number];
|
|
6
|
-
type ConfigPreset = Omit<ReactRouterConfig, ExcludedConfigPresetKey>;
|
|
7
|
-
export type Preset = {
|
|
8
|
-
name: string;
|
|
9
|
-
reactRouterConfig?: (args: {
|
|
10
|
-
reactRouterUserConfig: ReactRouterConfig;
|
|
11
|
-
}) => ConfigPreset | Promise<ConfigPreset>;
|
|
12
|
-
reactRouterConfigResolved?: (args: {
|
|
13
|
-
reactRouterConfig: ResolvedReactRouterConfig;
|
|
14
|
-
}) => void | Promise<void>;
|
|
15
|
-
};
|
|
16
|
-
declare const branchRouteProperties: readonly ["id", "path", "file", "index"];
|
|
17
|
-
type BranchRoute = Pick<RouteManifestEntry, (typeof branchRouteProperties)[number]>;
|
|
18
|
-
export declare const configRouteToBranchRoute: (configRoute: RouteManifestEntry) => BranchRoute;
|
|
19
|
-
export type ServerBundlesFunction = (args: {
|
|
20
|
-
branch: BranchRoute[];
|
|
21
|
-
}) => string | Promise<string>;
|
|
22
|
-
type BaseBuildManifest = {
|
|
23
|
-
routes: RouteManifest;
|
|
24
|
-
};
|
|
25
|
-
type DefaultBuildManifest = BaseBuildManifest & {
|
|
26
|
-
serverBundles?: never;
|
|
27
|
-
routeIdToServerBundleId?: never;
|
|
28
|
-
};
|
|
29
|
-
export type ServerBundlesBuildManifest = BaseBuildManifest & {
|
|
30
|
-
serverBundles: {
|
|
31
|
-
[serverBundleId: string]: {
|
|
32
|
-
id: string;
|
|
33
|
-
file: string;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
routeIdToServerBundleId: Record<string, string>;
|
|
37
|
-
};
|
|
38
|
-
type ServerModuleFormat = "esm" | "cjs";
|
|
39
|
-
interface FutureConfig {
|
|
40
|
-
}
|
|
41
|
-
export type BuildManifest = DefaultBuildManifest | ServerBundlesBuildManifest;
|
|
42
|
-
type BuildEndHook = (args: {
|
|
43
|
-
buildManifest: BuildManifest | undefined;
|
|
44
|
-
reactRouterConfig: ResolvedReactRouterConfig;
|
|
45
|
-
viteConfig: Vite.ResolvedConfig;
|
|
46
|
-
}) => void | Promise<void>;
|
|
47
|
-
export type ReactRouterConfig = {
|
|
48
|
-
/**
|
|
49
|
-
* The path to the `app` directory, relative to `remix.config.js`. Defaults
|
|
50
|
-
* to `"app"`.
|
|
51
|
-
*/
|
|
52
|
-
appDirectory?: string;
|
|
53
|
-
/**
|
|
54
|
-
* The output format of the server build. Defaults to "esm".
|
|
55
|
-
*/
|
|
56
|
-
serverModuleFormat?: ServerModuleFormat;
|
|
57
|
-
/**
|
|
58
|
-
* Enabled future flags
|
|
59
|
-
*/
|
|
60
|
-
future?: [keyof FutureConfig] extends [never] ? {
|
|
61
|
-
[key: string]: never;
|
|
62
|
-
} : Partial<FutureConfig>;
|
|
63
|
-
/**
|
|
64
|
-
* The React Router app basename. Defaults to `"/"`.
|
|
65
|
-
*/
|
|
66
|
-
basename?: string;
|
|
67
|
-
/**
|
|
68
|
-
* The path to the build directory, relative to the project. Defaults to
|
|
69
|
-
* `"build"`.
|
|
70
|
-
*/
|
|
71
|
-
buildDirectory?: string;
|
|
72
|
-
/**
|
|
73
|
-
* A function that is called after the full React Router build is complete.
|
|
74
|
-
*/
|
|
75
|
-
buildEnd?: BuildEndHook;
|
|
76
|
-
/**
|
|
77
|
-
* An array of URLs to prerender to HTML files at build time. Can also be a
|
|
78
|
-
* function returning an array to dynamically generate URLs.
|
|
79
|
-
*/
|
|
80
|
-
prerender?: boolean | Array<string> | ((args: {
|
|
81
|
-
getStaticPaths: () => string[];
|
|
82
|
-
}) => Array<string> | Promise<Array<string>>);
|
|
83
|
-
/**
|
|
84
|
-
* An array of React Router plugin config presets to ease integration with
|
|
85
|
-
* other platforms and tools.
|
|
86
|
-
*/
|
|
87
|
-
presets?: Array<Preset>;
|
|
88
|
-
/**
|
|
89
|
-
* The file name of the server build output. This file
|
|
90
|
-
* should end in a `.js` extension and should be deployed to your server.
|
|
91
|
-
* Defaults to `"index.js"`.
|
|
92
|
-
*/
|
|
93
|
-
serverBuildFile?: string;
|
|
94
|
-
/**
|
|
95
|
-
* A function for assigning routes to different server bundles. This
|
|
96
|
-
* function should return a server bundle ID which will be used as the
|
|
97
|
-
* bundle's directory name within the server build directory.
|
|
98
|
-
*/
|
|
99
|
-
serverBundles?: ServerBundlesFunction;
|
|
100
|
-
/**
|
|
101
|
-
* Enable server-side rendering for your application. Disable to use "SPA
|
|
102
|
-
* Mode", which will request the `/` path at build-time and save it as an
|
|
103
|
-
* `index.html` file with your assets so your application can be deployed as a
|
|
104
|
-
* SPA without server-rendering. Default's to `true`.
|
|
105
|
-
*/
|
|
106
|
-
ssr?: boolean;
|
|
107
|
-
};
|
|
108
|
-
export type ResolvedReactRouterConfig = Readonly<{
|
|
109
|
-
/**
|
|
110
|
-
* The absolute path to the application source directory.
|
|
111
|
-
*/
|
|
112
|
-
appDirectory: string;
|
|
113
|
-
/**
|
|
114
|
-
* The React Router app basename. Defaults to `"/"`.
|
|
115
|
-
*/
|
|
116
|
-
basename: string;
|
|
117
|
-
/**
|
|
118
|
-
* The absolute path to the build directory.
|
|
119
|
-
*/
|
|
120
|
-
buildDirectory: string;
|
|
121
|
-
/**
|
|
122
|
-
* A function that is called after the full React Router build is complete.
|
|
123
|
-
*/
|
|
124
|
-
buildEnd?: BuildEndHook;
|
|
125
|
-
/**
|
|
126
|
-
* Enabled future flags
|
|
127
|
-
*/
|
|
128
|
-
future: FutureConfig;
|
|
129
|
-
/**
|
|
130
|
-
* An array of URLs to prerender to HTML files at build time. Can also be a
|
|
131
|
-
* function returning an array to dynamically generate URLs.
|
|
132
|
-
*/
|
|
133
|
-
prerender: ReactRouterConfig["prerender"];
|
|
134
|
-
/**
|
|
135
|
-
* An object of all available routes, keyed by route id.
|
|
136
|
-
*/
|
|
137
|
-
routes: RouteManifest;
|
|
138
|
-
/**
|
|
139
|
-
* The file name of the server build output. This file
|
|
140
|
-
* should end in a `.js` extension and should be deployed to your server.
|
|
141
|
-
* Defaults to `"index.js"`.
|
|
142
|
-
*/
|
|
143
|
-
serverBuildFile: string;
|
|
144
|
-
/**
|
|
145
|
-
* A function for assigning routes to different server bundles. This
|
|
146
|
-
* function should return a server bundle ID which will be used as the
|
|
147
|
-
* bundle's directory name within the server build directory.
|
|
148
|
-
*/
|
|
149
|
-
serverBundles?: ServerBundlesFunction;
|
|
150
|
-
/**
|
|
151
|
-
* The output format of the server build. Defaults to "esm".
|
|
152
|
-
*/
|
|
153
|
-
serverModuleFormat: ServerModuleFormat;
|
|
154
|
-
/**
|
|
155
|
-
* Enable server-side rendering for your application. Disable to use "SPA
|
|
156
|
-
* Mode", which will request the `/` path at build-time and save it as an
|
|
157
|
-
* `index.html` file with your assets so your application can be deployed as a
|
|
158
|
-
* SPA without server-rendering. Default's to `true`.
|
|
159
|
-
*/
|
|
160
|
-
ssr: boolean;
|
|
161
|
-
}>;
|
|
162
|
-
export declare function resolvePublicPath(viteUserConfig: Vite.UserConfig): string;
|
|
163
|
-
export declare function resolveReactRouterConfig({ rootDirectory, reactRouterUserConfig, routeConfigChanged, viteUserConfig, viteCommand, routesViteNodeContext, }: {
|
|
164
|
-
rootDirectory: string;
|
|
165
|
-
reactRouterUserConfig: ReactRouterConfig;
|
|
166
|
-
routeConfigChanged: boolean;
|
|
167
|
-
viteUserConfig: Vite.UserConfig;
|
|
168
|
-
viteCommand: Vite.ConfigEnv["command"];
|
|
169
|
-
routesViteNodeContext: ViteNode.Context;
|
|
170
|
-
}): Promise<Readonly<{
|
|
171
|
-
/**
|
|
172
|
-
* The absolute path to the application source directory.
|
|
173
|
-
*/
|
|
174
|
-
appDirectory: string;
|
|
175
|
-
/**
|
|
176
|
-
* The React Router app basename. Defaults to `"/"`.
|
|
177
|
-
*/
|
|
178
|
-
basename: string;
|
|
179
|
-
/**
|
|
180
|
-
* The absolute path to the build directory.
|
|
181
|
-
*/
|
|
182
|
-
buildDirectory: string;
|
|
183
|
-
/**
|
|
184
|
-
* A function that is called after the full React Router build is complete.
|
|
185
|
-
*/
|
|
186
|
-
buildEnd?: BuildEndHook | undefined;
|
|
187
|
-
/**
|
|
188
|
-
* Enabled future flags
|
|
189
|
-
*/
|
|
190
|
-
future: FutureConfig;
|
|
191
|
-
/**
|
|
192
|
-
* An array of URLs to prerender to HTML files at build time. Can also be a
|
|
193
|
-
* function returning an array to dynamically generate URLs.
|
|
194
|
-
*/
|
|
195
|
-
prerender: boolean | string[] | ((args: {
|
|
196
|
-
getStaticPaths: () => string[];
|
|
197
|
-
}) => string[] | Promise<string[]>) | undefined;
|
|
198
|
-
/**
|
|
199
|
-
* An object of all available routes, keyed by route id.
|
|
200
|
-
*/
|
|
201
|
-
routes: RouteManifest;
|
|
202
|
-
/**
|
|
203
|
-
* The file name of the server build output. This file
|
|
204
|
-
* should end in a `.js` extension and should be deployed to your server.
|
|
205
|
-
* Defaults to `"index.js"`.
|
|
206
|
-
*/
|
|
207
|
-
serverBuildFile: string;
|
|
208
|
-
/**
|
|
209
|
-
* A function for assigning routes to different server bundles. This
|
|
210
|
-
* function should return a server bundle ID which will be used as the
|
|
211
|
-
* bundle's directory name within the server build directory.
|
|
212
|
-
*/
|
|
213
|
-
serverBundles?: ServerBundlesFunction | undefined;
|
|
214
|
-
/**
|
|
215
|
-
* The output format of the server build. Defaults to "esm".
|
|
216
|
-
*/
|
|
217
|
-
serverModuleFormat: ServerModuleFormat;
|
|
218
|
-
/**
|
|
219
|
-
* Enable server-side rendering for your application. Disable to use "SPA
|
|
220
|
-
* Mode", which will request the `/` path at build-time and save it as an
|
|
221
|
-
* `index.html` file with your assets so your application can be deployed as a
|
|
222
|
-
* SPA without server-rendering. Default's to `true`.
|
|
223
|
-
*/
|
|
224
|
-
ssr: boolean;
|
|
225
|
-
}>>;
|
|
226
|
-
export declare function resolveEntryFiles({ rootDirectory, reactRouterConfig, }: {
|
|
227
|
-
rootDirectory: string;
|
|
228
|
-
reactRouterConfig: ResolvedReactRouterConfig;
|
|
229
|
-
}): Promise<{
|
|
230
|
-
entryClientFilePath: string;
|
|
231
|
-
entryServerFilePath: string;
|
|
232
|
-
}>;
|
|
233
|
-
export declare function findEntry(dir: string, basename: string): string | undefined;
|
|
234
|
-
export {};
|
package/dist/vite/config.js
DELETED
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @react-router/dev v7.0.0-pre.2
|
|
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
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
|
-
var node_child_process = require('node:child_process');
|
|
16
|
-
var path = require('node:path');
|
|
17
|
-
var fse = require('fs-extra');
|
|
18
|
-
var colors = require('picocolors');
|
|
19
|
-
var pick = require('lodash/pick');
|
|
20
|
-
var omit = require('lodash/omit');
|
|
21
|
-
var PackageJson = require('@npmcli/package-json');
|
|
22
|
-
var routes = require('../config/routes.js');
|
|
23
|
-
var detectPackageManager = require('../cli/detectPackageManager.js');
|
|
24
|
-
var importViteEsmSync = require('./import-vite-esm-sync.js');
|
|
25
|
-
|
|
26
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
27
|
-
|
|
28
|
-
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
29
|
-
var fse__default = /*#__PURE__*/_interopDefaultLegacy(fse);
|
|
30
|
-
var colors__default = /*#__PURE__*/_interopDefaultLegacy(colors);
|
|
31
|
-
var pick__default = /*#__PURE__*/_interopDefaultLegacy(pick);
|
|
32
|
-
var omit__default = /*#__PURE__*/_interopDefaultLegacy(omit);
|
|
33
|
-
var PackageJson__default = /*#__PURE__*/_interopDefaultLegacy(PackageJson);
|
|
34
|
-
|
|
35
|
-
const excludedConfigPresetKeys = ["presets"];
|
|
36
|
-
// Only expose a subset of route properties to the "serverBundles" function
|
|
37
|
-
const branchRouteProperties = ["id", "path", "file", "index"];
|
|
38
|
-
const configRouteToBranchRoute = configRoute => pick__default["default"](configRoute, branchRouteProperties);
|
|
39
|
-
let mergeReactRouterConfig = (...configs) => {
|
|
40
|
-
let reducer = (configA, configB) => {
|
|
41
|
-
let mergeRequired = key => configA[key] !== undefined && configB[key] !== undefined;
|
|
42
|
-
return {
|
|
43
|
-
...configA,
|
|
44
|
-
...configB,
|
|
45
|
-
...(mergeRequired("buildEnd") ? {
|
|
46
|
-
buildEnd: async (...args) => {
|
|
47
|
-
var _configA$buildEnd, _configB$buildEnd;
|
|
48
|
-
await Promise.all([(_configA$buildEnd = configA.buildEnd) === null || _configA$buildEnd === void 0 ? void 0 : _configA$buildEnd.call(configA, ...args), (_configB$buildEnd = configB.buildEnd) === null || _configB$buildEnd === void 0 ? void 0 : _configB$buildEnd.call(configB, ...args)]);
|
|
49
|
-
}
|
|
50
|
-
} : {}),
|
|
51
|
-
...(mergeRequired("future") ? {
|
|
52
|
-
future: {
|
|
53
|
-
...configA.future,
|
|
54
|
-
...configB.future
|
|
55
|
-
}
|
|
56
|
-
} : {}),
|
|
57
|
-
...(mergeRequired("presets") ? {
|
|
58
|
-
presets: [...(configA.presets ?? []), ...(configB.presets ?? [])]
|
|
59
|
-
} : {})
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
return configs.reduce(reducer, {});
|
|
63
|
-
};
|
|
64
|
-
// Inlined from https://github.com/jsdf/deep-freeze
|
|
65
|
-
let deepFreeze = o => {
|
|
66
|
-
Object.freeze(o);
|
|
67
|
-
let oIsFunction = typeof o === "function";
|
|
68
|
-
let hasOwnProp = Object.prototype.hasOwnProperty;
|
|
69
|
-
Object.getOwnPropertyNames(o).forEach(function (prop) {
|
|
70
|
-
if (hasOwnProp.call(o, prop) && (oIsFunction ? prop !== "caller" && prop !== "callee" && prop !== "arguments" : true) && o[prop] !== null && (typeof o[prop] === "object" || typeof o[prop] === "function") && !Object.isFrozen(o[prop])) {
|
|
71
|
-
deepFreeze(o[prop]);
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
return o;
|
|
75
|
-
};
|
|
76
|
-
function resolvePublicPath(viteUserConfig) {
|
|
77
|
-
return viteUserConfig.base ?? "/";
|
|
78
|
-
}
|
|
79
|
-
let isFirstLoad = true;
|
|
80
|
-
let lastValidRoutes = {};
|
|
81
|
-
async function resolveReactRouterConfig({
|
|
82
|
-
rootDirectory,
|
|
83
|
-
reactRouterUserConfig,
|
|
84
|
-
routeConfigChanged,
|
|
85
|
-
viteUserConfig,
|
|
86
|
-
viteCommand,
|
|
87
|
-
routesViteNodeContext
|
|
88
|
-
}) {
|
|
89
|
-
var _viteUserConfig$serve;
|
|
90
|
-
let vite = importViteEsmSync.importViteEsmSync();
|
|
91
|
-
let logger = vite.createLogger(viteUserConfig.logLevel, {
|
|
92
|
-
prefix: "[react-router]"
|
|
93
|
-
});
|
|
94
|
-
let presets = (await Promise.all((reactRouterUserConfig.presets ?? []).map(async preset => {
|
|
95
|
-
if (!preset.name) {
|
|
96
|
-
throw new Error("React Router presets must have a `name` property defined.");
|
|
97
|
-
}
|
|
98
|
-
if (!preset.reactRouterConfig) {
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
let configPreset = omit__default["default"](await preset.reactRouterConfig({
|
|
102
|
-
reactRouterUserConfig
|
|
103
|
-
}), excludedConfigPresetKeys);
|
|
104
|
-
return configPreset;
|
|
105
|
-
}))).filter(function isNotNull(value) {
|
|
106
|
-
return value !== null;
|
|
107
|
-
});
|
|
108
|
-
let defaults = {
|
|
109
|
-
basename: "/",
|
|
110
|
-
buildDirectory: "build",
|
|
111
|
-
serverBuildFile: "index.js",
|
|
112
|
-
serverModuleFormat: "esm",
|
|
113
|
-
ssr: true
|
|
114
|
-
};
|
|
115
|
-
let {
|
|
116
|
-
appDirectory: userAppDirectory,
|
|
117
|
-
basename,
|
|
118
|
-
buildDirectory: userBuildDirectory,
|
|
119
|
-
buildEnd,
|
|
120
|
-
prerender,
|
|
121
|
-
serverBuildFile,
|
|
122
|
-
serverBundles,
|
|
123
|
-
serverModuleFormat,
|
|
124
|
-
ssr
|
|
125
|
-
} = {
|
|
126
|
-
...defaults,
|
|
127
|
-
// Default values should be completely overridden by user/preset config, not merged
|
|
128
|
-
...mergeReactRouterConfig(...presets, reactRouterUserConfig)
|
|
129
|
-
};
|
|
130
|
-
// Log warning for incompatible vite config flags
|
|
131
|
-
if (!ssr && serverBundles) {
|
|
132
|
-
console.warn(colors__default["default"].yellow(colors__default["default"].bold("⚠️ SPA Mode: ") + "the `serverBundles` config is invalid with " + "`ssr:false` and will be ignored`"));
|
|
133
|
-
serverBundles = undefined;
|
|
134
|
-
}
|
|
135
|
-
let isValidPrerenderConfig = prerender == null || typeof prerender === "boolean" || Array.isArray(prerender) || typeof prerender === "function";
|
|
136
|
-
if (!isValidPrerenderConfig) {
|
|
137
|
-
logger.error(colors__default["default"].red("The `prerender` config must be a boolean, an array of string paths, " + "or a function returning a boolean or array of string paths"));
|
|
138
|
-
process.exit(1);
|
|
139
|
-
}
|
|
140
|
-
let appDirectory = path__default["default"].resolve(rootDirectory, userAppDirectory || "app");
|
|
141
|
-
let buildDirectory = path__default["default"].resolve(rootDirectory, userBuildDirectory);
|
|
142
|
-
let publicPath = resolvePublicPath(viteUserConfig);
|
|
143
|
-
if (basename !== "/" && viteCommand === "serve" && !((_viteUserConfig$serve = viteUserConfig.server) !== null && _viteUserConfig$serve !== void 0 && _viteUserConfig$serve.middlewareMode) && !basename.startsWith(publicPath)) {
|
|
144
|
-
logger.error(colors__default["default"].red("When using the React Router `basename` and the Vite `base` config, " + "the `basename` config must begin with `base` for the default " + "Vite dev server."));
|
|
145
|
-
process.exit(1);
|
|
146
|
-
}
|
|
147
|
-
let rootRouteFile = findEntry(appDirectory, "root");
|
|
148
|
-
if (!rootRouteFile) {
|
|
149
|
-
let rootRouteDisplayPath = path__default["default"].relative(rootDirectory, path__default["default"].join(appDirectory, "root.tsx"));
|
|
150
|
-
logger.error(colors__default["default"].red(`Could not find a root route module in the app directory as "${rootRouteDisplayPath}"`));
|
|
151
|
-
process.exit(1);
|
|
152
|
-
}
|
|
153
|
-
let routes$1 = {
|
|
154
|
-
root: {
|
|
155
|
-
path: "",
|
|
156
|
-
id: "root",
|
|
157
|
-
file: rootRouteFile
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
let routeConfigFile = findEntry(appDirectory, "routes");
|
|
161
|
-
class FriendlyError extends Error {}
|
|
162
|
-
try {
|
|
163
|
-
if (!routeConfigFile) {
|
|
164
|
-
let routeConfigDisplayPath = vite.normalizePath(path__default["default"].relative(rootDirectory, path__default["default"].join(appDirectory, "routes.ts")));
|
|
165
|
-
throw new FriendlyError(`Route config file not found at "${routeConfigDisplayPath}".`);
|
|
166
|
-
}
|
|
167
|
-
routes.setAppDirectory(appDirectory);
|
|
168
|
-
let routeConfigExport = (await routesViteNodeContext.runner.executeFile(path__default["default"].join(appDirectory, routeConfigFile))).routes;
|
|
169
|
-
let routeConfig = await routeConfigExport;
|
|
170
|
-
let result = routes.validateRouteConfig({
|
|
171
|
-
routeConfigFile,
|
|
172
|
-
routeConfig
|
|
173
|
-
});
|
|
174
|
-
if (!result.valid) {
|
|
175
|
-
throw new FriendlyError(result.message);
|
|
176
|
-
}
|
|
177
|
-
routes$1 = {
|
|
178
|
-
...routes$1,
|
|
179
|
-
...routes.configRoutesToRouteManifest(routeConfig)
|
|
180
|
-
};
|
|
181
|
-
lastValidRoutes = routes$1;
|
|
182
|
-
if (routeConfigChanged) {
|
|
183
|
-
logger.info(colors__default["default"].green("Route config changed."), {
|
|
184
|
-
clear: true,
|
|
185
|
-
timestamp: true
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
} catch (error) {
|
|
189
|
-
var _error$loc, _error$loc2, _error$frame$trim, _error$frame;
|
|
190
|
-
logger.error(error instanceof FriendlyError ? colors__default["default"].red(error.message) : [colors__default["default"].red(`Route config in "${routeConfigFile}" is invalid.`), "", (_error$loc = error.loc) !== null && _error$loc !== void 0 && _error$loc.file && (_error$loc2 = error.loc) !== null && _error$loc2 !== void 0 && _error$loc2.column && error.frame ? [path__default["default"].relative(appDirectory, error.loc.file) + ":" + error.loc.line + ":" + error.loc.column, (_error$frame$trim = (_error$frame = error.frame).trim) === null || _error$frame$trim === void 0 ? void 0 : _error$frame$trim.call(_error$frame)] : error.stack].flat().join("\n") + "\n", {
|
|
191
|
-
error,
|
|
192
|
-
clear: !isFirstLoad,
|
|
193
|
-
timestamp: !isFirstLoad
|
|
194
|
-
});
|
|
195
|
-
// Bail if this is the first time loading config, otherwise keep the dev server running
|
|
196
|
-
if (isFirstLoad) {
|
|
197
|
-
process.exit(1);
|
|
198
|
-
}
|
|
199
|
-
// Keep dev server running with the last valid routes to allow for correction
|
|
200
|
-
routes$1 = lastValidRoutes;
|
|
201
|
-
}
|
|
202
|
-
let future = {};
|
|
203
|
-
let reactRouterConfig = deepFreeze({
|
|
204
|
-
appDirectory,
|
|
205
|
-
basename,
|
|
206
|
-
buildDirectory,
|
|
207
|
-
buildEnd,
|
|
208
|
-
future,
|
|
209
|
-
prerender,
|
|
210
|
-
routes: routes$1,
|
|
211
|
-
serverBuildFile,
|
|
212
|
-
serverBundles,
|
|
213
|
-
serverModuleFormat,
|
|
214
|
-
ssr
|
|
215
|
-
});
|
|
216
|
-
for (let preset of reactRouterUserConfig.presets ?? []) {
|
|
217
|
-
var _preset$reactRouterCo;
|
|
218
|
-
await ((_preset$reactRouterCo = preset.reactRouterConfigResolved) === null || _preset$reactRouterCo === void 0 ? void 0 : _preset$reactRouterCo.call(preset, {
|
|
219
|
-
reactRouterConfig
|
|
220
|
-
}));
|
|
221
|
-
}
|
|
222
|
-
isFirstLoad = false;
|
|
223
|
-
return reactRouterConfig;
|
|
224
|
-
}
|
|
225
|
-
async function resolveEntryFiles({
|
|
226
|
-
rootDirectory,
|
|
227
|
-
reactRouterConfig
|
|
228
|
-
}) {
|
|
229
|
-
let {
|
|
230
|
-
appDirectory
|
|
231
|
-
} = reactRouterConfig;
|
|
232
|
-
let defaultsDirectory = path__default["default"].resolve(__dirname, "..", "config", "defaults");
|
|
233
|
-
let userEntryClientFile = findEntry(appDirectory, "entry.client");
|
|
234
|
-
let userEntryServerFile = findEntry(appDirectory, "entry.server");
|
|
235
|
-
let entryServerFile;
|
|
236
|
-
let entryClientFile = userEntryClientFile || "entry.client.tsx";
|
|
237
|
-
let pkgJson = await PackageJson__default["default"].load(rootDirectory);
|
|
238
|
-
let deps = pkgJson.content.dependencies ?? {};
|
|
239
|
-
if (userEntryServerFile) {
|
|
240
|
-
entryServerFile = userEntryServerFile;
|
|
241
|
-
} else {
|
|
242
|
-
if (!deps["@react-router/node"]) {
|
|
243
|
-
throw new Error(`Could not determine server runtime. Please install @react-router/node, or provide a custom entry.server.tsx/jsx file in your app directory.`);
|
|
244
|
-
}
|
|
245
|
-
if (!deps["isbot"]) {
|
|
246
|
-
console.log("adding `isbot@5` to your package.json, you should commit this change");
|
|
247
|
-
pkgJson.update({
|
|
248
|
-
dependencies: {
|
|
249
|
-
...pkgJson.content.dependencies,
|
|
250
|
-
isbot: "^5"
|
|
251
|
-
}
|
|
252
|
-
});
|
|
253
|
-
await pkgJson.save();
|
|
254
|
-
let packageManager = detectPackageManager.detectPackageManager() ?? "npm";
|
|
255
|
-
node_child_process.execSync(`${packageManager} install`, {
|
|
256
|
-
cwd: rootDirectory,
|
|
257
|
-
stdio: "inherit"
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
entryServerFile = `entry.server.node.tsx`;
|
|
261
|
-
}
|
|
262
|
-
let entryClientFilePath = userEntryClientFile ? path__default["default"].resolve(reactRouterConfig.appDirectory, userEntryClientFile) : path__default["default"].resolve(defaultsDirectory, entryClientFile);
|
|
263
|
-
let entryServerFilePath = userEntryServerFile ? path__default["default"].resolve(reactRouterConfig.appDirectory, userEntryServerFile) : path__default["default"].resolve(defaultsDirectory, entryServerFile);
|
|
264
|
-
return {
|
|
265
|
-
entryClientFilePath,
|
|
266
|
-
entryServerFilePath
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
const entryExts = [".js", ".jsx", ".ts", ".tsx"];
|
|
270
|
-
function findEntry(dir, basename) {
|
|
271
|
-
for (let ext of entryExts) {
|
|
272
|
-
let file = path__default["default"].resolve(dir, basename + ext);
|
|
273
|
-
if (fse__default["default"].existsSync(file)) return path__default["default"].relative(dir, file);
|
|
274
|
-
}
|
|
275
|
-
return undefined;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
exports.configRouteToBranchRoute = configRouteToBranchRoute;
|
|
279
|
-
exports.findEntry = findEntry;
|
|
280
|
-
exports.resolveEntryFiles = resolveEntryFiles;
|
|
281
|
-
exports.resolvePublicPath = resolvePublicPath;
|
|
282
|
-
exports.resolveReactRouterConfig = resolveReactRouterConfig;
|
package/dist/vite/dev.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type * as Vite from "vite";
|
|
2
|
-
export interface ViteDevOptions {
|
|
3
|
-
clearScreen?: boolean;
|
|
4
|
-
config?: string;
|
|
5
|
-
cors?: boolean;
|
|
6
|
-
force?: boolean;
|
|
7
|
-
host?: boolean | string;
|
|
8
|
-
logLevel?: Vite.LogLevel;
|
|
9
|
-
mode?: string;
|
|
10
|
-
open?: boolean | string;
|
|
11
|
-
port?: number;
|
|
12
|
-
strictPort?: boolean;
|
|
13
|
-
profile?: boolean;
|
|
14
|
-
}
|
|
15
|
-
export declare function dev(root: string, { clearScreen, config: configFile, cors, force, host, logLevel, mode, open, port, strictPort, }: ViteDevOptions): Promise<void>;
|
package/dist/vite/dev.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @react-router/dev v7.0.0-pre.2
|
|
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
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
|
-
var colors = require('picocolors');
|
|
16
|
-
var importViteEsmSync = require('./import-vite-esm-sync.js');
|
|
17
|
-
var profiler = require('./profiler.js');
|
|
18
|
-
|
|
19
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
20
|
-
|
|
21
|
-
var colors__default = /*#__PURE__*/_interopDefaultLegacy(colors);
|
|
22
|
-
|
|
23
|
-
async function dev(root, {
|
|
24
|
-
clearScreen,
|
|
25
|
-
config: configFile,
|
|
26
|
-
cors,
|
|
27
|
-
force,
|
|
28
|
-
host,
|
|
29
|
-
logLevel,
|
|
30
|
-
mode,
|
|
31
|
-
open,
|
|
32
|
-
port,
|
|
33
|
-
strictPort
|
|
34
|
-
}) {
|
|
35
|
-
// Ensure Vite's ESM build is preloaded at the start of the process
|
|
36
|
-
// so it can be accessed synchronously via `importViteEsmSync`
|
|
37
|
-
await importViteEsmSync.preloadViteEsm();
|
|
38
|
-
let vite = await import('vite');
|
|
39
|
-
let server = await vite.createServer({
|
|
40
|
-
root,
|
|
41
|
-
mode,
|
|
42
|
-
configFile,
|
|
43
|
-
server: {
|
|
44
|
-
open,
|
|
45
|
-
cors,
|
|
46
|
-
host,
|
|
47
|
-
port,
|
|
48
|
-
strictPort
|
|
49
|
-
},
|
|
50
|
-
optimizeDeps: {
|
|
51
|
-
force
|
|
52
|
-
},
|
|
53
|
-
clearScreen,
|
|
54
|
-
logLevel
|
|
55
|
-
});
|
|
56
|
-
if (!server.config.plugins.find(plugin => plugin.name === "react-router")) {
|
|
57
|
-
console.error(colors__default["default"].red("React Router Vite plugin not found in Vite config"));
|
|
58
|
-
process.exit(1);
|
|
59
|
-
}
|
|
60
|
-
await server.listen();
|
|
61
|
-
server.printUrls();
|
|
62
|
-
let customShortcuts = [{
|
|
63
|
-
key: "p",
|
|
64
|
-
description: "start/stop the profiler",
|
|
65
|
-
async action(server) {
|
|
66
|
-
if (profiler.getSession()) {
|
|
67
|
-
await profiler.stop(server.config.logger.info);
|
|
68
|
-
} else {
|
|
69
|
-
await profiler.start(() => {
|
|
70
|
-
server.config.logger.info("Profiler started");
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}];
|
|
75
|
-
server.bindCLIShortcuts({
|
|
76
|
-
print: true,
|
|
77
|
-
customShortcuts
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
exports.dev = dev;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @react-router/dev v7.0.0-pre.2
|
|
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
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
|
-
var invariant = require('../invariant.js');
|
|
16
|
-
|
|
17
|
-
// This file is used to avoid CJS deprecation warnings in Vite 5 since
|
|
18
|
-
let vite;
|
|
19
|
-
async function preloadViteEsm() {
|
|
20
|
-
vite = await import('vite');
|
|
21
|
-
}
|
|
22
|
-
function importViteEsmSync() {
|
|
23
|
-
invariant(vite, "importViteEsmSync() called before preloadViteEsm()");
|
|
24
|
-
return vite;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
exports.importViteEsmSync = importViteEsmSync;
|
|
28
|
-
exports.preloadViteEsm = preloadViteEsm;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import type { ServerResponse } from "node:http";
|
|
3
|
-
import type * as Vite from "vite";
|
|
4
|
-
export type NodeRequestHandler = (req: Vite.Connect.IncomingMessage, res: ServerResponse) => Promise<void>;
|
|
5
|
-
export declare function fromNodeRequest(nodeReq: Vite.Connect.IncomingMessage, nodeRes: ServerResponse<Vite.Connect.IncomingMessage>): Request;
|
|
6
|
-
export declare function toNodeRequest(res: Response, nodeRes: ServerResponse): Promise<void>;
|