@react-router/dev 0.0.0-experimental-c0856287f
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/CHANGELOG.md +1773 -0
- package/LICENSE.md +23 -0
- package/README.md +13 -0
- package/dist/cli/commands.d.ts +12 -0
- package/dist/cli/commands.js +174 -0
- package/dist/cli/detectPackageManager.d.ts +10 -0
- package/dist/cli/detectPackageManager.js +39 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +19 -0
- package/dist/cli/run.d.ts +5 -0
- package/dist/cli/run.js +180 -0
- package/dist/cli/useJavascript.d.ts +4 -0
- package/dist/cli/useJavascript.js +66 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +21 -0
- package/dist/colors.d.ts +17 -0
- package/dist/colors.js +49 -0
- package/dist/config/defaults/entry.client.tsx +12 -0
- package/dist/config/defaults/entry.dev.d.ts +2 -0
- package/dist/config/defaults/entry.dev.ts +13 -0
- package/dist/config/defaults/entry.server.cloudflare.tsx +55 -0
- package/dist/config/defaults/entry.server.deno.tsx +55 -0
- package/dist/config/defaults/entry.server.node.tsx +155 -0
- package/dist/config/defaults/entry.server.spa.tsx +20 -0
- package/dist/config/flat-routes.d.ts +14 -0
- package/dist/config/flat-routes.js +418 -0
- package/dist/config/format.d.ts +5 -0
- package/dist/config/format.js +68 -0
- package/dist/config/routes.d.ts +98 -0
- package/dist/config/routes.js +93 -0
- package/dist/config/serverModes.d.ts +9 -0
- package/dist/config/serverModes.js +28 -0
- package/dist/config.d.ts +75 -0
- package/dist/config.js +152 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +23 -0
- package/dist/invariant.d.ts +2 -0
- package/dist/invariant.js +22 -0
- package/dist/manifest.d.ts +28 -0
- package/dist/vite/babel.d.ts +20 -0
- package/dist/vite/babel.js +49 -0
- package/dist/vite/build.d.ts +15 -0
- package/dist/vite/build.js +271 -0
- package/dist/vite/cloudflare-proxy-plugin.d.ts +15 -0
- package/dist/vite/cloudflare-proxy-plugin.js +82 -0
- package/dist/vite/dev.d.ts +15 -0
- package/dist/vite/dev.js +81 -0
- package/dist/vite/import-vite-esm-sync.d.ts +4 -0
- package/dist/vite/import-vite-esm-sync.js +28 -0
- package/dist/vite/index.d.ts +4 -0
- package/dist/vite/index.js +30 -0
- package/dist/vite/node-adapter.d.ts +6 -0
- package/dist/vite/node-adapter.js +78 -0
- package/dist/vite/plugin.d.ts +165 -0
- package/dist/vite/plugin.js +1178 -0
- package/dist/vite/profiler.d.ts +5 -0
- package/dist/vite/profiler.js +55 -0
- package/dist/vite/remove-exports-test.d.ts +1 -0
- package/dist/vite/remove-exports.d.ts +2 -0
- package/dist/vite/remove-exports.js +278 -0
- package/dist/vite/resolve-file-url.d.ts +3 -0
- package/dist/vite/resolve-file-url.js +53 -0
- package/dist/vite/static/refresh-utils.cjs +185 -0
- package/dist/vite/styles.d.ts +13 -0
- package/dist/vite/styles.js +176 -0
- package/dist/vite/vmod.d.ts +3 -0
- package/dist/vite/vmod.js +21 -0
- package/package.json +107 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-c0856287f
|
|
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 reactRouter = require('react-router');
|
|
17
|
+
var resolveFileUrl = require('./resolve-file-url.js');
|
|
18
|
+
|
|
19
|
+
function _interopNamespace(e) {
|
|
20
|
+
if (e && e.__esModule) return e;
|
|
21
|
+
var n = Object.create(null);
|
|
22
|
+
if (e) {
|
|
23
|
+
Object.keys(e).forEach(function (k) {
|
|
24
|
+
if (k !== 'default') {
|
|
25
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
26
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function () { return e[k]; }
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
n["default"] = e;
|
|
34
|
+
return Object.freeze(n);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
|
38
|
+
|
|
39
|
+
// Style collection logic adapted from solid-start: https://github.com/solidjs/solid-start
|
|
40
|
+
// Vite doesn't expose these so we just copy the list for now
|
|
41
|
+
// https://github.com/vitejs/vite/blob/d6bde8b03d433778aaed62afc2be0630c8131908/packages/vite/src/node/constants.ts#L49C23-L50
|
|
42
|
+
const cssFileRegExp = /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
|
|
43
|
+
// https://github.com/vitejs/vite/blob/d6bde8b03d433778aaed62afc2be0630c8131908/packages/vite/src/node/plugins/css.ts#L160
|
|
44
|
+
const cssModulesRegExp = new RegExp(`\\.module${cssFileRegExp.source}`);
|
|
45
|
+
const isCssFile = file => cssFileRegExp.test(file);
|
|
46
|
+
const isCssModulesFile = file => cssModulesRegExp.test(file);
|
|
47
|
+
const getStylesForFiles = async ({
|
|
48
|
+
viteDevServer,
|
|
49
|
+
rootDirectory,
|
|
50
|
+
cssModulesManifest,
|
|
51
|
+
files
|
|
52
|
+
}) => {
|
|
53
|
+
let styles = {};
|
|
54
|
+
let deps = new Set();
|
|
55
|
+
try {
|
|
56
|
+
for (let file of files) {
|
|
57
|
+
let normalizedPath = path__namespace.resolve(rootDirectory, file).replace(/\\/g, "/");
|
|
58
|
+
let node = await viteDevServer.moduleGraph.getModuleById(normalizedPath);
|
|
59
|
+
// If the module is only present in the client module graph, the module
|
|
60
|
+
// won't have been found on the first request to the server. If so, we
|
|
61
|
+
// request the module so it's in the module graph, then try again.
|
|
62
|
+
if (!node) {
|
|
63
|
+
try {
|
|
64
|
+
await viteDevServer.transformRequest(resolveFileUrl.resolveFileUrl({
|
|
65
|
+
rootDirectory
|
|
66
|
+
}, normalizedPath));
|
|
67
|
+
} catch (err) {
|
|
68
|
+
console.error(err);
|
|
69
|
+
}
|
|
70
|
+
node = await viteDevServer.moduleGraph.getModuleById(normalizedPath);
|
|
71
|
+
}
|
|
72
|
+
if (!node) {
|
|
73
|
+
console.log(`Could not resolve module for file: ${file}`);
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
await findDeps(viteDevServer, node, deps);
|
|
77
|
+
}
|
|
78
|
+
} catch (err) {
|
|
79
|
+
console.error(err);
|
|
80
|
+
}
|
|
81
|
+
for (let dep of deps) {
|
|
82
|
+
if (dep.file && isCssFile(dep.file) && !dep.url.endsWith("?url") // Ignore styles that resolved as URLs, otherwise we'll end up injecting URLs into the style tag contents
|
|
83
|
+
) {
|
|
84
|
+
try {
|
|
85
|
+
let css = isCssModulesFile(dep.file) ? cssModulesManifest[dep.file] : (await viteDevServer.ssrLoadModule(dep.url)).default;
|
|
86
|
+
if (css === undefined) {
|
|
87
|
+
throw new Error();
|
|
88
|
+
}
|
|
89
|
+
styles[dep.url] = css;
|
|
90
|
+
} catch {
|
|
91
|
+
console.warn(`Could not load ${dep.file}`);
|
|
92
|
+
// this can happen with dynamically imported modules, I think
|
|
93
|
+
// because the Vite module graph doesn't distinguish between
|
|
94
|
+
// static and dynamic imports? TODO investigate, submit fix
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return Object.entries(styles).map(([fileName, css], i) => [`\n/* ${fileName
|
|
99
|
+
// Escape comment syntax in file paths
|
|
100
|
+
.replace(/\/\*/g, "/\\*").replace(/\*\//g, "*\\/")} */`, css]).flat().join("\n") || undefined;
|
|
101
|
+
};
|
|
102
|
+
const findDeps = async (vite, node, deps) => {
|
|
103
|
+
// since `ssrTransformResult.deps` contains URLs instead of `ModuleNode`s, this process is asynchronous.
|
|
104
|
+
// instead of using `await`, we resolve all branches in parallel.
|
|
105
|
+
let branches = [];
|
|
106
|
+
async function addFromNode(node) {
|
|
107
|
+
if (!deps.has(node)) {
|
|
108
|
+
deps.add(node);
|
|
109
|
+
await findDeps(vite, node, deps);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async function addFromUrl(url) {
|
|
113
|
+
let node = await vite.moduleGraph.getModuleByUrl(url);
|
|
114
|
+
if (node) {
|
|
115
|
+
await addFromNode(node);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (node.ssrTransformResult) {
|
|
119
|
+
if (node.ssrTransformResult.deps) {
|
|
120
|
+
node.ssrTransformResult.deps.forEach(url => branches.push(addFromUrl(url)));
|
|
121
|
+
}
|
|
122
|
+
} else {
|
|
123
|
+
node.importedModules.forEach(node => branches.push(addFromNode(node)));
|
|
124
|
+
}
|
|
125
|
+
await Promise.all(branches);
|
|
126
|
+
};
|
|
127
|
+
const groupRoutesByParentId = manifest => {
|
|
128
|
+
let routes = {};
|
|
129
|
+
Object.values(manifest).forEach(route => {
|
|
130
|
+
let parentId = route.parentId || "";
|
|
131
|
+
if (!routes[parentId]) {
|
|
132
|
+
routes[parentId] = [];
|
|
133
|
+
}
|
|
134
|
+
routes[parentId].push(route);
|
|
135
|
+
});
|
|
136
|
+
return routes;
|
|
137
|
+
};
|
|
138
|
+
// Create a map of routes by parentId to use recursively instead of
|
|
139
|
+
// repeatedly filtering the manifest.
|
|
140
|
+
const createRoutes = (manifest, parentId = "", routesByParentId = groupRoutesByParentId(manifest)) => {
|
|
141
|
+
return (routesByParentId[parentId] || []).map(route => ({
|
|
142
|
+
...route,
|
|
143
|
+
children: createRoutes(manifest, route.id, routesByParentId)
|
|
144
|
+
}));
|
|
145
|
+
};
|
|
146
|
+
const getStylesForUrl = async ({
|
|
147
|
+
viteDevServer,
|
|
148
|
+
rootDirectory,
|
|
149
|
+
reactRouterConfig,
|
|
150
|
+
entryClientFilePath,
|
|
151
|
+
cssModulesManifest,
|
|
152
|
+
build,
|
|
153
|
+
url
|
|
154
|
+
}) => {
|
|
155
|
+
var _matchRoutes;
|
|
156
|
+
if (url === undefined || url.includes("?_data=")) {
|
|
157
|
+
return undefined;
|
|
158
|
+
}
|
|
159
|
+
let routes = createRoutes(build.routes);
|
|
160
|
+
let appPath = path__namespace.relative(process.cwd(), reactRouterConfig.appDirectory);
|
|
161
|
+
let documentRouteFiles = ((_matchRoutes = reactRouter.matchRoutes(routes, url, build.basename)) === null || _matchRoutes === void 0 ? void 0 : _matchRoutes.map(match => path__namespace.resolve(appPath, reactRouterConfig.routes[match.route.id].file))) ?? [];
|
|
162
|
+
let styles = await getStylesForFiles({
|
|
163
|
+
viteDevServer,
|
|
164
|
+
rootDirectory,
|
|
165
|
+
cssModulesManifest,
|
|
166
|
+
files: [
|
|
167
|
+
// Always include the client entry file when crawling the module graph for CSS
|
|
168
|
+
path__namespace.relative(rootDirectory, entryClientFilePath),
|
|
169
|
+
// Then include any styles from the matched routes
|
|
170
|
+
...documentRouteFiles]
|
|
171
|
+
});
|
|
172
|
+
return styles;
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
exports.getStylesForUrl = getStylesForUrl;
|
|
176
|
+
exports.isCssModulesFile = isCssModulesFile;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-c0856287f
|
|
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
|
+
let id = name => `virtual:react-router/${name}`;
|
|
16
|
+
let resolve = id => `\0${id}`;
|
|
17
|
+
let url = id => `/@id/__x00__${id}`;
|
|
18
|
+
|
|
19
|
+
exports.id = id;
|
|
20
|
+
exports.resolve = resolve;
|
|
21
|
+
exports.url = url;
|
package/package.json
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@react-router/dev",
|
|
3
|
+
"version": "0.0.0-experimental-c0856287f",
|
|
4
|
+
"description": "Dev tools and CLI for React Router",
|
|
5
|
+
"homepage": "https://reactrouter.com",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/remix-run/react-router/issues"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/remix-run/react-router",
|
|
12
|
+
"directory": "packages/remix-dev"
|
|
13
|
+
},
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"main": "dist/index.js",
|
|
16
|
+
"typings": "dist/index.d.ts",
|
|
17
|
+
"bin": {
|
|
18
|
+
"react-router": "dist/cli.js"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@babel/core": "^7.21.8",
|
|
22
|
+
"@babel/generator": "^7.21.5",
|
|
23
|
+
"@babel/parser": "^7.21.8",
|
|
24
|
+
"@babel/plugin-syntax-decorators": "^7.22.10",
|
|
25
|
+
"@babel/plugin-syntax-jsx": "^7.21.4",
|
|
26
|
+
"@babel/preset-typescript": "^7.21.5",
|
|
27
|
+
"@babel/traverse": "^7.23.2",
|
|
28
|
+
"@babel/types": "^7.22.5",
|
|
29
|
+
"@npmcli/package-json": "^4.0.1",
|
|
30
|
+
"arg": "^5.0.1",
|
|
31
|
+
"chalk": "^4.1.2",
|
|
32
|
+
"es-module-lexer": "^1.3.1",
|
|
33
|
+
"exit-hook": "2.2.1",
|
|
34
|
+
"fs-extra": "^10.0.0",
|
|
35
|
+
"gunzip-maybe": "^1.4.2",
|
|
36
|
+
"jsesc": "3.0.2",
|
|
37
|
+
"lodash": "^4.17.21",
|
|
38
|
+
"minimatch": "^9.0.0",
|
|
39
|
+
"picocolors": "^1.0.0",
|
|
40
|
+
"picomatch": "^2.3.1",
|
|
41
|
+
"prettier": "^2.7.1",
|
|
42
|
+
"react-refresh": "^0.14.0",
|
|
43
|
+
"semver": "^7.3.7",
|
|
44
|
+
"set-cookie-parser": "^2.6.0",
|
|
45
|
+
"@react-router/server-runtime": "0.0.0-experimental-c0856287f",
|
|
46
|
+
"@react-router/node": "0.0.0-experimental-c0856287f",
|
|
47
|
+
"react-router": "0.0.0-experimental-c0856287f"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/babel__core": "^7.20.5",
|
|
51
|
+
"@types/babel__generator": "^7.6.8",
|
|
52
|
+
"@types/babel__traverse": "^7.20.5",
|
|
53
|
+
"@types/express": "^4.17.9",
|
|
54
|
+
"@types/fs-extra": "^8.1.2",
|
|
55
|
+
"@types/gunzip-maybe": "^1.4.0",
|
|
56
|
+
"@types/jsesc": "^3.0.1",
|
|
57
|
+
"@types/lodash": "^4.14.182",
|
|
58
|
+
"@types/node": "^18.17.1",
|
|
59
|
+
"@types/npmcli__package-json": "^4.0.0",
|
|
60
|
+
"@types/picomatch": "^2.3.0",
|
|
61
|
+
"@types/prettier": "^2.7.3",
|
|
62
|
+
"@types/set-cookie-parser": "^2.4.1",
|
|
63
|
+
"dotenv": "^16.0.0",
|
|
64
|
+
"execa": "5.1.1",
|
|
65
|
+
"express": "^4.17.1",
|
|
66
|
+
"esbuild-register": "^3.3.2",
|
|
67
|
+
"fast-glob": "3.2.11",
|
|
68
|
+
"strip-ansi": "^6.0.1",
|
|
69
|
+
"tiny-invariant": "^1.2.0",
|
|
70
|
+
"vite": "^5.1.0",
|
|
71
|
+
"wrangler": "^3.28.2",
|
|
72
|
+
"@react-router/serve": "0.0.0-experimental-c0856287f"
|
|
73
|
+
},
|
|
74
|
+
"peerDependencies": {
|
|
75
|
+
"typescript": "^5.1.0",
|
|
76
|
+
"vite": "^5.1.0",
|
|
77
|
+
"wrangler": "^3.28.2",
|
|
78
|
+
"react-router": "^0.0.0-experimental-c0856287f",
|
|
79
|
+
"@react-router/serve": "^0.0.0-experimental-c0856287f"
|
|
80
|
+
},
|
|
81
|
+
"peerDependenciesMeta": {
|
|
82
|
+
"@react-router/serve": {
|
|
83
|
+
"optional": true
|
|
84
|
+
},
|
|
85
|
+
"typescript": {
|
|
86
|
+
"optional": true
|
|
87
|
+
},
|
|
88
|
+
"vite": {
|
|
89
|
+
"optional": true
|
|
90
|
+
},
|
|
91
|
+
"wrangler": {
|
|
92
|
+
"optional": true
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
"engines": {
|
|
96
|
+
"node": ">=18.0.0"
|
|
97
|
+
},
|
|
98
|
+
"files": [
|
|
99
|
+
"dist/",
|
|
100
|
+
"CHANGELOG.md",
|
|
101
|
+
"LICENSE.md",
|
|
102
|
+
"README.md"
|
|
103
|
+
],
|
|
104
|
+
"scripts": {
|
|
105
|
+
"tsc": "tsc"
|
|
106
|
+
}
|
|
107
|
+
}
|