@react-router/dev 0.0.0-experimental-a26b992a1 → 0.0.0-experimental-312bddb22

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-a26b992a1
2
+ * @react-router/dev v0.0.0-experimental-312bddb22
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-a26b992a1
2
+ * @react-router/dev v0.0.0-experimental-312bddb22
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
package/dist/cli/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-a26b992a1
2
+ * @react-router/dev v0.0.0-experimental-312bddb22
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
package/dist/cli/run.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-a26b992a1
2
+ * @react-router/dev v0.0.0-experimental-312bddb22
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-a26b992a1
2
+ * @react-router/dev v0.0.0-experimental-312bddb22
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
package/dist/colors.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-a26b992a1
2
+ * @react-router/dev v0.0.0-experimental-312bddb22
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-a26b992a1
2
+ * @react-router/dev v0.0.0-experimental-312bddb22
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-a26b992a1
2
+ * @react-router/dev v0.0.0-experimental-312bddb22
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
package/dist/invariant.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-a26b992a1
2
+ * @react-router/dev v0.0.0-experimental-312bddb22
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
package/dist/routes.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-a26b992a1
2
+ * @react-router/dev v0.0.0-experimental-312bddb22
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -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: "File" | "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" | "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;
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;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-a26b992a1
2
+ * @react-router/dev v0.0.0-experimental-312bddb22
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-a26b992a1
2
+ * @react-router/dev v0.0.0-experimental-312bddb22
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-a26b992a1
2
+ * @react-router/dev v0.0.0-experimental-312bddb22
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -69,7 +69,7 @@ const cloudflareDevProxyVitePlugin = (options = {}) => {
69
69
  try {
70
70
  let build = await viteDevServer.ssrLoadModule(serverBuildId);
71
71
  let handler = reactRouter.createRequestHandler(build, "development");
72
- let req = nodeAdapter.fromNodeRequest(nodeReq);
72
+ let req = nodeAdapter.fromNodeRequest(nodeReq, nodeRes);
73
73
  let loadContext = getLoadContext ? await getLoadContext({
74
74
  request: req,
75
75
  context
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-a26b992a1
2
+ * @react-router/dev v0.0.0-experimental-312bddb22
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-a26b992a1
2
+ * @react-router/dev v0.0.0-experimental-312bddb22
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -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> | (() => Array<string> | Promise<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: Array<string> | null;
133
+ prerender: ReactRouterConfig["prerender"];
131
134
  /**
132
135
  * An object of all available routes, keyed by route id.
133
136
  */
@@ -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[] | null;
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
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-a26b992a1
2
+ * @react-router/dev v0.0.0-experimental-312bddb22
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -117,7 +117,7 @@ async function resolveReactRouterConfig({
117
117
  basename,
118
118
  buildDirectory: userBuildDirectory,
119
119
  buildEnd,
120
- prerender: prerenderConfig,
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 prerender = null;
136
- if (prerenderConfig) {
137
- if (Array.isArray(prerenderConfig)) {
138
- prerender = prerenderConfig;
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);
package/dist/vite/dev.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-a26b992a1
2
+ * @react-router/dev v0.0.0-experimental-312bddb22
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-a26b992a1
2
+ * @react-router/dev v0.0.0-experimental-312bddb22
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -2,5 +2,5 @@
2
2
  import type { ServerResponse } from "node:http";
3
3
  import type * as Vite from "vite";
4
4
  export type NodeRequestHandler = (req: Vite.Connect.IncomingMessage, res: ServerResponse) => Promise<void>;
5
- export declare function fromNodeRequest(nodeReq: Vite.Connect.IncomingMessage): Request;
5
+ export declare function fromNodeRequest(nodeReq: Vite.Connect.IncomingMessage, nodeRes: ServerResponse<Vite.Connect.IncomingMessage>): Request;
6
6
  export declare function toNodeRequest(res: Response, nodeRes: ServerResponse): Promise<void>;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-a26b992a1
2
+ * @react-router/dev v0.0.0-experimental-312bddb22
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -34,14 +34,18 @@ function fromNodeHeaders(nodeHeaders) {
34
34
  return headers;
35
35
  }
36
36
  // Based on `createRemixRequest` in packages/react-router-express/server.ts
37
- function fromNodeRequest(nodeReq) {
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
40
  invariant["default"](nodeReq.originalUrl, "Expected `nodeReq.originalUrl` to be defined");
41
41
  let url = new URL(nodeReq.originalUrl, origin);
42
+ // Abort action/loaders once we can no longer write a response
43
+ let controller = new AbortController();
44
+ nodeRes.on("close", () => controller.abort());
42
45
  let init = {
43
46
  method: nodeReq.method,
44
- headers: fromNodeHeaders(nodeReq.headers)
47
+ headers: fromNodeHeaders(nodeReq.headers),
48
+ signal: controller.signal
45
49
  };
46
50
  if (nodeReq.method !== "GET" && nodeReq.method !== "HEAD") {
47
51
  init.body = node.createReadableStreamFromReadable(nodeReq);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-a26b992a1
2
+ * @react-router/dev v0.0.0-experimental-312bddb22
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -754,7 +754,7 @@ const reactRouterVitePlugin = _config => {
754
754
  let build = await viteDevServer.ssrLoadModule(serverBuildId);
755
755
  let handler = reactRouter.createRequestHandler(build, "development");
756
756
  let nodeHandler = async (nodeReq, nodeRes) => {
757
- let req = nodeAdapter.fromNodeRequest(nodeReq);
757
+ let req = nodeAdapter.fromNodeRequest(nodeReq, nodeRes);
758
758
  let res = await handler(req, await reactRouterDevLoadContext(req));
759
759
  await nodeAdapter.toNodeRequest(res, nodeRes);
760
760
  };
@@ -802,7 +802,7 @@ const reactRouterVitePlugin = _config => {
802
802
  if (movedAssetPaths.length) {
803
803
  viteConfig.logger.info(["", `${colors__default["default"].green("✓")} ${movedAssetPaths.length} asset${movedAssetPaths.length > 1 ? "s" : ""} moved from React Router server build to client assets.`, ...movedAssetPaths.map(movedAssetPath => colors__default["default"].dim(path__namespace.relative(ctx.rootDirectory, movedAssetPath))), ""].join("\n"));
804
804
  }
805
- if (ctx.reactRouterConfig.prerender != null) {
805
+ if (ctx.reactRouterConfig.prerender != null && ctx.reactRouterConfig.prerender !== false) {
806
806
  // If we have prerender routes, that takes precedence over SPA mode
807
807
  // which is ssr:false and only the rot route being rendered
808
808
  await handlePrerender(viteConfig, ctx.reactRouterConfig, serverBuildDirectory, clientBuildDirectory);
@@ -1168,7 +1168,17 @@ async function handlePrerender(viteConfig, reactRouterConfig, serverBuildDirecto
1168
1168
  handler
1169
1169
  } = await getPrerenderBuildAndHandler(viteConfig, reactRouterConfig, serverBuildDirectory);
1170
1170
  let routes = createPrerenderRoutes(build.routes);
1171
- let routesToPrerender = reactRouterConfig.prerender || ["/"];
1171
+ let routesToPrerender;
1172
+ if (typeof reactRouterConfig.prerender === "boolean") {
1173
+ invariant["default"](reactRouterConfig.prerender, "Expected prerender:true");
1174
+ routesToPrerender = determineStaticPrerenderRoutes(routes, viteConfig, true);
1175
+ } else if (typeof reactRouterConfig.prerender === "function") {
1176
+ routesToPrerender = await reactRouterConfig.prerender({
1177
+ getStaticPaths: () => determineStaticPrerenderRoutes(routes, viteConfig, false)
1178
+ });
1179
+ } else {
1180
+ routesToPrerender = reactRouterConfig.prerender || ["/"];
1181
+ }
1172
1182
  let requestInit = {
1173
1183
  headers: {
1174
1184
  // Header that can be used in the loader to know if you're running at
@@ -1184,19 +1194,48 @@ async function handlePrerender(viteConfig, reactRouterConfig, serverBuildDirecto
1184
1194
  }
1185
1195
  await prerenderRoute(handler, path, clientBuildDirectory, reactRouterConfig, viteConfig, requestInit);
1186
1196
  }
1187
- async function prerenderData(handler, prerenderPath, clientBuildDirectory, reactRouterConfig, viteConfig, requestInit) {
1188
- let normalizedPath = `${reactRouterConfig.basename}${prerenderPath === "/" ? "/_root.data" : `${prerenderPath.replace(/\/$/, "")}.data`}`.replace(/\/\/+/g, "/");
1189
- let request = new Request(`http://localhost${normalizedPath}`, requestInit);
1190
- let response = await handler(request);
1191
- let data = await response.text();
1192
- validatePrerenderedResponse(response, data, "Prerender", normalizedPath);
1193
- // Write out the .data file
1194
- let outdir = path__namespace.relative(process.cwd(), clientBuildDirectory);
1195
- let outfile = path__namespace.join(outdir, normalizedPath.split("/").join(path__namespace.sep));
1196
- await fse__namespace.ensureDir(path__namespace.dirname(outfile));
1197
- await fse__namespace.outputFile(outfile, data);
1198
- viteConfig.logger.info(`Prerender: Generated ${colors__default["default"].bold(outfile)}`);
1197
+ await prerenderManifest(build, clientBuildDirectory, reactRouterConfig, viteConfig);
1198
+ }
1199
+ function determineStaticPrerenderRoutes(routes, viteConfig, isBooleanUsage = false) {
1200
+ // Always start with the root/index route included
1201
+ let paths = ["/"];
1202
+ let paramRoutes = [];
1203
+ // Then recursively add any new path defined by the tree
1204
+ function recurse(subtree, prefix = "") {
1205
+ for (let route of subtree) {
1206
+ let newPath = [prefix, route.path].join("/").replace(/\/\/+/g, "/");
1207
+ if (route.path) {
1208
+ let segments = route.path.split("/");
1209
+ if (segments.some(s => s.startsWith(":") || s === "*")) {
1210
+ paramRoutes.push(route.path);
1211
+ } else {
1212
+ paths.push(newPath);
1213
+ }
1214
+ }
1215
+ if (route.children) {
1216
+ recurse(route.children, newPath);
1217
+ }
1218
+ }
1199
1219
  }
1220
+ recurse(routes);
1221
+ if (isBooleanUsage && paramRoutes) {
1222
+ viteConfig.logger.warn("The following paths were not prerendered because Dynamic Param and Splat " + "routes cannot be prerendered when using `prerender:true`. You may want to " + "consider using the `prerender()` API if you wish to prerender slug and " + "splat routes.");
1223
+ }
1224
+ // Clean double slashes and remove trailing slashes
1225
+ return paths.map(p => p.replace(/\/\/+/g, "/").replace(/(.+)\/$/, "$1"));
1226
+ }
1227
+ async function prerenderData(handler, prerenderPath, clientBuildDirectory, reactRouterConfig, viteConfig, requestInit) {
1228
+ let normalizedPath = `${reactRouterConfig.basename}${prerenderPath === "/" ? "/_root.data" : `${prerenderPath.replace(/\/$/, "")}.data`}`.replace(/\/\/+/g, "/");
1229
+ let request = new Request(`http://localhost${normalizedPath}`, requestInit);
1230
+ let response = await handler(request);
1231
+ let data = await response.text();
1232
+ validatePrerenderedResponse(response, data, "Prerender", normalizedPath);
1233
+ // Write out the .data file
1234
+ let outdir = path__namespace.relative(process.cwd(), clientBuildDirectory);
1235
+ let outfile = path__namespace.join(outdir, ...normalizedPath.split("/"));
1236
+ await fse__namespace.ensureDir(path__namespace.dirname(outfile));
1237
+ await fse__namespace.outputFile(outfile, data);
1238
+ viteConfig.logger.info(`Prerender: Generated ${colors__default["default"].bold(outfile)}`);
1200
1239
  }
1201
1240
  async function prerenderRoute(handler, prerenderPath, clientBuildDirectory, reactRouterConfig, viteConfig, requestInit) {
1202
1241
  let normalizedPath = `${reactRouterConfig.basename}${prerenderPath}/`.replace(/\/\/+/g, "/");
@@ -1214,6 +1253,15 @@ async function prerenderRoute(handler, prerenderPath, clientBuildDirectory, reac
1214
1253
  await fse__namespace.outputFile(outfile, html);
1215
1254
  viteConfig.logger.info(`Prerender: Generated ${colors__default["default"].bold(outfile)}`);
1216
1255
  }
1256
+ async function prerenderManifest(build, clientBuildDirectory, reactRouterConfig, viteConfig) {
1257
+ let normalizedPath = `${reactRouterConfig.basename}/__manifest`.replace(/\/\/+/g, "/");
1258
+ let outdir = path__namespace.relative(process.cwd(), clientBuildDirectory);
1259
+ let outfile = path__namespace.join(outdir, ...normalizedPath.split("/"));
1260
+ await fse__namespace.ensureDir(path__namespace.dirname(outfile));
1261
+ let manifestData = JSON.stringify(build.assets.routes);
1262
+ await fse__namespace.outputFile(outfile, manifestData);
1263
+ viteConfig.logger.info(`Prerender: Generated ${colors__default["default"].bold(outfile)}`);
1264
+ }
1217
1265
  function validatePrerenderedResponse(response, html, prefix, path) {
1218
1266
  if (response.status !== 200) {
1219
1267
  throw new Error(`${prefix}: Received a ${response.status} status code from ` + `\`entry.server.tsx\` while prerendering the \`${path}\` ` + `path.\n${html}`);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-a26b992a1
2
+ * @react-router/dev v0.0.0-experimental-312bddb22
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-a26b992a1
2
+ * @react-router/dev v0.0.0-experimental-312bddb22
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-a26b992a1
2
+ * @react-router/dev v0.0.0-experimental-312bddb22
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-a26b992a1
2
+ * @react-router/dev v0.0.0-experimental-312bddb22
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
package/dist/vite/vmod.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-a26b992a1
2
+ * @react-router/dev v0.0.0-experimental-312bddb22
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-a26b992a1
2
+ * @react-router/dev v0.0.0-experimental-312bddb22
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
package/dist/vite.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-a26b992a1
2
+ * @react-router/dev v0.0.0-experimental-312bddb22
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-router/dev",
3
- "version": "0.0.0-experimental-a26b992a1",
3
+ "version": "0.0.0-experimental-312bddb22",
4
4
  "description": "Dev tools and CLI for React Router",
5
5
  "homepage": "https://reactrouter.com",
6
6
  "bugs": {
@@ -58,7 +58,7 @@
58
58
  "set-cookie-parser": "^2.6.0",
59
59
  "vite-node": "^1.6.0",
60
60
  "valibot": "^0.41.0",
61
- "@react-router/node": "0.0.0-experimental-a26b992a1"
61
+ "@react-router/node": "0.0.0-experimental-312bddb22"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@types/babel__core": "^7.20.5",
@@ -84,15 +84,15 @@
84
84
  "tiny-invariant": "^1.2.0",
85
85
  "vite": "^5.1.0",
86
86
  "wrangler": "^3.28.2",
87
- "react-router": "^0.0.0-experimental-a26b992a1",
88
- "@react-router/serve": "0.0.0-experimental-a26b992a1"
87
+ "@react-router/serve": "0.0.0-experimental-312bddb22",
88
+ "react-router": "^0.0.0-experimental-312bddb22"
89
89
  },
90
90
  "peerDependencies": {
91
91
  "typescript": "^5.1.0",
92
92
  "vite": "^5.1.0",
93
93
  "wrangler": "^3.28.2",
94
- "@react-router/serve": "^0.0.0-experimental-a26b992a1",
95
- "react-router": "^0.0.0-experimental-a26b992a1"
94
+ "@react-router/serve": "^0.0.0-experimental-312bddb22",
95
+ "react-router": "^0.0.0-experimental-312bddb22"
96
96
  },
97
97
  "peerDependenciesMeta": {
98
98
  "@react-router/serve": {