@react-router/dev 0.0.0-experimental-7b411a741 → 0.0.0-experimental-79e23be50
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.js +1 -1
- package/dist/cli/detectPackageManager.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/run.js +1 -1
- package/dist/cli/useJavascript.js +1 -1
- package/dist/cli.js +1 -1
- package/dist/colors.js +1 -1
- package/dist/config/findConfig.d.ts +1 -0
- package/dist/config/findConfig.js +32 -0
- package/dist/config/{flat-routes.js → flatRoutes.js} +5 -5
- package/dist/config/format.js +1 -1
- package/dist/config/routes.js +1 -1
- package/dist/config.d.ts +197 -23
- package/dist/config.js +192 -65
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/invariant.js +1 -1
- package/dist/vite/babel.js +1 -1
- package/dist/vite/build.js +3 -2
- package/dist/vite/cloudflare-proxy-plugin.js +1 -1
- package/dist/vite/dev.js +1 -1
- package/dist/vite/import-vite-esm-sync.js +1 -1
- package/dist/vite/index.d.ts +0 -1
- package/dist/vite/index.js +1 -1
- package/dist/vite/node-adapter.js +1 -1
- package/dist/vite/plugin.d.ts +2 -96
- package/dist/vite/plugin.js +35 -141
- 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.d.ts +2 -2
- package/dist/vite/styles.js +1 -1
- package/dist/vite/vmod.js +1 -1
- package/package.json +7 -7
- package/dist/config/serverModes.js +0 -28
- /package/dist/config/{flat-routes.d.ts → flatRoutes.d.ts} +0 -0
package/dist/cli/commands.js
CHANGED
package/dist/cli/index.js
CHANGED
package/dist/cli/run.js
CHANGED
package/dist/cli.js
CHANGED
package/dist/colors.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function findConfig(dir: string, basename: string, extensions: string[]): string | undefined;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-79e23be50
|
|
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 path = require('node:path');
|
|
16
|
+
var fse = require('fs-extra');
|
|
17
|
+
|
|
18
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
19
|
+
|
|
20
|
+
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
21
|
+
var fse__default = /*#__PURE__*/_interopDefaultLegacy(fse);
|
|
22
|
+
|
|
23
|
+
function findConfig(dir, basename, extensions) {
|
|
24
|
+
for (let ext of extensions) {
|
|
25
|
+
let name = basename + ext;
|
|
26
|
+
let file = path__default["default"].join(dir, name);
|
|
27
|
+
if (fse__default["default"].existsSync(file)) return file;
|
|
28
|
+
}
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
exports.findConfig = findConfig;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @react-router/dev v0.0.0-experimental-
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-79e23be50
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -16,7 +16,7 @@ var fs = require('node:fs');
|
|
|
16
16
|
var path = require('node:path');
|
|
17
17
|
var minimatch = require('minimatch');
|
|
18
18
|
var routes = require('./routes.js');
|
|
19
|
-
var
|
|
19
|
+
var findConfig = require('./findConfig.js');
|
|
20
20
|
|
|
21
21
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
22
22
|
|
|
@@ -69,7 +69,7 @@ class PrefixLookupTrie {
|
|
|
69
69
|
function flatRoutes(appDirectory, ignoredFilePatterns = [], prefix = "routes") {
|
|
70
70
|
let ignoredFileRegex = Array.from(new Set(["**/.*", ...ignoredFilePatterns])).map(re => minimatch.makeRe(re)).filter(re => !!re);
|
|
71
71
|
let routesDir = path__default["default"].join(appDirectory, prefix);
|
|
72
|
-
let rootRoute =
|
|
72
|
+
let rootRoute = findConfig.findConfig(appDirectory, "root", routeModuleExts);
|
|
73
73
|
if (!rootRoute) {
|
|
74
74
|
throw new Error(`Could not find a root route module in the app directory: ${appDirectory}`);
|
|
75
75
|
}
|
|
@@ -240,8 +240,8 @@ function findRouteModuleForFolder(appDirectory, filepath, ignoredFileRegex) {
|
|
|
240
240
|
let relativePath = path__default["default"].relative(appDirectory, filepath);
|
|
241
241
|
let isIgnored = ignoredFileRegex.some(regex => regex.test(relativePath));
|
|
242
242
|
if (isIgnored) return null;
|
|
243
|
-
let routeRouteModule =
|
|
244
|
-
let routeIndexModule =
|
|
243
|
+
let routeRouteModule = findConfig.findConfig(filepath, "route", routeModuleExts);
|
|
244
|
+
let routeIndexModule = findConfig.findConfig(filepath, "index", routeModuleExts);
|
|
245
245
|
// if both a route and index module exist, throw a conflict error
|
|
246
246
|
// preferring the route module over the index module
|
|
247
247
|
if (routeRouteModule && routeIndexModule) {
|
package/dist/config/format.js
CHANGED
package/dist/config/routes.js
CHANGED
package/dist/config.d.ts
CHANGED
|
@@ -1,17 +1,53 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type * as Vite from "vite";
|
|
2
|
+
import { type RouteManifest, type ConfigRoute, type DefineRoutesFunction } from "./config/routes";
|
|
3
|
+
declare const excludedConfigPresetKeys: readonly ["presets"];
|
|
4
|
+
type ExcludedConfigPresetKey = (typeof excludedConfigPresetKeys)[number];
|
|
5
|
+
type ConfigPreset = Omit<VitePluginConfig, ExcludedConfigPresetKey>;
|
|
6
|
+
export type Preset = {
|
|
7
|
+
name: string;
|
|
8
|
+
reactRouterConfig?: (args: {
|
|
9
|
+
reactRouterUserConfig: VitePluginConfig;
|
|
10
|
+
}) => ConfigPreset | Promise<ConfigPreset>;
|
|
11
|
+
reactRouterConfigResolved?: (args: {
|
|
12
|
+
reactRouterConfig: ResolvedVitePluginConfig;
|
|
13
|
+
}) => void | Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
declare const branchRouteProperties: readonly ["id", "path", "file", "index"];
|
|
16
|
+
type BranchRoute = Pick<ConfigRoute, (typeof branchRouteProperties)[number]>;
|
|
17
|
+
export declare const configRouteToBranchRoute: (configRoute: ConfigRoute) => BranchRoute;
|
|
18
|
+
export type ServerBundlesFunction = (args: {
|
|
19
|
+
branch: BranchRoute[];
|
|
20
|
+
}) => string | Promise<string>;
|
|
21
|
+
type BaseBuildManifest = {
|
|
22
|
+
routes: RouteManifest;
|
|
23
|
+
};
|
|
24
|
+
type DefaultBuildManifest = BaseBuildManifest & {
|
|
25
|
+
serverBundles?: never;
|
|
26
|
+
routeIdToServerBundleId?: never;
|
|
27
|
+
};
|
|
28
|
+
export type ServerBundlesBuildManifest = BaseBuildManifest & {
|
|
29
|
+
serverBundles: {
|
|
30
|
+
[serverBundleId: string]: {
|
|
31
|
+
id: string;
|
|
32
|
+
file: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
routeIdToServerBundleId: Record<string, string>;
|
|
36
|
+
};
|
|
37
|
+
type ServerModuleFormat = "esm" | "cjs";
|
|
5
38
|
interface FutureConfig {
|
|
6
39
|
v3_fetcherPersist: boolean;
|
|
7
40
|
v3_relativeSplatPath: boolean;
|
|
8
41
|
v3_throwAbortReason: boolean;
|
|
9
42
|
unstable_singleFetch: boolean;
|
|
10
43
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
44
|
+
export type BuildManifest = DefaultBuildManifest | ServerBundlesBuildManifest;
|
|
45
|
+
type BuildEndHook = (args: {
|
|
46
|
+
buildManifest: BuildManifest | undefined;
|
|
47
|
+
reactRouterConfig: ResolvedVitePluginConfig;
|
|
48
|
+
viteConfig: Vite.ResolvedConfig;
|
|
49
|
+
}) => void | Promise<void>;
|
|
50
|
+
export type VitePluginConfig = {
|
|
15
51
|
/**
|
|
16
52
|
* The path to the `app` directory, relative to `remix.config.js`. Defaults
|
|
17
53
|
* to `"app"`.
|
|
@@ -39,37 +75,175 @@ export interface AppConfig {
|
|
|
39
75
|
future?: [keyof FutureConfig] extends [never] ? {
|
|
40
76
|
[key: string]: never;
|
|
41
77
|
} : Partial<FutureConfig>;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
78
|
+
/**
|
|
79
|
+
* The React Router app basename. Defaults to `"/"`.
|
|
80
|
+
*/
|
|
81
|
+
basename?: string;
|
|
82
|
+
/**
|
|
83
|
+
* The path to the build directory, relative to the project. Defaults to
|
|
84
|
+
* `"build"`.
|
|
85
|
+
*/
|
|
86
|
+
buildDirectory?: string;
|
|
87
|
+
/**
|
|
88
|
+
* A function that is called after the full React Router build is complete.
|
|
89
|
+
*/
|
|
90
|
+
buildEnd?: BuildEndHook;
|
|
91
|
+
/**
|
|
92
|
+
* Whether to write a `"manifest.json"` file to the build directory.`
|
|
93
|
+
* Defaults to `false`.
|
|
94
|
+
*/
|
|
95
|
+
manifest?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* An array of React Router plugin config presets to ease integration with
|
|
98
|
+
* other platforms and tools.
|
|
99
|
+
*/
|
|
100
|
+
presets?: Array<Preset>;
|
|
101
|
+
/**
|
|
102
|
+
* The file name of the server build output. This file
|
|
103
|
+
* should end in a `.js` extension and should be deployed to your server.
|
|
104
|
+
* Defaults to `"index.js"`.
|
|
105
|
+
*/
|
|
106
|
+
serverBuildFile?: string;
|
|
107
|
+
/**
|
|
108
|
+
* A function for assigning routes to different server bundles. This
|
|
109
|
+
* function should return a server bundle ID which will be used as the
|
|
110
|
+
* bundle's directory name within the server build directory.
|
|
111
|
+
*/
|
|
112
|
+
serverBundles?: ServerBundlesFunction;
|
|
113
|
+
/**
|
|
114
|
+
* Enable server-side rendering for your application. Disable to use "SPA
|
|
115
|
+
* Mode", which will request the `/` path at build-time and save it as an
|
|
116
|
+
* `index.html` file with your assets so your application can be deployed as a
|
|
117
|
+
* SPA without server-rendering. Default's to `true`.
|
|
118
|
+
*/
|
|
119
|
+
ssr?: boolean;
|
|
120
|
+
};
|
|
121
|
+
export type ResolvedVitePluginConfig = Readonly<{
|
|
47
122
|
/**
|
|
48
123
|
* The absolute path to the application source directory.
|
|
49
124
|
*/
|
|
50
125
|
appDirectory: string;
|
|
51
126
|
/**
|
|
52
|
-
* The
|
|
127
|
+
* The React Router app basename. Defaults to `"/"`.
|
|
53
128
|
*/
|
|
54
|
-
|
|
129
|
+
basename: string;
|
|
55
130
|
/**
|
|
56
|
-
* The absolute path to the
|
|
131
|
+
* The absolute path to the build directory.
|
|
57
132
|
*/
|
|
58
|
-
|
|
133
|
+
buildDirectory: string;
|
|
134
|
+
/**
|
|
135
|
+
* A function that is called after the full React Router build is complete.
|
|
136
|
+
*/
|
|
137
|
+
buildEnd?: BuildEndHook;
|
|
138
|
+
/**
|
|
139
|
+
* Enabled future flags
|
|
140
|
+
*/
|
|
141
|
+
future: FutureConfig;
|
|
142
|
+
/**
|
|
143
|
+
* Whether to write a `"manifest.json"` file to the build directory.`
|
|
144
|
+
* Defaults to `false`.
|
|
145
|
+
*/
|
|
146
|
+
manifest: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Derived from Vite's `base` config
|
|
149
|
+
* */
|
|
150
|
+
publicPath: string;
|
|
59
151
|
/**
|
|
60
152
|
* An object of all available routes, keyed by route id.
|
|
61
153
|
*/
|
|
62
154
|
routes: RouteManifest;
|
|
155
|
+
/**
|
|
156
|
+
* The file name of the server build output. This file
|
|
157
|
+
* should end in a `.js` extension and should be deployed to your server.
|
|
158
|
+
* Defaults to `"index.js"`.
|
|
159
|
+
*/
|
|
160
|
+
serverBuildFile: string;
|
|
161
|
+
/**
|
|
162
|
+
* A function for assigning routes to different server bundles. This
|
|
163
|
+
* function should return a server bundle ID which will be used as the
|
|
164
|
+
* bundle's directory name within the server build directory.
|
|
165
|
+
*/
|
|
166
|
+
serverBundles?: ServerBundlesFunction;
|
|
63
167
|
/**
|
|
64
168
|
* The output format of the server build. Defaults to "esm".
|
|
65
169
|
*/
|
|
66
170
|
serverModuleFormat: ServerModuleFormat;
|
|
171
|
+
/**
|
|
172
|
+
* Enable server-side rendering for your application. Disable to use "SPA
|
|
173
|
+
* Mode", which will request the `/` path at build-time and save it as an
|
|
174
|
+
* `index.html` file with your assets so your application can be deployed as a
|
|
175
|
+
* SPA without server-rendering. Default's to `true`.
|
|
176
|
+
*/
|
|
177
|
+
ssr: boolean;
|
|
178
|
+
}>;
|
|
179
|
+
export declare function resolveReactRouterConfig({ rootDirectory, reactRouterUserConfig, viteUserConfig, viteCommand, }: {
|
|
180
|
+
rootDirectory: string;
|
|
181
|
+
reactRouterUserConfig: VitePluginConfig;
|
|
182
|
+
viteUserConfig: Vite.UserConfig;
|
|
183
|
+
viteCommand: Vite.ConfigEnv["command"];
|
|
184
|
+
}): Promise<Readonly<{
|
|
185
|
+
/**
|
|
186
|
+
* The absolute path to the application source directory.
|
|
187
|
+
*/
|
|
188
|
+
appDirectory: string;
|
|
189
|
+
/**
|
|
190
|
+
* The React Router app basename. Defaults to `"/"`.
|
|
191
|
+
*/
|
|
192
|
+
basename: string;
|
|
193
|
+
/**
|
|
194
|
+
* The absolute path to the build directory.
|
|
195
|
+
*/
|
|
196
|
+
buildDirectory: string;
|
|
197
|
+
/**
|
|
198
|
+
* A function that is called after the full React Router build is complete.
|
|
199
|
+
*/
|
|
200
|
+
buildEnd?: BuildEndHook | undefined;
|
|
201
|
+
/**
|
|
202
|
+
* Enabled future flags
|
|
203
|
+
*/
|
|
67
204
|
future: FutureConfig;
|
|
68
|
-
|
|
69
|
-
|
|
205
|
+
/**
|
|
206
|
+
* Whether to write a `"manifest.json"` file to the build directory.`
|
|
207
|
+
* Defaults to `false`.
|
|
208
|
+
*/
|
|
209
|
+
manifest: boolean;
|
|
210
|
+
/**
|
|
211
|
+
* Derived from Vite's `base` config
|
|
212
|
+
* */
|
|
213
|
+
publicPath: string;
|
|
214
|
+
/**
|
|
215
|
+
* An object of all available routes, keyed by route id.
|
|
216
|
+
*/
|
|
217
|
+
routes: RouteManifest;
|
|
218
|
+
/**
|
|
219
|
+
* The file name of the server build output. This file
|
|
220
|
+
* should end in a `.js` extension and should be deployed to your server.
|
|
221
|
+
* Defaults to `"index.js"`.
|
|
222
|
+
*/
|
|
223
|
+
serverBuildFile: string;
|
|
224
|
+
/**
|
|
225
|
+
* A function for assigning routes to different server bundles. This
|
|
226
|
+
* function should return a server bundle ID which will be used as the
|
|
227
|
+
* bundle's directory name within the server build directory.
|
|
228
|
+
*/
|
|
229
|
+
serverBundles?: ServerBundlesFunction | undefined;
|
|
230
|
+
/**
|
|
231
|
+
* The output format of the server build. Defaults to "esm".
|
|
232
|
+
*/
|
|
233
|
+
serverModuleFormat: ServerModuleFormat;
|
|
234
|
+
/**
|
|
235
|
+
* Enable server-side rendering for your application. Disable to use "SPA
|
|
236
|
+
* Mode", which will request the `/` path at build-time and save it as an
|
|
237
|
+
* `index.html` file with your assets so your application can be deployed as a
|
|
238
|
+
* SPA without server-rendering. Default's to `true`.
|
|
239
|
+
*/
|
|
240
|
+
ssr: boolean;
|
|
241
|
+
}>>;
|
|
242
|
+
export declare function resolveEntryFiles({ rootDirectory, reactRouterConfig, }: {
|
|
70
243
|
rootDirectory: string;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
244
|
+
reactRouterConfig: ResolvedVitePluginConfig;
|
|
245
|
+
}): Promise<{
|
|
246
|
+
entryClientFilePath: string;
|
|
247
|
+
entryServerFilePath: string;
|
|
248
|
+
}>;
|
|
75
249
|
export {};
|