@react-router/dev 0.0.0-experimental-3278f3ca6 → 0.0.0-experimental-2d5e406e4
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/colors.js +1 -1
- package/dist/config/format.js +1 -1
- package/dist/config/routes.js +2 -2
- package/dist/invariant.js +2 -4
- package/dist/routes.js +1 -1
- package/dist/typescript/ast.d.ts +8 -0
- package/dist/typescript/ast.js +98 -0
- package/dist/typescript/autotype/api.completions.d.ts +5 -0
- package/dist/typescript/autotype/api.completions.js +75 -0
- package/dist/typescript/autotype/api.definitions.d.ts +4 -0
- package/dist/typescript/autotype/api.definitions.js +55 -0
- package/dist/typescript/autotype/api.diagnostics.d.ts +5 -0
- package/dist/typescript/autotype/api.diagnostics.js +60 -0
- package/dist/typescript/autotype/api.hover.d.ts +3 -0
- package/dist/typescript/autotype/api.hover.js +33 -0
- package/dist/typescript/autotype/api.inlay-hints.d.ts +3 -0
- package/dist/typescript/autotype/api.inlay-hints.js +31 -0
- package/dist/typescript/autotype/index.d.ts +5 -0
- package/dist/typescript/autotype/language-service.d.ts +35 -0
- package/dist/typescript/autotype/language-service.js +290 -0
- package/dist/typescript/context.d.ts +15 -0
- package/dist/typescript/decorate.d.ts +2 -0
- package/dist/typescript/decorate.js +233 -0
- package/dist/typescript/plugin.d.ts +6 -0
- package/dist/typescript/plugin.js +67 -0
- package/dist/typescript/routes.d.ts +10 -0
- package/dist/typescript/routes.js +102 -0
- package/dist/typescript/typecheck.d.ts +1 -0
- package/dist/typescript/typegen.d.ts +5 -0
- package/dist/typescript/typegen.js +165 -0
- package/dist/vite/babel.d.ts +1 -1
- package/dist/vite/babel.js +1 -1
- package/dist/vite/build.js +3 -3
- 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.d.ts +14 -8
- package/dist/vite/config.js +8 -14
- package/dist/vite/dev.js +1 -1
- package/dist/vite/import-vite-esm-sync.js +2 -2
- package/dist/vite/node-adapter.js +2 -2
- package/dist/vite/plugin.d.ts +1 -1
- package/dist/vite/plugin.js +64 -55
- 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.d.ts +9 -0
- package/dist/vite/vite-node.js +57 -0
- package/dist/vite/vmod.js +1 -1
- package/dist/vite/with-props.js +1 -1
- package/dist/vite.js +1 -1
- package/package.json +11 -7
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-2d5e406e4
|
|
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('pathe');
|
|
16
|
+
var Pathe = require('pathe/utils');
|
|
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 Pathe__default = /*#__PURE__*/_interopDefaultLegacy(Pathe);
|
|
22
|
+
|
|
23
|
+
function noext(path) {
|
|
24
|
+
return Path__default["default"].join(Path__default["default"].dirname(path), Pathe__default["default"].filename(path));
|
|
25
|
+
}
|
|
26
|
+
function get(ctx, fileName) {
|
|
27
|
+
var _ctx$logger;
|
|
28
|
+
const routeId = noext(Path__default["default"].relative(ctx.config.appDirectory, fileName));
|
|
29
|
+
(_ctx$logger = ctx.logger) === null || _ctx$logger === void 0 ? void 0 : _ctx$logger.info(`Route.get filename:${fileName} routeId:${routeId} routes:${JSON.stringify(ctx.routes)}`);
|
|
30
|
+
return ctx.routes[routeId];
|
|
31
|
+
}
|
|
32
|
+
const exports$1 = {
|
|
33
|
+
links: {
|
|
34
|
+
annotateReturnType: true,
|
|
35
|
+
documentation: createDocumentation({
|
|
36
|
+
name: "links",
|
|
37
|
+
link: `https://remix.run/docs/en/main/route/links`
|
|
38
|
+
})
|
|
39
|
+
},
|
|
40
|
+
loader: {
|
|
41
|
+
annotateReturnType: false,
|
|
42
|
+
documentation: createDocumentation({
|
|
43
|
+
name: "serverLoader",
|
|
44
|
+
link: `https://remix.run/docs/en/main/route/loader`
|
|
45
|
+
})
|
|
46
|
+
},
|
|
47
|
+
clientLoader: {
|
|
48
|
+
annotateReturnType: false,
|
|
49
|
+
documentation: createDocumentation({
|
|
50
|
+
name: "clientLoader",
|
|
51
|
+
link: `https://remix.run/docs/en/main/route/client-loader`
|
|
52
|
+
})
|
|
53
|
+
},
|
|
54
|
+
// TODO clientLoader.hydrate?
|
|
55
|
+
HydrateFallback: {
|
|
56
|
+
annotateReturnType: true,
|
|
57
|
+
documentation: createDocumentation({
|
|
58
|
+
name: "HydrateFallback",
|
|
59
|
+
link: `https://remix.run/docs/en/main/route/hydrate-fallback`
|
|
60
|
+
})
|
|
61
|
+
},
|
|
62
|
+
action: {
|
|
63
|
+
annotateReturnType: false,
|
|
64
|
+
documentation: createDocumentation({
|
|
65
|
+
name: "serverAction",
|
|
66
|
+
link: `https://remix.run/docs/en/main/route/action`
|
|
67
|
+
})
|
|
68
|
+
},
|
|
69
|
+
clientAction: {
|
|
70
|
+
annotateReturnType: false,
|
|
71
|
+
documentation: createDocumentation({
|
|
72
|
+
name: "clientAction",
|
|
73
|
+
link: `https://remix.run/docs/en/main/route/client-action`
|
|
74
|
+
})
|
|
75
|
+
},
|
|
76
|
+
default: {
|
|
77
|
+
annotateReturnType: true,
|
|
78
|
+
documentation: createDocumentation({
|
|
79
|
+
name: "default",
|
|
80
|
+
link: `https://remix.run/docs/en/main/route/component`
|
|
81
|
+
})
|
|
82
|
+
},
|
|
83
|
+
ErrorBoundary: {
|
|
84
|
+
annotateReturnType: true,
|
|
85
|
+
documentation: createDocumentation({
|
|
86
|
+
name: "ErrorBoundary",
|
|
87
|
+
link: `https://remix.run/docs/en/main/route/error-boundary`
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
// TODO handle
|
|
91
|
+
// TODO meta
|
|
92
|
+
// TODO shouldRevalidate
|
|
93
|
+
};
|
|
94
|
+
function createDocumentation(args) {
|
|
95
|
+
return [{
|
|
96
|
+
kind: "text",
|
|
97
|
+
text: `React Router \`${args.name}\` export\n\nDocs: ${args.link}`
|
|
98
|
+
}];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
exports.exports = exports$1;
|
|
102
|
+
exports.get = get;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function typecheck(rootDirectory: string): void;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type RouteManifestEntry } from "../config/routes";
|
|
2
|
+
import type { Context } from "./context";
|
|
3
|
+
export declare function getPath(ctx: Context, route: Pick<RouteManifestEntry, "file">): string;
|
|
4
|
+
export declare function watch(ctx: Context): Promise<void>;
|
|
5
|
+
export declare function typegenAll(ctx: Context): Promise<void>;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-2d5e406e4
|
|
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 fs = require('node:fs');
|
|
16
|
+
var Chokidar = require('chokidar');
|
|
17
|
+
var dedent = require('dedent');
|
|
18
|
+
var Path = require('pathe');
|
|
19
|
+
var Pathe = require('pathe/utils');
|
|
20
|
+
var routes = require('../config/routes.js');
|
|
21
|
+
var viteNode = require('../vite/vite-node.js');
|
|
22
|
+
|
|
23
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
24
|
+
|
|
25
|
+
function _interopNamespace(e) {
|
|
26
|
+
if (e && e.__esModule) return e;
|
|
27
|
+
var n = Object.create(null);
|
|
28
|
+
if (e) {
|
|
29
|
+
Object.keys(e).forEach(function (k) {
|
|
30
|
+
if (k !== 'default') {
|
|
31
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
32
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () { return e[k]; }
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
n["default"] = e;
|
|
40
|
+
return Object.freeze(n);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
44
|
+
var Chokidar__default = /*#__PURE__*/_interopDefaultLegacy(Chokidar);
|
|
45
|
+
var dedent__default = /*#__PURE__*/_interopDefaultLegacy(dedent);
|
|
46
|
+
var Path__namespace = /*#__PURE__*/_interopNamespace(Path);
|
|
47
|
+
var Pathe__namespace = /*#__PURE__*/_interopNamespace(Pathe);
|
|
48
|
+
|
|
49
|
+
function getDirectory(ctx) {
|
|
50
|
+
return Path__namespace.join(ctx.config.rootDirectory, ".react-router/types");
|
|
51
|
+
}
|
|
52
|
+
function getPath(ctx, route) {
|
|
53
|
+
return Path__namespace.join(getDirectory(ctx), "app", Path__namespace.dirname(route.file), "+types." + Path__namespace.basename(route.file));
|
|
54
|
+
}
|
|
55
|
+
async function watch(ctx) {
|
|
56
|
+
const appDirectory = Path__namespace.normalize(ctx.config.appDirectory);
|
|
57
|
+
const routesTsPath = Path__namespace.join(appDirectory, "routes.ts");
|
|
58
|
+
const routesViteNodeContext = await viteNode.createContext();
|
|
59
|
+
async function updateRoutes() {
|
|
60
|
+
routesViteNodeContext.devServer.moduleGraph.invalidateAll();
|
|
61
|
+
routesViteNodeContext.runner.moduleCache.clear();
|
|
62
|
+
const result = await routesViteNodeContext.runner.executeFile(routesTsPath);
|
|
63
|
+
ctx.routes = routes.configRoutesToRouteManifest(result.routes);
|
|
64
|
+
}
|
|
65
|
+
await updateRoutes();
|
|
66
|
+
await typegenAll(ctx);
|
|
67
|
+
const watcher = Chokidar__default["default"].watch(appDirectory, {
|
|
68
|
+
ignoreInitial: true
|
|
69
|
+
});
|
|
70
|
+
watcher.on("all", async (event, path) => {
|
|
71
|
+
path = Path__namespace.normalize(path);
|
|
72
|
+
await updateRoutes();
|
|
73
|
+
const routeConfigChanged = Boolean(routesViteNodeContext.devServer.moduleGraph.getModuleById(path));
|
|
74
|
+
if (routeConfigChanged) {
|
|
75
|
+
await typegenAll(ctx);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const isRoute = Object.values(ctx.routes).find(route => path === Path__namespace.join(ctx.config.appDirectory, route.file));
|
|
79
|
+
if (isRoute && (event === "add" || event === "unlink")) {
|
|
80
|
+
await typegenAll(ctx);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
async function typegenAll(ctx) {
|
|
86
|
+
fs__default["default"].rmSync(getDirectory(ctx), {
|
|
87
|
+
recursive: true,
|
|
88
|
+
force: true
|
|
89
|
+
});
|
|
90
|
+
Object.values(ctx.routes).forEach(route => {
|
|
91
|
+
const typesPath = getPath(ctx, route);
|
|
92
|
+
const content = getModule(ctx, route);
|
|
93
|
+
fs__default["default"].mkdirSync(Path__namespace.dirname(typesPath), {
|
|
94
|
+
recursive: true
|
|
95
|
+
});
|
|
96
|
+
fs__default["default"].writeFileSync(typesPath, content);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function getModule(ctx, route) {
|
|
100
|
+
return dedent__default["default"]`
|
|
101
|
+
// typegen: ${route.file}
|
|
102
|
+
import * as T from "react-router/types"
|
|
103
|
+
|
|
104
|
+
export type Params = {${formattedParamsProperties(ctx.routes, route)}}
|
|
105
|
+
|
|
106
|
+
type Route = typeof import("./${Pathe__namespace.filename(route.file)}")
|
|
107
|
+
|
|
108
|
+
export type LoaderData = T.LoaderData<Route>
|
|
109
|
+
export type ActionData = T.ActionData<Route>
|
|
110
|
+
|
|
111
|
+
export type serverLoader = T.ServerLoader<Params>
|
|
112
|
+
export type clientLoader = T.ClientLoader<Params, Route>
|
|
113
|
+
export type serverAction = T.ServerAction<Params>
|
|
114
|
+
export type clientAction = T.ClientAction<Params, Route>
|
|
115
|
+
|
|
116
|
+
export type HydrateFallback = T.HydrateFallback<Params>
|
|
117
|
+
export type Default = T.Default<Params, LoaderData, ActionData>
|
|
118
|
+
export type ErrorBoundary = T.ErrorBoundary<Params, LoaderData, ActionData>
|
|
119
|
+
`;
|
|
120
|
+
}
|
|
121
|
+
function formattedParamsProperties(routes, route) {
|
|
122
|
+
const urlpath = routeLineage(routes, route).map(route => route.path).join("/");
|
|
123
|
+
const params = parseParams(urlpath);
|
|
124
|
+
const indent = " ".repeat(3);
|
|
125
|
+
const properties = Object.entries(params).map(([name, values]) => {
|
|
126
|
+
if (values.length === 1) {
|
|
127
|
+
const isOptional = values[0];
|
|
128
|
+
return indent + (isOptional ? `${name}?: string` : `${name}: string`);
|
|
129
|
+
}
|
|
130
|
+
const items = values.map(isOptional => isOptional ? "string | undefined" : "string");
|
|
131
|
+
return indent + `${name}: [${items.join(", ")}]`;
|
|
132
|
+
});
|
|
133
|
+
// prettier-ignore
|
|
134
|
+
const body = properties.length === 0 ? "" : "\n" + properties.join("\n") + "\n";
|
|
135
|
+
return body;
|
|
136
|
+
}
|
|
137
|
+
function routeLineage(routes, route) {
|
|
138
|
+
const result = [];
|
|
139
|
+
while (route) {
|
|
140
|
+
result.push(route);
|
|
141
|
+
if (!route.parentId) break;
|
|
142
|
+
route = routes[route.parentId];
|
|
143
|
+
}
|
|
144
|
+
result.reverse();
|
|
145
|
+
return result;
|
|
146
|
+
}
|
|
147
|
+
function parseParams(urlpath) {
|
|
148
|
+
const result = {};
|
|
149
|
+
let segments = urlpath.split("/");
|
|
150
|
+
segments.filter(s => s.startsWith(":")).forEach(param => {
|
|
151
|
+
param = param.slice(1); // omit leading `:`
|
|
152
|
+
let isOptional = param.endsWith("?");
|
|
153
|
+
if (isOptional) {
|
|
154
|
+
param = param.slice(0, -1); // omit trailing `?`
|
|
155
|
+
}
|
|
156
|
+
result[param] ??= [];
|
|
157
|
+
result[param].push(isOptional);
|
|
158
|
+
return;
|
|
159
|
+
});
|
|
160
|
+
return result;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
exports.getPath = getPath;
|
|
164
|
+
exports.typegenAll = typegenAll;
|
|
165
|
+
exports.watch = watch;
|
package/dist/vite/babel.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ declare const traverse: {
|
|
|
12
12
|
node: (node: Babel.Node, opts: import("@babel/traverse").TraverseOptions<Babel.Node>, scope?: import("@babel/traverse").Scope | undefined, state?: any, path?: NodePath<Babel.Node> | undefined, skipKeys?: Record<string, boolean> | undefined) => void;
|
|
13
13
|
clearNode: (node: Babel.Node, opts?: Babel.RemovePropertiesOptions | undefined) => void;
|
|
14
14
|
removeProperties: (tree: Babel.Node, opts?: Babel.RemovePropertiesOptions | undefined) => Babel.Node;
|
|
15
|
-
hasType: (tree: Babel.Node, type: "
|
|
15
|
+
hasType: (tree: Babel.Node, type: "ArrayPattern" | "ObjectPattern" | "Identifier" | "RestElement" | "AssignmentPattern" | "TSAsExpression" | "TSSatisfiesExpression" | "TSTypeAssertion" | "TSNonNullExpression" | "MemberExpression" | "TSParameterProperty" | "ObjectProperty" | "ArrayExpression" | "AssignmentExpression" | "BinaryExpression" | "CallExpression" | "ConditionalExpression" | "FunctionExpression" | "StringLiteral" | "NumericLiteral" | "NullLiteral" | "BooleanLiteral" | "RegExpLiteral" | "LogicalExpression" | "NewExpression" | "ObjectExpression" | "SequenceExpression" | "ParenthesizedExpression" | "ThisExpression" | "UnaryExpression" | "UpdateExpression" | "ArrowFunctionExpression" | "ClassExpression" | "ImportExpression" | "MetaProperty" | "Super" | "TaggedTemplateExpression" | "TemplateLiteral" | "YieldExpression" | "AwaitExpression" | "Import" | "BigIntLiteral" | "OptionalMemberExpression" | "OptionalCallExpression" | "TypeCastExpression" | "JSXElement" | "JSXFragment" | "BindExpression" | "DoExpression" | "RecordExpression" | "TupleExpression" | "DecimalLiteral" | "ModuleExpression" | "TopicReference" | "PipelineTopicExpression" | "PipelineBareFunction" | "PipelinePrimaryTopicReference" | "TSInstantiationExpression" | "PrivateName" | "File" | "AnyTypeAnnotation" | "ArgumentPlaceholder" | "ArrayTypeAnnotation" | "BlockStatement" | "BooleanLiteralTypeAnnotation" | "BooleanTypeAnnotation" | "BreakStatement" | "CatchClause" | "ClassAccessorProperty" | "ClassBody" | "ClassDeclaration" | "ClassImplements" | "ClassMethod" | "ClassPrivateMethod" | "ClassPrivateProperty" | "ClassProperty" | "ContinueStatement" | "DebuggerStatement" | "DeclareClass" | "DeclareExportAllDeclaration" | "DeclareExportDeclaration" | "DeclareFunction" | "DeclareInterface" | "DeclareModule" | "DeclareModuleExports" | "DeclareOpaqueType" | "DeclareTypeAlias" | "DeclareVariable" | "DeclaredPredicate" | "Decorator" | "Directive" | "DirectiveLiteral" | "DoWhileStatement" | "EmptyStatement" | "EmptyTypeAnnotation" | "EnumBooleanBody" | "EnumBooleanMember" | "EnumDeclaration" | "EnumDefaultedMember" | "EnumNumberBody" | "EnumNumberMember" | "EnumStringBody" | "EnumStringMember" | "EnumSymbolBody" | "ExistsTypeAnnotation" | "ExportAllDeclaration" | "ExportDefaultDeclaration" | "ExportDefaultSpecifier" | "ExportNamedDeclaration" | "ExportNamespaceSpecifier" | "ExportSpecifier" | "ExpressionStatement" | "ForInStatement" | "ForOfStatement" | "ForStatement" | "FunctionDeclaration" | "FunctionTypeAnnotation" | "FunctionTypeParam" | "GenericTypeAnnotation" | "IfStatement" | "ImportAttribute" | "ImportDeclaration" | "ImportDefaultSpecifier" | "ImportNamespaceSpecifier" | "ImportSpecifier" | "IndexedAccessType" | "InferredPredicate" | "InterfaceDeclaration" | "InterfaceExtends" | "InterfaceTypeAnnotation" | "InterpreterDirective" | "IntersectionTypeAnnotation" | "JSXAttribute" | "JSXClosingElement" | "JSXClosingFragment" | "JSXEmptyExpression" | "JSXExpressionContainer" | "JSXIdentifier" | "JSXMemberExpression" | "JSXNamespacedName" | "JSXOpeningElement" | "JSXOpeningFragment" | "JSXSpreadAttribute" | "JSXSpreadChild" | "JSXText" | "LabeledStatement" | "MixedTypeAnnotation" | "Noop" | "NullLiteralTypeAnnotation" | "NullableTypeAnnotation" | "NumberLiteral" | "NumberLiteralTypeAnnotation" | "NumberTypeAnnotation" | "ObjectMethod" | "ObjectTypeAnnotation" | "ObjectTypeCallProperty" | "ObjectTypeIndexer" | "ObjectTypeInternalSlot" | "ObjectTypeProperty" | "ObjectTypeSpreadProperty" | "OpaqueType" | "OptionalIndexedAccessType" | "Placeholder" | "Program" | "QualifiedTypeIdentifier" | "RegexLiteral" | "RestProperty" | "ReturnStatement" | "SpreadElement" | "SpreadProperty" | "StaticBlock" | "StringLiteralTypeAnnotation" | "StringTypeAnnotation" | "SwitchCase" | "SwitchStatement" | "SymbolTypeAnnotation" | "TSAnyKeyword" | "TSArrayType" | "TSBigIntKeyword" | "TSBooleanKeyword" | "TSCallSignatureDeclaration" | "TSConditionalType" | "TSConstructSignatureDeclaration" | "TSConstructorType" | "TSDeclareFunction" | "TSDeclareMethod" | "TSEnumDeclaration" | "TSEnumMember" | "TSExportAssignment" | "TSExpressionWithTypeArguments" | "TSExternalModuleReference" | "TSFunctionType" | "TSImportEqualsDeclaration" | "TSImportType" | "TSIndexSignature" | "TSIndexedAccessType" | "TSInferType" | "TSInterfaceBody" | "TSInterfaceDeclaration" | "TSIntersectionType" | "TSIntrinsicKeyword" | "TSLiteralType" | "TSMappedType" | "TSMethodSignature" | "TSModuleBlock" | "TSModuleDeclaration" | "TSNamedTupleMember" | "TSNamespaceExportDeclaration" | "TSNeverKeyword" | "TSNullKeyword" | "TSNumberKeyword" | "TSObjectKeyword" | "TSOptionalType" | "TSParenthesizedType" | "TSPropertySignature" | "TSQualifiedName" | "TSRestType" | "TSStringKeyword" | "TSSymbolKeyword" | "TSThisType" | "TSTupleType" | "TSTypeAliasDeclaration" | "TSTypeAnnotation" | "TSTypeLiteral" | "TSTypeOperator" | "TSTypeParameter" | "TSTypeParameterDeclaration" | "TSTypeParameterInstantiation" | "TSTypePredicate" | "TSTypeQuery" | "TSTypeReference" | "TSUndefinedKeyword" | "TSUnionType" | "TSUnknownKeyword" | "TSVoidKeyword" | "TemplateElement" | "ThisTypeAnnotation" | "ThrowStatement" | "TryStatement" | "TupleTypeAnnotation" | "TypeAlias" | "TypeAnnotation" | "TypeParameter" | "TypeParameterDeclaration" | "TypeParameterInstantiation" | "TypeofTypeAnnotation" | "UnionTypeAnnotation" | "V8IntrinsicIdentifier" | "VariableDeclaration" | "VariableDeclarator" | "Variance" | "VoidTypeAnnotation" | "WhileStatement" | "WithStatement", denylistTypes?: string[] | undefined) => boolean;
|
|
16
16
|
cache: typeof import("@babel/traverse").cache;
|
|
17
17
|
};
|
|
18
18
|
declare const generate: typeof import("@babel/generator").default;
|
package/dist/vite/babel.js
CHANGED
package/dist/vite/build.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @react-router/dev v0.0.0-experimental-
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-2d5e406e4
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -32,7 +32,7 @@ function getAddressableRoutes(routes) {
|
|
|
32
32
|
let route = routes[id];
|
|
33
33
|
// We omit the parent route of index routes since the index route takes ownership of its parent's path
|
|
34
34
|
if (route.index) {
|
|
35
|
-
invariant
|
|
35
|
+
invariant(route.parentId, `Expected index route "${route.id}" to have "parentId" set`);
|
|
36
36
|
nonAddressableIds.add(route.parentId);
|
|
37
37
|
}
|
|
38
38
|
// We omit pathless routes since they can only be addressed via descendant routes
|
|
@@ -47,7 +47,7 @@ function getRouteBranch(routes, routeId) {
|
|
|
47
47
|
let currentRouteId = routeId;
|
|
48
48
|
while (currentRouteId) {
|
|
49
49
|
let route = routes[currentRouteId];
|
|
50
|
-
invariant
|
|
50
|
+
invariant(route, `Missing route for ${currentRouteId}`);
|
|
51
51
|
branch.push(route);
|
|
52
52
|
currentRouteId = route.parentId;
|
|
53
53
|
}
|
package/dist/vite/cloudflare.js
CHANGED
package/dist/vite/config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type * as Vite from "vite";
|
|
2
|
-
import type
|
|
2
|
+
import type * as ViteNode from "./vite-node";
|
|
3
3
|
import { type RouteManifest, type RouteManifestEntry } from "../config/routes";
|
|
4
4
|
declare const excludedConfigPresetKeys: readonly ["presets"];
|
|
5
5
|
type ExcludedConfigPresetKey = (typeof excludedConfigPresetKeys)[number];
|
|
@@ -77,7 +77,9 @@ export type ReactRouterConfig = {
|
|
|
77
77
|
* An array of URLs to prerender to HTML files at build time. Can also be a
|
|
78
78
|
* function returning an array to dynamically generate URLs.
|
|
79
79
|
*/
|
|
80
|
-
prerender?: Array<string> | ((
|
|
80
|
+
prerender?: boolean | Array<string> | ((args: {
|
|
81
|
+
getStaticPaths: () => string[];
|
|
82
|
+
}) => Array<string> | Promise<Array<string>>);
|
|
81
83
|
/**
|
|
82
84
|
* An array of React Router plugin config presets to ease integration with
|
|
83
85
|
* other platforms and tools.
|
|
@@ -125,9 +127,10 @@ export type ResolvedReactRouterConfig = Readonly<{
|
|
|
125
127
|
*/
|
|
126
128
|
future: FutureConfig;
|
|
127
129
|
/**
|
|
128
|
-
* An array of URLs to prerender to HTML files at build time.
|
|
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.
|
|
129
132
|
*/
|
|
130
|
-
prerender:
|
|
133
|
+
prerender: ReactRouterConfig["prerender"];
|
|
131
134
|
/**
|
|
132
135
|
* An object of all available routes, keyed by route id.
|
|
133
136
|
*/
|
|
@@ -157,13 +160,13 @@ export type ResolvedReactRouterConfig = Readonly<{
|
|
|
157
160
|
ssr: boolean;
|
|
158
161
|
}>;
|
|
159
162
|
export declare function resolvePublicPath(viteUserConfig: Vite.UserConfig): string;
|
|
160
|
-
export declare function resolveReactRouterConfig({ rootDirectory, reactRouterUserConfig, routeConfigChanged, viteUserConfig, viteCommand,
|
|
163
|
+
export declare function resolveReactRouterConfig({ rootDirectory, reactRouterUserConfig, routeConfigChanged, viteUserConfig, viteCommand, routesViteNodeContext, }: {
|
|
161
164
|
rootDirectory: string;
|
|
162
165
|
reactRouterUserConfig: ReactRouterConfig;
|
|
163
166
|
routeConfigChanged: boolean;
|
|
164
167
|
viteUserConfig: Vite.UserConfig;
|
|
165
168
|
viteCommand: Vite.ConfigEnv["command"];
|
|
166
|
-
|
|
169
|
+
routesViteNodeContext: ViteNode.Context;
|
|
167
170
|
}): Promise<Readonly<{
|
|
168
171
|
/**
|
|
169
172
|
* The absolute path to the application source directory.
|
|
@@ -186,9 +189,12 @@ export declare function resolveReactRouterConfig({ rootDirectory, reactRouterUse
|
|
|
186
189
|
*/
|
|
187
190
|
future: FutureConfig;
|
|
188
191
|
/**
|
|
189
|
-
* An array of URLs to prerender to HTML files at build time.
|
|
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.
|
|
190
194
|
*/
|
|
191
|
-
prerender: string[] |
|
|
195
|
+
prerender: boolean | string[] | ((args: {
|
|
196
|
+
getStaticPaths: () => string[];
|
|
197
|
+
}) => string[] | Promise<string[]>) | undefined;
|
|
192
198
|
/**
|
|
193
199
|
* An object of all available routes, keyed by route id.
|
|
194
200
|
*/
|
package/dist/vite/config.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @react-router/dev v0.0.0-experimental-
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-2d5e406e4
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -84,7 +84,7 @@ async function resolveReactRouterConfig({
|
|
|
84
84
|
routeConfigChanged,
|
|
85
85
|
viteUserConfig,
|
|
86
86
|
viteCommand,
|
|
87
|
-
|
|
87
|
+
routesViteNodeContext
|
|
88
88
|
}) {
|
|
89
89
|
var _viteUserConfig$serve;
|
|
90
90
|
let vite = importViteEsmSync.importViteEsmSync();
|
|
@@ -117,7 +117,7 @@ async function resolveReactRouterConfig({
|
|
|
117
117
|
basename,
|
|
118
118
|
buildDirectory: userBuildDirectory,
|
|
119
119
|
buildEnd,
|
|
120
|
-
prerender
|
|
120
|
+
prerender,
|
|
121
121
|
serverBuildFile,
|
|
122
122
|
serverBundles,
|
|
123
123
|
serverModuleFormat,
|
|
@@ -132,16 +132,10 @@ async function resolveReactRouterConfig({
|
|
|
132
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
133
|
serverBundles = undefined;
|
|
134
134
|
}
|
|
135
|
-
let
|
|
136
|
-
if (
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
} else if (typeof prerenderConfig === "function") {
|
|
140
|
-
prerender = await prerenderConfig();
|
|
141
|
-
} else {
|
|
142
|
-
logger.error(colors__default["default"].red("The `prerender` config must be an array of string paths, or a function " + "returning an array of string paths"));
|
|
143
|
-
process.exit(1);
|
|
144
|
-
}
|
|
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);
|
|
145
139
|
}
|
|
146
140
|
let appDirectory = path__default["default"].resolve(rootDirectory, userAppDirectory || "app");
|
|
147
141
|
let buildDirectory = path__default["default"].resolve(rootDirectory, userBuildDirectory);
|
|
@@ -171,7 +165,7 @@ async function resolveReactRouterConfig({
|
|
|
171
165
|
throw new FriendlyError(`Route config file not found at "${routeConfigDisplayPath}".`);
|
|
172
166
|
}
|
|
173
167
|
routes.setAppDirectory(appDirectory);
|
|
174
|
-
let routeConfigExport = (await
|
|
168
|
+
let routeConfigExport = (await routesViteNodeContext.runner.executeFile(path__default["default"].join(appDirectory, routeConfigFile))).routes;
|
|
175
169
|
let routeConfig = await routeConfigExport;
|
|
176
170
|
let result = routes.validateRouteConfig({
|
|
177
171
|
routeConfigFile,
|
package/dist/vite/dev.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @react-router/dev v0.0.0-experimental-
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-2d5e406e4
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -20,7 +20,7 @@ async function preloadViteEsm() {
|
|
|
20
20
|
vite = await import('vite');
|
|
21
21
|
}
|
|
22
22
|
function importViteEsmSync() {
|
|
23
|
-
invariant
|
|
23
|
+
invariant(vite, "importViteEsmSync() called before preloadViteEsm()");
|
|
24
24
|
return vite;
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @react-router/dev v0.0.0-experimental-
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-2d5e406e4
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -37,7 +37,7 @@ function fromNodeHeaders(nodeHeaders) {
|
|
|
37
37
|
function fromNodeRequest(nodeReq, nodeRes) {
|
|
38
38
|
let origin = nodeReq.headers.origin && "null" !== nodeReq.headers.origin ? nodeReq.headers.origin : `http://${nodeReq.headers.host}`;
|
|
39
39
|
// Use `req.originalUrl` so React Router is aware of the full path
|
|
40
|
-
invariant
|
|
40
|
+
invariant(nodeReq.originalUrl, "Expected `nodeReq.originalUrl` to be defined");
|
|
41
41
|
let url = new URL(nodeReq.originalUrl, origin);
|
|
42
42
|
// Abort action/loaders once we can no longer write a response
|
|
43
43
|
let controller = new AbortController();
|
package/dist/vite/plugin.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare function resolveViteConfig({ configFile, mode, root, }: {
|
|
|
6
6
|
configFile?: string;
|
|
7
7
|
mode?: string;
|
|
8
8
|
root: string;
|
|
9
|
-
}): Promise<Readonly<Omit<Vite.UserConfig, "
|
|
9
|
+
}): Promise<Readonly<Omit<Vite.UserConfig, "optimizeDeps" | "plugins" | "css" | "assetsInclude" | "worker" | "build"> & {
|
|
10
10
|
configFile: string | undefined;
|
|
11
11
|
configFileDependencies: string[];
|
|
12
12
|
inlineConfig: Vite.InlineConfig;
|