@react-router/dev 0.0.0-experimental-49eef6a01 → 0.0.0-experimental-a26b992a1
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/bin.js +1 -1
- package/dist/cli/commands.js +1 -1
- package/dist/cli/detectPackageManager.js +1 -1
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +7 -6
- package/dist/cli/run.js +1 -1
- package/dist/cli/useJavascript.js +1 -1
- package/dist/colors.js +1 -1
- package/dist/config/defaults/entry.client.tsx +1 -1
- package/dist/config/format.js +1 -1
- package/dist/config/routes.d.ts +77 -50
- package/dist/config/routes.js +175 -43
- package/dist/invariant.js +1 -1
- package/dist/routes.d.ts +2 -0
- package/dist/routes.js +23 -0
- package/dist/vite/babel.d.ts +10 -10
- package/dist/vite/babel.js +1 -1
- package/dist/vite/build.js +2 -2
- package/dist/vite/cloudflare-dev-proxy.d.ts +7 -1
- package/dist/vite/cloudflare-dev-proxy.js +23 -7
- package/dist/vite/cloudflare.d.ts +1 -0
- package/dist/vite/cloudflare.js +19 -0
- package/dist/vite/combine-urls.d.ts +1 -0
- package/dist/vite/combine-urls.js +20 -0
- package/dist/{config.d.ts → vite/config.d.ts} +15 -27
- package/dist/{config.js → vite/config.js} +62 -45
- package/dist/vite/dev.js +1 -1
- package/dist/vite/import-vite-esm-sync.js +1 -1
- package/dist/vite/node-adapter.js +1 -1
- package/dist/vite/plugin.d.ts +6 -3
- package/dist/vite/plugin.js +145 -121
- package/dist/vite/profiler.js +1 -1
- package/dist/vite/remove-exports.d.ts +2 -2
- package/dist/vite/remove-exports.js +113 -243
- package/dist/vite/resolve-file-url.js +1 -1
- package/dist/vite/static/refresh-utils.cjs +7 -26
- package/dist/vite/styles.d.ts +3 -2
- package/dist/vite/styles.js +23 -2
- package/dist/vite/vmod.js +1 -1
- package/dist/vite/with-props.d.ts +4 -0
- package/dist/vite/with-props.js +151 -0
- package/dist/vite.d.ts +2 -0
- package/dist/{cli.js → vite.js} +7 -8
- package/package.json +21 -12
- package/dist/config/findConfig.d.ts +0 -1
- package/dist/config/findConfig.js +0 -32
- package/dist/config/flatRoutes.d.ts +0 -14
- package/dist/config/flatRoutes.js +0 -418
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -23
- package/dist/vite/define-route.d.ts +0 -5
- package/dist/vite/define-route.js +0 -207
- package/dist/vite/index.d.ts +0 -3
- package/dist/vite/index.js +0 -31
- /package/dist/{cli.d.ts → vite/combine-urls-test.d.ts} +0 -0
package/dist/vite.d.ts
ADDED
package/dist/{cli.js → vite.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @react-router/dev v0.0.0-experimental-
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-a26b992a1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -10,11 +10,10 @@
|
|
|
10
10
|
*/
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
});
|
|
15
|
+
var plugin = require('./vite/plugin.js');
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
exports.reactRouter = plugin.reactRouterVitePlugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-router/dev",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-a26b992a1",
|
|
4
4
|
"description": "Dev tools and CLI for React Router",
|
|
5
5
|
"homepage": "https://reactrouter.com",
|
|
6
6
|
"bugs": {
|
|
@@ -12,12 +12,18 @@
|
|
|
12
12
|
"directory": "packages/react-router-dev"
|
|
13
13
|
},
|
|
14
14
|
"license": "MIT",
|
|
15
|
-
"main": "dist/index.js",
|
|
16
|
-
"typings": "dist/index.d.ts",
|
|
17
15
|
"exports": {
|
|
18
|
-
"
|
|
19
|
-
"types": "./dist/
|
|
20
|
-
"default": "./dist/
|
|
16
|
+
"./routes": {
|
|
17
|
+
"types": "./dist/routes.d.ts",
|
|
18
|
+
"default": "./dist/routes.js"
|
|
19
|
+
},
|
|
20
|
+
"./vite": {
|
|
21
|
+
"types": "./dist/vite.d.ts",
|
|
22
|
+
"default": "./dist/vite.js"
|
|
23
|
+
},
|
|
24
|
+
"./vite/cloudflare": {
|
|
25
|
+
"types": "./dist/vite/cloudflare.d.ts",
|
|
26
|
+
"default": "./dist/vite/cloudflare.js"
|
|
21
27
|
},
|
|
22
28
|
"./package.json": "./package.json"
|
|
23
29
|
},
|
|
@@ -37,25 +43,28 @@
|
|
|
37
43
|
"arg": "^5.0.1",
|
|
38
44
|
"babel-dead-code-elimination": "^1.0.6",
|
|
39
45
|
"chalk": "^4.1.2",
|
|
46
|
+
"dedent": "^1.5.3",
|
|
40
47
|
"es-module-lexer": "^1.3.1",
|
|
41
48
|
"exit-hook": "2.2.1",
|
|
42
49
|
"fs-extra": "^10.0.0",
|
|
43
50
|
"gunzip-maybe": "^1.4.2",
|
|
44
51
|
"jsesc": "3.0.2",
|
|
45
52
|
"lodash": "^4.17.21",
|
|
46
|
-
"minimatch": "^9.0.0",
|
|
47
53
|
"picocolors": "^1.0.0",
|
|
48
54
|
"picomatch": "^2.3.1",
|
|
49
55
|
"prettier": "^2.7.1",
|
|
50
56
|
"react-refresh": "^0.14.0",
|
|
51
57
|
"semver": "^7.3.7",
|
|
52
58
|
"set-cookie-parser": "^2.6.0",
|
|
53
|
-
"
|
|
59
|
+
"vite-node": "^1.6.0",
|
|
60
|
+
"valibot": "^0.41.0",
|
|
61
|
+
"@react-router/node": "0.0.0-experimental-a26b992a1"
|
|
54
62
|
},
|
|
55
63
|
"devDependencies": {
|
|
56
64
|
"@types/babel__core": "^7.20.5",
|
|
57
65
|
"@types/babel__generator": "^7.6.8",
|
|
58
66
|
"@types/babel__traverse": "^7.20.5",
|
|
67
|
+
"@types/dedent": "^0.7.0",
|
|
59
68
|
"@types/express": "^4.17.9",
|
|
60
69
|
"@types/fs-extra": "^8.1.2",
|
|
61
70
|
"@types/gunzip-maybe": "^1.4.0",
|
|
@@ -75,15 +84,15 @@
|
|
|
75
84
|
"tiny-invariant": "^1.2.0",
|
|
76
85
|
"vite": "^5.1.0",
|
|
77
86
|
"wrangler": "^3.28.2",
|
|
78
|
-
"
|
|
79
|
-
"react-router": "
|
|
87
|
+
"react-router": "^0.0.0-experimental-a26b992a1",
|
|
88
|
+
"@react-router/serve": "0.0.0-experimental-a26b992a1"
|
|
80
89
|
},
|
|
81
90
|
"peerDependencies": {
|
|
82
91
|
"typescript": "^5.1.0",
|
|
83
92
|
"vite": "^5.1.0",
|
|
84
93
|
"wrangler": "^3.28.2",
|
|
85
|
-
"@react-router/serve": "^0.0.0-experimental-
|
|
86
|
-
"react-router": "^0.0.0-experimental-
|
|
94
|
+
"@react-router/serve": "^0.0.0-experimental-a26b992a1",
|
|
95
|
+
"react-router": "^0.0.0-experimental-a26b992a1"
|
|
87
96
|
},
|
|
88
97
|
"peerDependenciesMeta": {
|
|
89
98
|
"@react-router/serve": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function findConfig(dir: string, basename: string, extensions: string[]): string | undefined;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @react-router/dev v0.0.0-experimental-49eef6a01
|
|
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,14 +0,0 @@
|
|
|
1
|
-
import type { RouteManifest } from "./routes";
|
|
2
|
-
export declare const routeModuleExts: string[];
|
|
3
|
-
export declare let paramPrefixChar: "$";
|
|
4
|
-
export declare let escapeStart: "[";
|
|
5
|
-
export declare let escapeEnd: "]";
|
|
6
|
-
export declare let optionalStart: "(";
|
|
7
|
-
export declare let optionalEnd: ")";
|
|
8
|
-
export declare function flatRoutes(appDirectory: string, ignoredFilePatterns?: string[], prefix?: string): RouteManifest;
|
|
9
|
-
export declare function flatRoutesUniversal(appDirectory: string, routes: string[], prefix?: string): RouteManifest;
|
|
10
|
-
export declare function getRouteSegments(routeId: string): [string[], string[]];
|
|
11
|
-
export declare function createRoutePath(routeSegments: string[], rawRouteSegments: string[], isIndex?: boolean): string | undefined;
|
|
12
|
-
export declare function getRoutePathConflictErrorMessage(pathname: string, routes: string[]): string;
|
|
13
|
-
export declare function getRouteIdConflictErrorMessage(routeId: string, files: string[]): string;
|
|
14
|
-
export declare function isSegmentSeparator(checkChar: string | undefined): boolean;
|
|
@@ -1,418 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @react-router/dev v0.0.0-experimental-49eef6a01
|
|
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 path = require('node:path');
|
|
17
|
-
var minimatch = require('minimatch');
|
|
18
|
-
var routes = require('./routes.js');
|
|
19
|
-
var findConfig = require('./findConfig.js');
|
|
20
|
-
|
|
21
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
22
|
-
|
|
23
|
-
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
24
|
-
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
25
|
-
|
|
26
|
-
const routeModuleExts = [".js", ".jsx", ".ts", ".tsx", ".md", ".mdx"];
|
|
27
|
-
let paramPrefixChar = "$";
|
|
28
|
-
let escapeStart = "[";
|
|
29
|
-
let escapeEnd = "]";
|
|
30
|
-
let optionalStart = "(";
|
|
31
|
-
let optionalEnd = ")";
|
|
32
|
-
const PrefixLookupTrieEndSymbol = Symbol("PrefixLookupTrieEndSymbol");
|
|
33
|
-
class PrefixLookupTrie {
|
|
34
|
-
root = {
|
|
35
|
-
[PrefixLookupTrieEndSymbol]: false
|
|
36
|
-
};
|
|
37
|
-
add(value) {
|
|
38
|
-
if (!value) throw new Error("Cannot add empty string to PrefixLookupTrie");
|
|
39
|
-
let node = this.root;
|
|
40
|
-
for (let char of value) {
|
|
41
|
-
if (!node[char]) {
|
|
42
|
-
node[char] = {
|
|
43
|
-
[PrefixLookupTrieEndSymbol]: false
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
node = node[char];
|
|
47
|
-
}
|
|
48
|
-
node[PrefixLookupTrieEndSymbol] = true;
|
|
49
|
-
}
|
|
50
|
-
findAndRemove(prefix, filter) {
|
|
51
|
-
let node = this.root;
|
|
52
|
-
for (let char of prefix) {
|
|
53
|
-
if (!node[char]) return [];
|
|
54
|
-
node = node[char];
|
|
55
|
-
}
|
|
56
|
-
return this.#findAndRemoveRecursive([], node, prefix, filter);
|
|
57
|
-
}
|
|
58
|
-
#findAndRemoveRecursive(values, node, prefix, filter) {
|
|
59
|
-
for (let char of Object.keys(node)) {
|
|
60
|
-
this.#findAndRemoveRecursive(values, node[char], prefix + char, filter);
|
|
61
|
-
}
|
|
62
|
-
if (node[PrefixLookupTrieEndSymbol] && filter(prefix)) {
|
|
63
|
-
node[PrefixLookupTrieEndSymbol] = false;
|
|
64
|
-
values.push(prefix);
|
|
65
|
-
}
|
|
66
|
-
return values;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
function flatRoutes(appDirectory, ignoredFilePatterns = [], prefix = "routes") {
|
|
70
|
-
let ignoredFileRegex = Array.from(new Set(["**/.*", ...ignoredFilePatterns])).map(re => minimatch.makeRe(re)).filter(re => !!re);
|
|
71
|
-
let routesDir = path__default["default"].join(appDirectory, prefix);
|
|
72
|
-
let rootRoute = findConfig.findConfig(appDirectory, "root", routeModuleExts);
|
|
73
|
-
if (!rootRoute) {
|
|
74
|
-
throw new Error(`Could not find a root route module in the app directory: ${appDirectory}`);
|
|
75
|
-
}
|
|
76
|
-
if (!fs__default["default"].existsSync(rootRoute)) {
|
|
77
|
-
throw new Error(`Could not find the routes directory: ${routesDir}. Did you forget to create it?`);
|
|
78
|
-
}
|
|
79
|
-
// Only read the routes directory
|
|
80
|
-
let entries = fs__default["default"].readdirSync(routesDir, {
|
|
81
|
-
withFileTypes: true,
|
|
82
|
-
encoding: "utf-8"
|
|
83
|
-
});
|
|
84
|
-
let routes$1 = [];
|
|
85
|
-
for (let entry of entries) {
|
|
86
|
-
let filepath = routes.normalizeSlashes(path__default["default"].join(routesDir, entry.name));
|
|
87
|
-
let route = null;
|
|
88
|
-
// If it's a directory, don't recurse into it, instead just look for a route module
|
|
89
|
-
if (entry.isDirectory()) {
|
|
90
|
-
route = findRouteModuleForFolder(appDirectory, filepath, ignoredFileRegex);
|
|
91
|
-
} else if (entry.isFile()) {
|
|
92
|
-
route = findRouteModuleForFile(appDirectory, filepath, ignoredFileRegex);
|
|
93
|
-
}
|
|
94
|
-
if (route) routes$1.push(route);
|
|
95
|
-
}
|
|
96
|
-
let routeManifest = flatRoutesUniversal(appDirectory, routes$1, prefix);
|
|
97
|
-
return routeManifest;
|
|
98
|
-
}
|
|
99
|
-
function flatRoutesUniversal(appDirectory, routes$1, prefix = "routes") {
|
|
100
|
-
let urlConflicts = new Map();
|
|
101
|
-
let routeManifest = {};
|
|
102
|
-
let prefixLookup = new PrefixLookupTrie();
|
|
103
|
-
let uniqueRoutes = new Map();
|
|
104
|
-
let routeIdConflicts = new Map();
|
|
105
|
-
// id -> file
|
|
106
|
-
let routeIds = new Map();
|
|
107
|
-
for (let file of routes$1) {
|
|
108
|
-
let normalizedFile = routes.normalizeSlashes(file);
|
|
109
|
-
let routeExt = path__default["default"].extname(normalizedFile);
|
|
110
|
-
let routeDir = path__default["default"].dirname(normalizedFile);
|
|
111
|
-
let normalizedApp = routes.normalizeSlashes(appDirectory);
|
|
112
|
-
let routeId = routeDir === path__default["default"].posix.join(normalizedApp, prefix) ? path__default["default"].posix.relative(normalizedApp, normalizedFile).slice(0, -routeExt.length) : path__default["default"].posix.relative(normalizedApp, routeDir);
|
|
113
|
-
let conflict = routeIds.get(routeId);
|
|
114
|
-
if (conflict) {
|
|
115
|
-
let currentConflicts = routeIdConflicts.get(routeId);
|
|
116
|
-
if (!currentConflicts) {
|
|
117
|
-
currentConflicts = [path__default["default"].posix.relative(normalizedApp, conflict)];
|
|
118
|
-
}
|
|
119
|
-
currentConflicts.push(path__default["default"].posix.relative(normalizedApp, normalizedFile));
|
|
120
|
-
routeIdConflicts.set(routeId, currentConflicts);
|
|
121
|
-
continue;
|
|
122
|
-
}
|
|
123
|
-
routeIds.set(routeId, normalizedFile);
|
|
124
|
-
}
|
|
125
|
-
let sortedRouteIds = Array.from(routeIds).sort(([a], [b]) => b.length - a.length);
|
|
126
|
-
for (let [routeId, file] of sortedRouteIds) {
|
|
127
|
-
let index = routeId.endsWith("_index");
|
|
128
|
-
let [segments, raw] = getRouteSegments(routeId.slice(prefix.length + 1));
|
|
129
|
-
let pathname = createRoutePath(segments, raw, index);
|
|
130
|
-
routeManifest[routeId] = {
|
|
131
|
-
file: file.slice(appDirectory.length + 1),
|
|
132
|
-
id: routeId,
|
|
133
|
-
path: pathname
|
|
134
|
-
};
|
|
135
|
-
if (index) routeManifest[routeId].index = true;
|
|
136
|
-
let childRouteIds = prefixLookup.findAndRemove(routeId, value => {
|
|
137
|
-
return [".", "/"].includes(value.slice(routeId.length).charAt(0));
|
|
138
|
-
});
|
|
139
|
-
prefixLookup.add(routeId);
|
|
140
|
-
if (childRouteIds.length > 0) {
|
|
141
|
-
for (let childRouteId of childRouteIds) {
|
|
142
|
-
routeManifest[childRouteId].parentId = routeId;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
// path creation
|
|
147
|
-
let parentChildrenMap = new Map();
|
|
148
|
-
for (let [routeId] of sortedRouteIds) {
|
|
149
|
-
let config = routeManifest[routeId];
|
|
150
|
-
if (!config.parentId) continue;
|
|
151
|
-
let existingChildren = parentChildrenMap.get(config.parentId) || [];
|
|
152
|
-
existingChildren.push(config);
|
|
153
|
-
parentChildrenMap.set(config.parentId, existingChildren);
|
|
154
|
-
}
|
|
155
|
-
for (let [routeId] of sortedRouteIds) {
|
|
156
|
-
let config = routeManifest[routeId];
|
|
157
|
-
let originalPathname = config.path || "";
|
|
158
|
-
let pathname = config.path;
|
|
159
|
-
let parentConfig = config.parentId ? routeManifest[config.parentId] : null;
|
|
160
|
-
if (parentConfig !== null && parentConfig !== void 0 && parentConfig.path && pathname) {
|
|
161
|
-
pathname = pathname.slice(parentConfig.path.length).replace(/^\//, "").replace(/\/$/, "");
|
|
162
|
-
}
|
|
163
|
-
if (!config.parentId) config.parentId = "root";
|
|
164
|
-
config.path = pathname || undefined;
|
|
165
|
-
/**
|
|
166
|
-
* We do not try to detect path collisions for pathless layout route
|
|
167
|
-
* files because, by definition, they create the potential for route
|
|
168
|
-
* collisions _at that level in the tree_.
|
|
169
|
-
*
|
|
170
|
-
* Consider example where a user may want multiple pathless layout routes
|
|
171
|
-
* for different subfolders
|
|
172
|
-
*
|
|
173
|
-
* routes/
|
|
174
|
-
* account.tsx
|
|
175
|
-
* account._private.tsx
|
|
176
|
-
* account._private.orders.tsx
|
|
177
|
-
* account._private.profile.tsx
|
|
178
|
-
* account._public.tsx
|
|
179
|
-
* account._public.login.tsx
|
|
180
|
-
* account._public.perks.tsx
|
|
181
|
-
*
|
|
182
|
-
* In order to support both a public and private layout for `/account/*`
|
|
183
|
-
* URLs, we are creating a mutually exclusive set of URLs beneath 2
|
|
184
|
-
* separate pathless layout routes. In this case, the route paths for
|
|
185
|
-
* both account._public.tsx and account._private.tsx is the same
|
|
186
|
-
* (/account), but we're again not expecting to match at that level.
|
|
187
|
-
*
|
|
188
|
-
* By only ignoring this check when the final portion of the filename is
|
|
189
|
-
* pathless, we will still detect path collisions such as:
|
|
190
|
-
*
|
|
191
|
-
* routes/parent._pathless.foo.tsx
|
|
192
|
-
* routes/parent._pathless2.foo.tsx
|
|
193
|
-
*
|
|
194
|
-
* and
|
|
195
|
-
*
|
|
196
|
-
* routes/parent._pathless/index.tsx
|
|
197
|
-
* routes/parent._pathless2/index.tsx
|
|
198
|
-
*/
|
|
199
|
-
let lastRouteSegment = config.id.replace(new RegExp(`^${prefix}/`), "").split(".").pop();
|
|
200
|
-
let isPathlessLayoutRoute = lastRouteSegment && lastRouteSegment.startsWith("_") && lastRouteSegment !== "_index";
|
|
201
|
-
if (isPathlessLayoutRoute) {
|
|
202
|
-
continue;
|
|
203
|
-
}
|
|
204
|
-
let conflictRouteId = originalPathname + (config.index ? "?index" : "");
|
|
205
|
-
let conflict = uniqueRoutes.get(conflictRouteId);
|
|
206
|
-
uniqueRoutes.set(conflictRouteId, config);
|
|
207
|
-
if (conflict && (originalPathname || config.index)) {
|
|
208
|
-
let currentConflicts = urlConflicts.get(originalPathname);
|
|
209
|
-
if (!currentConflicts) currentConflicts = [conflict];
|
|
210
|
-
currentConflicts.push(config);
|
|
211
|
-
urlConflicts.set(originalPathname, currentConflicts);
|
|
212
|
-
continue;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
if (routeIdConflicts.size > 0) {
|
|
216
|
-
for (let [routeId, files] of routeIdConflicts.entries()) {
|
|
217
|
-
console.error(getRouteIdConflictErrorMessage(routeId, files));
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
// report conflicts
|
|
221
|
-
if (urlConflicts.size > 0) {
|
|
222
|
-
for (let [path, routes] of urlConflicts.entries()) {
|
|
223
|
-
// delete all but the first route from the manifest
|
|
224
|
-
for (let i = 1; i < routes.length; i++) {
|
|
225
|
-
delete routeManifest[routes[i].id];
|
|
226
|
-
}
|
|
227
|
-
let files = routes.map(r => r.file);
|
|
228
|
-
console.error(getRoutePathConflictErrorMessage(path, files));
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
return routeManifest;
|
|
232
|
-
}
|
|
233
|
-
function findRouteModuleForFile(appDirectory, filepath, ignoredFileRegex) {
|
|
234
|
-
let relativePath = routes.normalizeSlashes(path__default["default"].relative(appDirectory, filepath));
|
|
235
|
-
let isIgnored = ignoredFileRegex.some(regex => regex.test(relativePath));
|
|
236
|
-
if (isIgnored) return null;
|
|
237
|
-
return filepath;
|
|
238
|
-
}
|
|
239
|
-
function findRouteModuleForFolder(appDirectory, filepath, ignoredFileRegex) {
|
|
240
|
-
let relativePath = path__default["default"].relative(appDirectory, filepath);
|
|
241
|
-
let isIgnored = ignoredFileRegex.some(regex => regex.test(relativePath));
|
|
242
|
-
if (isIgnored) return null;
|
|
243
|
-
let routeRouteModule = findConfig.findConfig(filepath, "route", routeModuleExts);
|
|
244
|
-
let routeIndexModule = findConfig.findConfig(filepath, "index", routeModuleExts);
|
|
245
|
-
// if both a route and index module exist, throw a conflict error
|
|
246
|
-
// preferring the route module over the index module
|
|
247
|
-
if (routeRouteModule && routeIndexModule) {
|
|
248
|
-
let [segments, raw] = getRouteSegments(path__default["default"].relative(appDirectory, filepath));
|
|
249
|
-
let routePath = createRoutePath(segments, raw, false);
|
|
250
|
-
console.error(getRoutePathConflictErrorMessage(routePath || "/", [routeRouteModule, routeIndexModule]));
|
|
251
|
-
}
|
|
252
|
-
return routeRouteModule || routeIndexModule || null;
|
|
253
|
-
}
|
|
254
|
-
function getRouteSegments(routeId) {
|
|
255
|
-
let routeSegments = [];
|
|
256
|
-
let rawRouteSegments = [];
|
|
257
|
-
let index = 0;
|
|
258
|
-
let routeSegment = "";
|
|
259
|
-
let rawRouteSegment = "";
|
|
260
|
-
let state = "NORMAL";
|
|
261
|
-
let pushRouteSegment = (segment, rawSegment) => {
|
|
262
|
-
if (!segment) return;
|
|
263
|
-
let notSupportedInRR = (segment, char) => {
|
|
264
|
-
throw new Error(`Route segment "${segment}" for "${routeId}" cannot contain "${char}".\n` + `If this is something you need, upvote this proposal for React Router https://github.com/remix-run/react-router/discussions/9822.`);
|
|
265
|
-
};
|
|
266
|
-
if (rawSegment.includes("*")) {
|
|
267
|
-
return notSupportedInRR(rawSegment, "*");
|
|
268
|
-
}
|
|
269
|
-
if (rawSegment.includes(":")) {
|
|
270
|
-
return notSupportedInRR(rawSegment, ":");
|
|
271
|
-
}
|
|
272
|
-
if (rawSegment.includes("/")) {
|
|
273
|
-
return notSupportedInRR(segment, "/");
|
|
274
|
-
}
|
|
275
|
-
routeSegments.push(segment);
|
|
276
|
-
rawRouteSegments.push(rawSegment);
|
|
277
|
-
};
|
|
278
|
-
while (index < routeId.length) {
|
|
279
|
-
let char = routeId[index];
|
|
280
|
-
index++; //advance to next char
|
|
281
|
-
switch (state) {
|
|
282
|
-
case "NORMAL":
|
|
283
|
-
{
|
|
284
|
-
if (isSegmentSeparator(char)) {
|
|
285
|
-
pushRouteSegment(routeSegment, rawRouteSegment);
|
|
286
|
-
routeSegment = "";
|
|
287
|
-
rawRouteSegment = "";
|
|
288
|
-
state = "NORMAL";
|
|
289
|
-
break;
|
|
290
|
-
}
|
|
291
|
-
if (char === escapeStart) {
|
|
292
|
-
state = "ESCAPE";
|
|
293
|
-
rawRouteSegment += char;
|
|
294
|
-
break;
|
|
295
|
-
}
|
|
296
|
-
if (char === optionalStart) {
|
|
297
|
-
state = "OPTIONAL";
|
|
298
|
-
rawRouteSegment += char;
|
|
299
|
-
break;
|
|
300
|
-
}
|
|
301
|
-
if (!routeSegment && char == paramPrefixChar) {
|
|
302
|
-
if (index === routeId.length) {
|
|
303
|
-
routeSegment += "*";
|
|
304
|
-
rawRouteSegment += char;
|
|
305
|
-
} else {
|
|
306
|
-
routeSegment += ":";
|
|
307
|
-
rawRouteSegment += char;
|
|
308
|
-
}
|
|
309
|
-
break;
|
|
310
|
-
}
|
|
311
|
-
routeSegment += char;
|
|
312
|
-
rawRouteSegment += char;
|
|
313
|
-
break;
|
|
314
|
-
}
|
|
315
|
-
case "ESCAPE":
|
|
316
|
-
{
|
|
317
|
-
if (char === escapeEnd) {
|
|
318
|
-
state = "NORMAL";
|
|
319
|
-
rawRouteSegment += char;
|
|
320
|
-
break;
|
|
321
|
-
}
|
|
322
|
-
routeSegment += char;
|
|
323
|
-
rawRouteSegment += char;
|
|
324
|
-
break;
|
|
325
|
-
}
|
|
326
|
-
case "OPTIONAL":
|
|
327
|
-
{
|
|
328
|
-
if (char === optionalEnd) {
|
|
329
|
-
routeSegment += "?";
|
|
330
|
-
rawRouteSegment += char;
|
|
331
|
-
state = "NORMAL";
|
|
332
|
-
break;
|
|
333
|
-
}
|
|
334
|
-
if (char === escapeStart) {
|
|
335
|
-
state = "OPTIONAL_ESCAPE";
|
|
336
|
-
rawRouteSegment += char;
|
|
337
|
-
break;
|
|
338
|
-
}
|
|
339
|
-
if (!routeSegment && char === paramPrefixChar) {
|
|
340
|
-
if (index === routeId.length) {
|
|
341
|
-
routeSegment += "*";
|
|
342
|
-
rawRouteSegment += char;
|
|
343
|
-
} else {
|
|
344
|
-
routeSegment += ":";
|
|
345
|
-
rawRouteSegment += char;
|
|
346
|
-
}
|
|
347
|
-
break;
|
|
348
|
-
}
|
|
349
|
-
routeSegment += char;
|
|
350
|
-
rawRouteSegment += char;
|
|
351
|
-
break;
|
|
352
|
-
}
|
|
353
|
-
case "OPTIONAL_ESCAPE":
|
|
354
|
-
{
|
|
355
|
-
if (char === escapeEnd) {
|
|
356
|
-
state = "OPTIONAL";
|
|
357
|
-
rawRouteSegment += char;
|
|
358
|
-
break;
|
|
359
|
-
}
|
|
360
|
-
routeSegment += char;
|
|
361
|
-
rawRouteSegment += char;
|
|
362
|
-
break;
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
// process remaining segment
|
|
367
|
-
pushRouteSegment(routeSegment, rawRouteSegment);
|
|
368
|
-
return [routeSegments, rawRouteSegments];
|
|
369
|
-
}
|
|
370
|
-
function createRoutePath(routeSegments, rawRouteSegments, isIndex) {
|
|
371
|
-
let result = [];
|
|
372
|
-
if (isIndex) {
|
|
373
|
-
routeSegments = routeSegments.slice(0, -1);
|
|
374
|
-
}
|
|
375
|
-
for (let index = 0; index < routeSegments.length; index++) {
|
|
376
|
-
let segment = routeSegments[index];
|
|
377
|
-
let rawSegment = rawRouteSegments[index];
|
|
378
|
-
// skip pathless layout segments
|
|
379
|
-
if (segment.startsWith("_") && rawSegment.startsWith("_")) {
|
|
380
|
-
continue;
|
|
381
|
-
}
|
|
382
|
-
// remove trailing slash
|
|
383
|
-
if (segment.endsWith("_") && rawSegment.endsWith("_")) {
|
|
384
|
-
segment = segment.slice(0, -1);
|
|
385
|
-
}
|
|
386
|
-
result.push(segment);
|
|
387
|
-
}
|
|
388
|
-
return result.length ? result.join("/") : undefined;
|
|
389
|
-
}
|
|
390
|
-
function getRoutePathConflictErrorMessage(pathname, routes) {
|
|
391
|
-
let [taken, ...others] = routes;
|
|
392
|
-
if (!pathname.startsWith("/")) {
|
|
393
|
-
pathname = "/" + pathname;
|
|
394
|
-
}
|
|
395
|
-
return `⚠️ Route Path Collision: "${pathname}"\n\n` + `The following routes all define the same URL, only the first one will be used\n\n` + `🟢 ${taken}\n` + others.map(route => `⭕️️ ${route}`).join("\n") + "\n";
|
|
396
|
-
}
|
|
397
|
-
function getRouteIdConflictErrorMessage(routeId, files) {
|
|
398
|
-
let [taken, ...others] = files;
|
|
399
|
-
return `⚠️ Route ID Collision: "${routeId}"\n\n` + `The following routes all define the same Route ID, only the first one will be used\n\n` + `🟢 ${taken}\n` + others.map(route => `⭕️️ ${route}`).join("\n") + "\n";
|
|
400
|
-
}
|
|
401
|
-
function isSegmentSeparator(checkChar) {
|
|
402
|
-
if (!checkChar) return false;
|
|
403
|
-
return ["/", ".", path__default["default"].win32.sep].includes(checkChar);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
exports.createRoutePath = createRoutePath;
|
|
407
|
-
exports.escapeEnd = escapeEnd;
|
|
408
|
-
exports.escapeStart = escapeStart;
|
|
409
|
-
exports.flatRoutes = flatRoutes;
|
|
410
|
-
exports.flatRoutesUniversal = flatRoutesUniversal;
|
|
411
|
-
exports.getRouteIdConflictErrorMessage = getRouteIdConflictErrorMessage;
|
|
412
|
-
exports.getRoutePathConflictErrorMessage = getRoutePathConflictErrorMessage;
|
|
413
|
-
exports.getRouteSegments = getRouteSegments;
|
|
414
|
-
exports.isSegmentSeparator = isSegmentSeparator;
|
|
415
|
-
exports.optionalEnd = optionalEnd;
|
|
416
|
-
exports.optionalStart = optionalStart;
|
|
417
|
-
exports.paramPrefixChar = paramPrefixChar;
|
|
418
|
-
exports.routeModuleExts = routeModuleExts;
|
package/dist/index.d.ts
DELETED
package/dist/index.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @react-router/dev v0.0.0-experimental-49eef6a01
|
|
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 index = require('./cli/index.js');
|
|
16
|
-
var index$1 = require('./vite/index.js');
|
|
17
|
-
var cloudflareDevProxy = require('./vite/cloudflare-dev-proxy.js');
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
exports.cli = index;
|
|
22
|
-
exports.vitePlugin = index$1.vitePlugin;
|
|
23
|
-
exports.cloudflareDevProxyVitePlugin = cloudflareDevProxy.cloudflareDevProxyVitePlugin;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export declare function transform(code: string, id: string, options?: {
|
|
2
|
-
ssr?: boolean;
|
|
3
|
-
}): string | import("@babel/generator").GeneratorResult;
|
|
4
|
-
export declare function parseFields(code: string): string[];
|
|
5
|
-
export declare function assertNotImported(code: string): void;
|