@react-router/dev 0.0.0-experimental-7a19e47ea → 0.0.0-experimental-8fdb14ec6

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/config.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-7a19e47ea
2
+ * @react-router/dev v0.0.0-experimental-8fdb14ec6
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -8,21 +8,3 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- "use strict";
12
- var __defProp = Object.defineProperty;
13
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
14
- var __getOwnPropNames = Object.getOwnPropertyNames;
15
- var __hasOwnProp = Object.prototype.hasOwnProperty;
16
- var __copyProps = (to, from, except, desc) => {
17
- if (from && typeof from === "object" || typeof from === "function") {
18
- for (let key of __getOwnPropNames(from))
19
- if (!__hasOwnProp.call(to, key) && key !== except)
20
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
- }
22
- return to;
23
- };
24
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
-
26
- // config.ts
27
- var config_exports = {};
28
- module.exports = __toCommonJS(config_exports);
@@ -0,0 +1,74 @@
1
+ /**
2
+ * @react-router/dev v0.0.0-experimental-8fdb14ec6
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
+ import {
12
+ getSession,
13
+ start,
14
+ stop
15
+ } from "./chunk-NPNB22L5.js";
16
+ import {
17
+ getVite,
18
+ preloadVite
19
+ } from "./chunk-6ZGYCLOA.js";
20
+ import "./chunk-6CEKSKVN.js";
21
+
22
+ // vite/dev.ts
23
+ import colors from "picocolors";
24
+ async function dev(root, {
25
+ clearScreen,
26
+ config: configFile,
27
+ cors,
28
+ force,
29
+ host,
30
+ logLevel,
31
+ mode,
32
+ open,
33
+ port,
34
+ strictPort
35
+ }) {
36
+ await preloadVite();
37
+ let vite = getVite();
38
+ let server = await vite.createServer({
39
+ root,
40
+ mode,
41
+ configFile,
42
+ server: { open, cors, host, port, strictPort },
43
+ optimizeDeps: { force },
44
+ clearScreen,
45
+ logLevel
46
+ });
47
+ if (!server.config.plugins.find((plugin) => plugin.name === "react-router")) {
48
+ console.error(
49
+ colors.red("React Router Vite plugin not found in Vite config")
50
+ );
51
+ process.exit(1);
52
+ }
53
+ await server.listen();
54
+ server.printUrls();
55
+ let customShortcuts = [
56
+ {
57
+ key: "p",
58
+ description: "start/stop the profiler",
59
+ async action(server2) {
60
+ if (getSession()) {
61
+ await stop(server2.config.logger.info);
62
+ } else {
63
+ await start(() => {
64
+ server2.config.logger.info("Profiler started");
65
+ });
66
+ }
67
+ }
68
+ }
69
+ ];
70
+ server.bindCLIShortcuts({ print: true, customShortcuts });
71
+ }
72
+ export {
73
+ dev
74
+ };
package/dist/routes.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-7a19e47ea
2
+ * @react-router/dev v0.0.0-experimental-8fdb14ec6
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -8,187 +8,20 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- "use strict";
12
- var __create = Object.create;
13
- var __defProp = Object.defineProperty;
14
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
15
- var __getOwnPropNames = Object.getOwnPropertyNames;
16
- var __getProtoOf = Object.getPrototypeOf;
17
- var __hasOwnProp = Object.prototype.hasOwnProperty;
18
- var __export = (target, all) => {
19
- for (var name in all)
20
- __defProp(target, name, { get: all[name], enumerable: true });
21
- };
22
- var __copyProps = (to, from, except, desc) => {
23
- if (from && typeof from === "object" || typeof from === "function") {
24
- for (let key of __getOwnPropNames(from))
25
- if (!__hasOwnProp.call(to, key) && key !== except)
26
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
27
- }
28
- return to;
29
- };
30
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
31
- // If the importer is in node compatibility mode or this is not an ESM
32
- // file that has been converted to a CommonJS file using a Babel-
33
- // compatible transform (i.e. "__esModule" has not been set), then set
34
- // "default" to the CommonJS "module.exports" for node compatibility.
35
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
36
- mod
37
- ));
38
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
39
-
40
- // routes.ts
41
- var routes_exports = {};
42
- __export(routes_exports, {
43
- getAppDirectory: () => getAppDirectory,
44
- index: () => index,
45
- layout: () => layout,
46
- prefix: () => prefix,
47
- relative: () => relative2,
48
- route: () => route
49
- });
50
- module.exports = __toCommonJS(routes_exports);
51
-
52
- // config/routes.ts
53
- var Path = __toESM(require("pathe"));
54
- var v = __toESM(require("valibot"));
55
- var import_pick = __toESM(require("lodash/pick"));
56
-
57
- // invariant.ts
58
- function invariant(value, message) {
59
- if (value === false || value === null || typeof value === "undefined") {
60
- console.error(
61
- "The following error is a bug in React Router; please open an issue! https://github.com/remix-run/react-router/issues/new/choose"
62
- );
63
- throw new Error(message);
64
- }
65
- }
66
-
67
- // config/routes.ts
68
- function getAppDirectory() {
69
- invariant(globalThis.__reactRouterAppDirectory);
70
- return globalThis.__reactRouterAppDirectory;
71
- }
72
- var routeConfigEntrySchema = v.pipe(
73
- v.custom((value) => {
74
- return !(typeof value === "object" && value !== null && "then" in value && "catch" in value);
75
- }, "Invalid type: Expected object but received a promise. Did you forget to await?"),
76
- v.object({
77
- id: v.optional(v.string()),
78
- path: v.optional(v.string()),
79
- index: v.optional(v.boolean()),
80
- caseSensitive: v.optional(v.boolean()),
81
- file: v.string(),
82
- children: v.optional(v.array(v.lazy(() => routeConfigEntrySchema)))
83
- })
84
- );
85
- var resolvedRouteConfigSchema = v.array(routeConfigEntrySchema);
86
- var createConfigRouteOptionKeys = [
87
- "id",
88
- "index",
89
- "caseSensitive"
90
- ];
91
- function route(path, file, optionsOrChildren, children) {
92
- let options = {};
93
- if (Array.isArray(optionsOrChildren) || !optionsOrChildren) {
94
- children = optionsOrChildren;
95
- } else {
96
- options = optionsOrChildren;
97
- }
98
- return {
99
- file,
100
- children,
101
- path: path ?? void 0,
102
- ...(0, import_pick.default)(options, createConfigRouteOptionKeys)
103
- };
104
- }
105
- var createIndexOptionKeys = ["id"];
106
- function index(file, options) {
107
- return {
108
- file,
109
- index: true,
110
- ...(0, import_pick.default)(options, createIndexOptionKeys)
111
- };
112
- }
113
- var createLayoutOptionKeys = ["id"];
114
- function layout(file, optionsOrChildren, children) {
115
- let options = {};
116
- if (Array.isArray(optionsOrChildren) || !optionsOrChildren) {
117
- children = optionsOrChildren;
118
- } else {
119
- options = optionsOrChildren;
120
- }
121
- return {
122
- file,
123
- children,
124
- ...(0, import_pick.default)(options, createLayoutOptionKeys)
125
- };
126
- }
127
- function prefix(prefixPath, routes) {
128
- return routes.map((route2) => {
129
- if (route2.index || typeof route2.path === "string") {
130
- return {
131
- ...route2,
132
- path: route2.path ? joinRoutePaths(prefixPath, route2.path) : prefixPath,
133
- children: route2.children
134
- };
135
- } else if (route2.children) {
136
- return {
137
- ...route2,
138
- children: prefix(prefixPath, route2.children)
139
- };
140
- }
141
- return route2;
142
- });
143
- }
144
- function relative2(directory) {
145
- return {
146
- /**
147
- * Helper function for creating a route config entry, for use within
148
- * `routes.ts`. Note that this helper has been scoped, meaning that file
149
- * path will be resolved relative to the directory provided to the
150
- * `relative` call that created this helper.
151
- */
152
- route: (path, file, ...rest) => {
153
- return route(path, Path.resolve(directory, file), ...rest);
154
- },
155
- /**
156
- * Helper function for creating a route config entry for an index route, for
157
- * use within `routes.ts`. Note that this helper has been scoped, meaning
158
- * that file path will be resolved relative to the directory provided to the
159
- * `relative` call that created this helper.
160
- */
161
- index: (file, ...rest) => {
162
- return index(Path.resolve(directory, file), ...rest);
163
- },
164
- /**
165
- * Helper function for creating a route config entry for a layout route, for
166
- * use within `routes.ts`. Note that this helper has been scoped, meaning
167
- * that file path will be resolved relative to the directory provided to the
168
- * `relative` call that created this helper.
169
- */
170
- layout: (file, ...rest) => {
171
- return layout(Path.resolve(directory, file), ...rest);
172
- },
173
- // Passthrough of helper functions that don't need relative scoping so that
174
- // a complete API is still provided.
175
- prefix
176
- };
177
- }
178
- function joinRoutePaths(path1, path2) {
179
- return [
180
- path1.replace(/\/+$/, ""),
181
- // Remove trailing slashes
182
- path2.replace(/^\/+/, "")
183
- // Remove leading slashes
184
- ].join("/");
185
- }
186
- // Annotate the CommonJS export names for ESM import in node:
187
- 0 && (module.exports = {
11
+ import {
188
12
  getAppDirectory,
189
13
  index,
190
14
  layout,
191
15
  prefix,
192
16
  relative,
193
17
  route
194
- });
18
+ } from "./chunk-76RVI3VW.js";
19
+ import "./chunk-6CEKSKVN.js";
20
+ export {
21
+ getAppDirectory,
22
+ index,
23
+ layout,
24
+ prefix,
25
+ relative,
26
+ route
27
+ };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-7a19e47ea
2
+ * @react-router/dev v0.0.0-experimental-8fdb14ec6
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -8,121 +8,18 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- "use strict";
12
- var __create = Object.create;
13
- var __defProp = Object.defineProperty;
14
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
15
- var __getOwnPropNames = Object.getOwnPropertyNames;
16
- var __getProtoOf = Object.getPrototypeOf;
17
- var __hasOwnProp = Object.prototype.hasOwnProperty;
18
- var __export = (target, all) => {
19
- for (var name in all)
20
- __defProp(target, name, { get: all[name], enumerable: true });
21
- };
22
- var __copyProps = (to, from, except, desc) => {
23
- if (from && typeof from === "object" || typeof from === "function") {
24
- for (let key of __getOwnPropNames(from))
25
- if (!__hasOwnProp.call(to, key) && key !== except)
26
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
27
- }
28
- return to;
29
- };
30
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
31
- // If the importer is in node compatibility mode or this is not an ESM
32
- // file that has been converted to a CommonJS file using a Babel-
33
- // compatible transform (i.e. "__esModule" has not been set), then set
34
- // "default" to the CommonJS "module.exports" for node compatibility.
35
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
36
- mod
37
- ));
38
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
39
-
40
- // vite/cloudflare.ts
41
- var cloudflare_exports = {};
42
- __export(cloudflare_exports, {
43
- cloudflareDevProxy: () => cloudflareDevProxyVitePlugin
44
- });
45
- module.exports = __toCommonJS(cloudflare_exports);
46
-
47
- // vite/cloudflare-dev-proxy.ts
48
- var import_react_router = require("react-router");
49
-
50
- // vite/node-adapter.ts
51
- var import_node_events = require("events");
52
- var import_node_stream = require("stream");
53
- var import_set_cookie_parser = require("set-cookie-parser");
54
- var import_node = require("@react-router/node");
55
-
56
- // invariant.ts
57
- function invariant(value, message) {
58
- if (value === false || value === null || typeof value === "undefined") {
59
- console.error(
60
- "The following error is a bug in React Router; please open an issue! https://github.com/remix-run/react-router/issues/new/choose"
61
- );
62
- throw new Error(message);
63
- }
64
- }
65
-
66
- // vite/node-adapter.ts
67
- function fromNodeHeaders(nodeHeaders) {
68
- let headers = new Headers();
69
- for (let [key, values] of Object.entries(nodeHeaders)) {
70
- if (values) {
71
- if (Array.isArray(values)) {
72
- for (let value of values) {
73
- headers.append(key, value);
74
- }
75
- } else {
76
- headers.set(key, values);
77
- }
78
- }
79
- }
80
- return headers;
81
- }
82
- function fromNodeRequest(nodeReq, nodeRes) {
83
- let origin = nodeReq.headers.origin && "null" !== nodeReq.headers.origin ? nodeReq.headers.origin : `http://${nodeReq.headers.host}`;
84
- invariant(
85
- nodeReq.originalUrl,
86
- "Expected `nodeReq.originalUrl` to be defined"
87
- );
88
- let url = new URL(nodeReq.originalUrl, origin);
89
- let controller = new AbortController();
90
- let init = {
91
- method: nodeReq.method,
92
- headers: fromNodeHeaders(nodeReq.headers),
93
- signal: controller.signal
94
- };
95
- nodeRes.on("finish", () => controller = null);
96
- nodeRes.on("close", () => controller?.abort());
97
- if (nodeReq.method !== "GET" && nodeReq.method !== "HEAD") {
98
- init.body = (0, import_node.createReadableStreamFromReadable)(nodeReq);
99
- init.duplex = "half";
100
- }
101
- return new Request(url.href, init);
102
- }
103
- async function toNodeRequest(res, nodeRes) {
104
- nodeRes.statusCode = res.status;
105
- nodeRes.statusMessage = res.statusText;
106
- let cookiesStrings = [];
107
- for (let [name, value] of res.headers) {
108
- if (name === "set-cookie") {
109
- cookiesStrings.push(...(0, import_set_cookie_parser.splitCookiesString)(value));
110
- } else nodeRes.setHeader(name, value);
111
- }
112
- if (cookiesStrings.length) {
113
- nodeRes.setHeader("set-cookie", cookiesStrings);
114
- }
115
- if (res.body) {
116
- let responseBody = res.body;
117
- let readable = import_node_stream.Readable.from(responseBody);
118
- readable.pipe(nodeRes);
119
- await (0, import_node_events.once)(readable, "end");
120
- } else {
121
- nodeRes.end();
122
- }
123
- }
11
+ import {
12
+ fromNodeRequest,
13
+ toNodeRequest
14
+ } from "../chunk-ACXLX4EI.js";
15
+ import {
16
+ getVite,
17
+ preloadVite
18
+ } from "../chunk-6ZGYCLOA.js";
19
+ import "../chunk-6CEKSKVN.js";
124
20
 
125
21
  // vite/cloudflare-dev-proxy.ts
22
+ import { createRequestHandler } from "react-router";
126
23
  var serverBuildId = "virtual:react-router/server-build";
127
24
  function importWrangler() {
128
25
  try {
@@ -136,13 +33,20 @@ var cloudflareDevProxyVitePlugin = (options = {}) => {
136
33
  let { getLoadContext, ...restOptions } = options;
137
34
  return {
138
35
  name: PLUGIN_NAME,
139
- config: () => ({
140
- ssr: {
141
- resolve: {
142
- externalConditions: ["workerd", "worker"]
36
+ config: async () => {
37
+ await preloadVite();
38
+ const vite = getVite();
39
+ const serverConditions = [
40
+ ...vite.defaultServerConditions ?? []
41
+ ];
42
+ return {
43
+ ssr: {
44
+ resolve: {
45
+ externalConditions: ["workerd", "worker", ...serverConditions]
46
+ }
143
47
  }
144
- }
145
- }),
48
+ };
49
+ },
146
50
  configResolved: (viteConfig) => {
147
51
  let pluginIndex = (name) => viteConfig.plugins.findIndex((plugin) => plugin.name === name);
148
52
  let reactRouterPluginIndex = pluginIndex("react-router");
@@ -165,7 +69,7 @@ var cloudflareDevProxyVitePlugin = (options = {}) => {
165
69
  let build = await viteDevServer.ssrLoadModule(
166
70
  serverBuildId
167
71
  );
168
- let handler = (0, import_react_router.createRequestHandler)(build, "development");
72
+ let handler = createRequestHandler(build, "development");
169
73
  let req = fromNodeRequest(nodeReq, nodeRes);
170
74
  let loadContext = getLoadContext ? await getLoadContext({ request: req, context }) : context;
171
75
  let res = await handler(req, loadContext);
@@ -179,7 +83,6 @@ var cloudflareDevProxyVitePlugin = (options = {}) => {
179
83
  }
180
84
  };
181
85
  };
182
- // Annotate the CommonJS export names for ESM import in node:
183
- 0 && (module.exports = {
184
- cloudflareDevProxy
185
- });
86
+ export {
87
+ cloudflareDevProxyVitePlugin as cloudflareDevProxy
88
+ };