@react-router/dev 7.0.0-pre.2 → 7.0.0-pre.3
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 +11 -0
- package/dist/cli/index.d.ts +2 -1
- package/dist/cli/index.js +1352 -8
- package/dist/routes.d.ts +4 -2
- package/dist/routes.js +181 -11
- package/dist/typescript/plugin.d.ts +5 -2
- package/dist/typescript/plugin.js +479 -31
- package/dist/vite/cloudflare.d.ts +1 -1
- package/dist/vite/cloudflare.js +171 -5
- package/dist/vite.d.ts +2 -2
- package/dist/vite.js +2394 -5
- package/package.json +28 -7
- package/dist/cli/commands.d.ts +0 -13
- package/dist/cli/commands.js +0 -179
- package/dist/cli/detectPackageManager.d.ts +0 -10
- package/dist/cli/detectPackageManager.js +0 -39
- package/dist/cli/run.d.ts +0 -5
- package/dist/cli/run.js +0 -188
- package/dist/cli/useJavascript.d.ts +0 -4
- package/dist/cli/useJavascript.js +0 -66
- package/dist/colors.d.ts +0 -17
- package/dist/colors.js +0 -49
- package/dist/config/format.d.ts +0 -5
- package/dist/config/format.js +0 -68
- package/dist/config/routes.d.ts +0 -129
- package/dist/config/routes.js +0 -253
- package/dist/config/serverModes.d.ts +0 -9
- package/dist/invariant.d.ts +0 -2
- package/dist/invariant.js +0 -20
- package/dist/manifest.d.ts +0 -28
- package/dist/typescript/typegen.d.ts +0 -10
- package/dist/typescript/typegen.js +0 -190
- package/dist/vite/babel.d.ts +0 -20
- package/dist/vite/babel.js +0 -49
- package/dist/vite/build.d.ts +0 -15
- package/dist/vite/build.js +0 -249
- package/dist/vite/cloudflare-dev-proxy.d.ts +0 -21
- package/dist/vite/cloudflare-dev-proxy.js +0 -89
- package/dist/vite/combine-urls-test.d.ts +0 -1
- package/dist/vite/combine-urls.d.ts +0 -1
- package/dist/vite/combine-urls.js +0 -20
- package/dist/vite/config.d.ts +0 -234
- package/dist/vite/config.js +0 -282
- package/dist/vite/dev.d.ts +0 -15
- package/dist/vite/dev.js +0 -81
- package/dist/vite/import-vite-esm-sync.d.ts +0 -4
- package/dist/vite/import-vite-esm-sync.js +0 -28
- package/dist/vite/node-adapter.d.ts +0 -6
- package/dist/vite/node-adapter.js +0 -90
- package/dist/vite/plugin.d.ts +0 -75
- package/dist/vite/plugin.js +0 -1301
- package/dist/vite/profiler.d.ts +0 -5
- package/dist/vite/profiler.js +0 -55
- package/dist/vite/remove-exports-test.d.ts +0 -1
- package/dist/vite/remove-exports.d.ts +0 -2
- package/dist/vite/remove-exports.js +0 -148
- package/dist/vite/resolve-file-url.d.ts +0 -3
- package/dist/vite/resolve-file-url.js +0 -53
- package/dist/vite/styles.d.ts +0 -14
- package/dist/vite/styles.js +0 -199
- package/dist/vite/vite-node.d.ts +0 -9
- package/dist/vite/vite-node.js +0 -57
- package/dist/vite/vmod.d.ts +0 -3
- package/dist/vite/vmod.js +0 -21
- package/dist/vite/with-props.d.ts +0 -4
- package/dist/vite/with-props.js +0 -151
- /package/dist/{vite/static → static}/refresh-utils.cjs +0 -0
package/dist/vite/profiler.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import type { Session } from "node:inspector";
|
|
3
|
-
export declare const getSession: () => Session | undefined;
|
|
4
|
-
export declare const start: (callback?: () => void | Promise<void>) => Promise<void>;
|
|
5
|
-
export declare const stop: (log: (message: string) => void) => void | Promise<void>;
|
package/dist/vite/profiler.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @react-router/dev v7.0.0-pre.2
|
|
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 colors = require('picocolors');
|
|
18
|
-
|
|
19
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
20
|
-
|
|
21
|
-
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
22
|
-
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
23
|
-
var colors__default = /*#__PURE__*/_interopDefaultLegacy(colors);
|
|
24
|
-
|
|
25
|
-
// Adapted from:
|
|
26
|
-
const getSession = () => global.__reactRouter_profile_session;
|
|
27
|
-
const start = async callback => {
|
|
28
|
-
let inspector = await import('node:inspector').then(r => r.default);
|
|
29
|
-
let session = global.__reactRouter_profile_session = new inspector.Session();
|
|
30
|
-
session.connect();
|
|
31
|
-
session.post("Profiler.enable", () => {
|
|
32
|
-
session.post("Profiler.start", callback);
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
let profileCount = 0;
|
|
36
|
-
const stop = log => {
|
|
37
|
-
let session = getSession();
|
|
38
|
-
if (!session) return;
|
|
39
|
-
return new Promise((res, rej) => {
|
|
40
|
-
session.post("Profiler.stop", (err, {
|
|
41
|
-
profile
|
|
42
|
-
}) => {
|
|
43
|
-
if (err) return rej(err);
|
|
44
|
-
let outPath = path__default["default"].resolve(`./react-router-${profileCount++}.cpuprofile`);
|
|
45
|
-
fs__default["default"].writeFileSync(outPath, JSON.stringify(profile));
|
|
46
|
-
log(colors__default["default"].yellow(`CPU profile written to ${colors__default["default"].white(colors__default["default"].dim(outPath))}`));
|
|
47
|
-
global.__reactRouter_profile_session = undefined;
|
|
48
|
-
res();
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
exports.getSession = getSession;
|
|
54
|
-
exports.start = start;
|
|
55
|
-
exports.stop = stop;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @react-router/dev v7.0.0-pre.2
|
|
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 babelDeadCodeElimination = require('babel-dead-code-elimination');
|
|
16
|
-
var babel = require('./babel.js');
|
|
17
|
-
|
|
18
|
-
const removeExports = (ast, exportsToRemove) => {
|
|
19
|
-
let previouslyReferencedIdentifiers = babelDeadCodeElimination.findReferencedIdentifiers(ast);
|
|
20
|
-
let exportsFiltered = false;
|
|
21
|
-
let markedForRemoval = new Set();
|
|
22
|
-
babel.traverse(ast, {
|
|
23
|
-
ExportDeclaration(path) {
|
|
24
|
-
// export { foo };
|
|
25
|
-
// export { bar } from "./module";
|
|
26
|
-
if (path.node.type === "ExportNamedDeclaration") {
|
|
27
|
-
var _path$node$declaratio, _path$node$declaratio2, _path$node$declaratio3;
|
|
28
|
-
if (path.node.specifiers.length) {
|
|
29
|
-
path.node.specifiers = path.node.specifiers.filter(specifier => {
|
|
30
|
-
// Filter out individual specifiers
|
|
31
|
-
if (specifier.type === "ExportSpecifier" && specifier.exported.type === "Identifier") {
|
|
32
|
-
if (exportsToRemove.includes(specifier.exported.name)) {
|
|
33
|
-
exportsFiltered = true;
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return true;
|
|
38
|
-
});
|
|
39
|
-
// Remove the entire export statement if all specifiers were removed
|
|
40
|
-
if (path.node.specifiers.length === 0) {
|
|
41
|
-
markedForRemoval.add(path);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
// export const foo = ...;
|
|
45
|
-
// export const [ foo ] = ...;
|
|
46
|
-
if (((_path$node$declaratio = path.node.declaration) === null || _path$node$declaratio === void 0 ? void 0 : _path$node$declaratio.type) === "VariableDeclaration") {
|
|
47
|
-
let declaration = path.node.declaration;
|
|
48
|
-
declaration.declarations = declaration.declarations.filter(declaration => {
|
|
49
|
-
// export const foo = ...;
|
|
50
|
-
// export const foo = ..., bar = ...;
|
|
51
|
-
if (declaration.id.type === "Identifier" && exportsToRemove.includes(declaration.id.name)) {
|
|
52
|
-
// Filter out individual variables
|
|
53
|
-
exportsFiltered = true;
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
// export const [ foo ] = ...;
|
|
57
|
-
// export const { foo } = ...;
|
|
58
|
-
if (declaration.id.type === "ArrayPattern" || declaration.id.type === "ObjectPattern") {
|
|
59
|
-
// NOTE: These exports cannot be safely removed, so instead we
|
|
60
|
-
// validate them to ensure that any exports that are intended to
|
|
61
|
-
// be removed are not present
|
|
62
|
-
validateDestructuredExports(declaration.id, exportsToRemove);
|
|
63
|
-
}
|
|
64
|
-
return true;
|
|
65
|
-
});
|
|
66
|
-
// Remove the entire export statement if all variables were removed
|
|
67
|
-
if (declaration.declarations.length === 0) {
|
|
68
|
-
markedForRemoval.add(path);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
// export function foo() {}
|
|
72
|
-
if (((_path$node$declaratio2 = path.node.declaration) === null || _path$node$declaratio2 === void 0 ? void 0 : _path$node$declaratio2.type) === "FunctionDeclaration") {
|
|
73
|
-
let id = path.node.declaration.id;
|
|
74
|
-
if (id && exportsToRemove.includes(id.name)) {
|
|
75
|
-
markedForRemoval.add(path);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
// export class Foo() {}
|
|
79
|
-
if (((_path$node$declaratio3 = path.node.declaration) === null || _path$node$declaratio3 === void 0 ? void 0 : _path$node$declaratio3.type) === "ClassDeclaration") {
|
|
80
|
-
let id = path.node.declaration.id;
|
|
81
|
-
if (id && exportsToRemove.includes(id.name)) {
|
|
82
|
-
markedForRemoval.add(path);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
// export default ...;
|
|
87
|
-
if (path.node.type === "ExportDefaultDeclaration" && exportsToRemove.includes("default")) {
|
|
88
|
-
markedForRemoval.add(path);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
if (markedForRemoval.size > 0 || exportsFiltered) {
|
|
93
|
-
for (let path of markedForRemoval) {
|
|
94
|
-
path.remove();
|
|
95
|
-
}
|
|
96
|
-
// Run dead code elimination on any newly unreferenced identifiers
|
|
97
|
-
babelDeadCodeElimination.deadCodeElimination(ast, previouslyReferencedIdentifiers);
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
function validateDestructuredExports(id, exportsToRemove) {
|
|
101
|
-
if (id.type === "ArrayPattern") {
|
|
102
|
-
for (let element of id.elements) {
|
|
103
|
-
if (!element) {
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
// [ foo ]
|
|
107
|
-
if (element.type === "Identifier" && exportsToRemove.includes(element.name)) {
|
|
108
|
-
throw invalidDestructureError(element.name);
|
|
109
|
-
}
|
|
110
|
-
// [ ...foo ]
|
|
111
|
-
if (element.type === "RestElement" && element.argument.type === "Identifier" && exportsToRemove.includes(element.argument.name)) {
|
|
112
|
-
throw invalidDestructureError(element.argument.name);
|
|
113
|
-
}
|
|
114
|
-
// [ [...] ]
|
|
115
|
-
// [ {...} ]
|
|
116
|
-
if (element.type === "ArrayPattern" || element.type === "ObjectPattern") {
|
|
117
|
-
validateDestructuredExports(element, exportsToRemove);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
if (id.type === "ObjectPattern") {
|
|
122
|
-
for (let property of id.properties) {
|
|
123
|
-
if (!property) {
|
|
124
|
-
continue;
|
|
125
|
-
}
|
|
126
|
-
if (property.type === "ObjectProperty" && property.key.type === "Identifier") {
|
|
127
|
-
// { foo }
|
|
128
|
-
if (property.value.type === "Identifier" && exportsToRemove.includes(property.value.name)) {
|
|
129
|
-
throw invalidDestructureError(property.value.name);
|
|
130
|
-
}
|
|
131
|
-
// { foo: [...] }
|
|
132
|
-
// { foo: {...} }
|
|
133
|
-
if (property.value.type === "ArrayPattern" || property.value.type === "ObjectPattern") {
|
|
134
|
-
validateDestructuredExports(property.value, exportsToRemove);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
// { ...foo }
|
|
138
|
-
if (property.type === "RestElement" && property.argument.type === "Identifier" && exportsToRemove.includes(property.argument.name)) {
|
|
139
|
-
throw invalidDestructureError(property.argument.name);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
function invalidDestructureError(name) {
|
|
145
|
-
return new Error(`Cannot remove destructured export "${name}"`);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
exports.removeExports = removeExports;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @react-router/dev v7.0.0-pre.2
|
|
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 importViteEsmSync = require('./import-vite-esm-sync.js');
|
|
17
|
-
|
|
18
|
-
function _interopNamespace(e) {
|
|
19
|
-
if (e && e.__esModule) return e;
|
|
20
|
-
var n = Object.create(null);
|
|
21
|
-
if (e) {
|
|
22
|
-
Object.keys(e).forEach(function (k) {
|
|
23
|
-
if (k !== 'default') {
|
|
24
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
25
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function () { return e[k]; }
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
n["default"] = e;
|
|
33
|
-
return Object.freeze(n);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
|
37
|
-
|
|
38
|
-
const resolveFileUrl = ({
|
|
39
|
-
rootDirectory
|
|
40
|
-
}, filePath) => {
|
|
41
|
-
let vite = importViteEsmSync.importViteEsmSync();
|
|
42
|
-
let relativePath = path__namespace.relative(rootDirectory, filePath);
|
|
43
|
-
let isWithinRoot = !relativePath.startsWith("..") && !path__namespace.isAbsolute(relativePath);
|
|
44
|
-
if (!isWithinRoot) {
|
|
45
|
-
// Vite will prevent serving files outside of the workspace
|
|
46
|
-
// unless user explictly opts in with `server.fs.allow`
|
|
47
|
-
// https://vitejs.dev/config/server-options.html#server-fs-allow
|
|
48
|
-
return path__namespace.posix.join("/@fs", vite.normalizePath(filePath));
|
|
49
|
-
}
|
|
50
|
-
return "/" + vite.normalizePath(relativePath);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
exports.resolveFileUrl = resolveFileUrl;
|
package/dist/vite/styles.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { ServerBuild } from "react-router";
|
|
2
|
-
import type { ViteDevServer } from "vite";
|
|
3
|
-
import type { ResolvedReactRouterConfig } from "./config";
|
|
4
|
-
export declare const isCssModulesFile: (file: string) => boolean;
|
|
5
|
-
export declare const isCssUrlWithoutSideEffects: (url: string) => boolean;
|
|
6
|
-
export declare const getStylesForUrl: ({ viteDevServer, rootDirectory, reactRouterConfig, entryClientFilePath, cssModulesManifest, build, url, }: {
|
|
7
|
-
viteDevServer: ViteDevServer;
|
|
8
|
-
rootDirectory: string;
|
|
9
|
-
reactRouterConfig: Pick<ResolvedReactRouterConfig, "appDirectory" | "routes">;
|
|
10
|
-
entryClientFilePath: string;
|
|
11
|
-
cssModulesManifest: Record<string, string>;
|
|
12
|
-
build: ServerBuild;
|
|
13
|
-
url: string | undefined;
|
|
14
|
-
}) => Promise<string | undefined>;
|
package/dist/vite/styles.js
DELETED
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @react-router/dev v7.0.0-pre.2
|
|
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
|
-
// https://vitejs.dev/guide/features#disabling-css-injection-into-the-page
|
|
48
|
-
// https://github.com/vitejs/vite/blob/561b940f6f963fbb78058a6e23b4adad53a2edb9/packages/vite/src/node/plugins/css.ts#L194
|
|
49
|
-
// https://vitejs.dev/guide/features#static-assets
|
|
50
|
-
// https://github.com/vitejs/vite/blob/561b940f6f963fbb78058a6e23b4adad53a2edb9/packages/vite/src/node/utils.ts#L309-L310
|
|
51
|
-
const cssUrlParamsWithoutSideEffects = ["url", "inline", "raw", "inline-css"];
|
|
52
|
-
const isCssUrlWithoutSideEffects = url => {
|
|
53
|
-
let queryString = url.split("?")[1];
|
|
54
|
-
if (!queryString) {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
let params = new URLSearchParams(queryString);
|
|
58
|
-
for (let paramWithoutSideEffects of cssUrlParamsWithoutSideEffects) {
|
|
59
|
-
if (
|
|
60
|
-
// Parameter is blank and not explicitly set, i.e. "?url", not "?url="
|
|
61
|
-
params.get(paramWithoutSideEffects) === "" && !url.includes(`?${paramWithoutSideEffects}=`) && !url.includes(`&${paramWithoutSideEffects}=`)) {
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return false;
|
|
66
|
-
};
|
|
67
|
-
const getStylesForFiles = async ({
|
|
68
|
-
viteDevServer,
|
|
69
|
-
rootDirectory,
|
|
70
|
-
cssModulesManifest,
|
|
71
|
-
files
|
|
72
|
-
}) => {
|
|
73
|
-
let styles = {};
|
|
74
|
-
let deps = new Set();
|
|
75
|
-
try {
|
|
76
|
-
for (let file of files) {
|
|
77
|
-
let normalizedPath = path__namespace.resolve(rootDirectory, file).replace(/\\/g, "/");
|
|
78
|
-
let node = await viteDevServer.moduleGraph.getModuleById(normalizedPath);
|
|
79
|
-
// If the module is only present in the client module graph, the module
|
|
80
|
-
// won't have been found on the first request to the server. If so, we
|
|
81
|
-
// request the module so it's in the module graph, then try again.
|
|
82
|
-
if (!node) {
|
|
83
|
-
try {
|
|
84
|
-
await viteDevServer.transformRequest(resolveFileUrl.resolveFileUrl({
|
|
85
|
-
rootDirectory
|
|
86
|
-
}, normalizedPath));
|
|
87
|
-
} catch (err) {
|
|
88
|
-
console.error(err);
|
|
89
|
-
}
|
|
90
|
-
node = await viteDevServer.moduleGraph.getModuleById(normalizedPath);
|
|
91
|
-
}
|
|
92
|
-
if (!node) {
|
|
93
|
-
console.log(`Could not resolve module for file: ${file}`);
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
96
|
-
await findDeps(viteDevServer, node, deps);
|
|
97
|
-
}
|
|
98
|
-
} catch (err) {
|
|
99
|
-
console.error(err);
|
|
100
|
-
}
|
|
101
|
-
for (let dep of deps) {
|
|
102
|
-
if (dep.file && isCssFile(dep.file) && !isCssUrlWithoutSideEffects(dep.url) // Ignore styles that resolved as URLs, inline or raw. These shouldn't get injected.
|
|
103
|
-
) {
|
|
104
|
-
try {
|
|
105
|
-
let css = isCssModulesFile(dep.file) ? cssModulesManifest[dep.file] : (await viteDevServer.ssrLoadModule(dep.url)).default;
|
|
106
|
-
if (css === undefined) {
|
|
107
|
-
throw new Error();
|
|
108
|
-
}
|
|
109
|
-
styles[dep.url] = css;
|
|
110
|
-
} catch {
|
|
111
|
-
console.warn(`Could not load ${dep.file}`);
|
|
112
|
-
// this can happen with dynamically imported modules, I think
|
|
113
|
-
// because the Vite module graph doesn't distinguish between
|
|
114
|
-
// static and dynamic imports? TODO investigate, submit fix
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return Object.entries(styles).map(([fileName, css], i) => [`\n/* ${fileName
|
|
119
|
-
// Escape comment syntax in file paths
|
|
120
|
-
.replace(/\/\*/g, "/\\*").replace(/\*\//g, "*\\/")} */`, css]).flat().join("\n") || undefined;
|
|
121
|
-
};
|
|
122
|
-
const findDeps = async (vite, node, deps) => {
|
|
123
|
-
// since `ssrTransformResult.deps` contains URLs instead of `ModuleNode`s, this process is asynchronous.
|
|
124
|
-
// instead of using `await`, we resolve all branches in parallel.
|
|
125
|
-
let branches = [];
|
|
126
|
-
async function addFromNode(node) {
|
|
127
|
-
if (!deps.has(node)) {
|
|
128
|
-
deps.add(node);
|
|
129
|
-
await findDeps(vite, node, deps);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
async function addFromUrl(url) {
|
|
133
|
-
let node = await vite.moduleGraph.getModuleByUrl(url);
|
|
134
|
-
if (node) {
|
|
135
|
-
await addFromNode(node);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
if (node.ssrTransformResult) {
|
|
139
|
-
if (node.ssrTransformResult.deps) {
|
|
140
|
-
node.ssrTransformResult.deps.forEach(url => branches.push(addFromUrl(url)));
|
|
141
|
-
}
|
|
142
|
-
} else {
|
|
143
|
-
node.importedModules.forEach(node => branches.push(addFromNode(node)));
|
|
144
|
-
}
|
|
145
|
-
await Promise.all(branches);
|
|
146
|
-
};
|
|
147
|
-
const groupRoutesByParentId = manifest => {
|
|
148
|
-
let routes = {};
|
|
149
|
-
Object.values(manifest).forEach(route => {
|
|
150
|
-
if (route) {
|
|
151
|
-
let parentId = route.parentId || "";
|
|
152
|
-
if (!routes[parentId]) {
|
|
153
|
-
routes[parentId] = [];
|
|
154
|
-
}
|
|
155
|
-
routes[parentId].push(route);
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
return routes;
|
|
159
|
-
};
|
|
160
|
-
// Create a map of routes by parentId to use recursively instead of
|
|
161
|
-
// repeatedly filtering the manifest.
|
|
162
|
-
const createRoutes = (manifest, parentId = "", routesByParentId = groupRoutesByParentId(manifest)) => {
|
|
163
|
-
return (routesByParentId[parentId] || []).map(route => ({
|
|
164
|
-
...route,
|
|
165
|
-
children: createRoutes(manifest, route.id, routesByParentId)
|
|
166
|
-
}));
|
|
167
|
-
};
|
|
168
|
-
const getStylesForUrl = async ({
|
|
169
|
-
viteDevServer,
|
|
170
|
-
rootDirectory,
|
|
171
|
-
reactRouterConfig,
|
|
172
|
-
entryClientFilePath,
|
|
173
|
-
cssModulesManifest,
|
|
174
|
-
build,
|
|
175
|
-
url
|
|
176
|
-
}) => {
|
|
177
|
-
var _matchRoutes;
|
|
178
|
-
if (url === undefined || url.includes("?_data=")) {
|
|
179
|
-
return undefined;
|
|
180
|
-
}
|
|
181
|
-
let routes = createRoutes(build.routes);
|
|
182
|
-
let appPath = path__namespace.relative(process.cwd(), reactRouterConfig.appDirectory);
|
|
183
|
-
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))) ?? [];
|
|
184
|
-
let styles = await getStylesForFiles({
|
|
185
|
-
viteDevServer,
|
|
186
|
-
rootDirectory,
|
|
187
|
-
cssModulesManifest,
|
|
188
|
-
files: [
|
|
189
|
-
// Always include the client entry file when crawling the module graph for CSS
|
|
190
|
-
path__namespace.relative(rootDirectory, entryClientFilePath),
|
|
191
|
-
// Then include any styles from the matched routes
|
|
192
|
-
...documentRouteFiles]
|
|
193
|
-
});
|
|
194
|
-
return styles;
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
exports.getStylesForUrl = getStylesForUrl;
|
|
198
|
-
exports.isCssModulesFile = isCssModulesFile;
|
|
199
|
-
exports.isCssUrlWithoutSideEffects = isCssUrlWithoutSideEffects;
|
package/dist/vite/vite-node.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ViteNodeServer } from "vite-node/server";
|
|
2
|
-
import { ViteNodeRunner } from "vite-node/client";
|
|
3
|
-
import type * as Vite from "vite";
|
|
4
|
-
export type Context = {
|
|
5
|
-
devServer: Vite.ViteDevServer;
|
|
6
|
-
server: ViteNodeServer;
|
|
7
|
-
runner: ViteNodeRunner;
|
|
8
|
-
};
|
|
9
|
-
export declare function createContext(viteConfig?: Vite.InlineConfig): Promise<Context>;
|
package/dist/vite/vite-node.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @react-router/dev v7.0.0-pre.2
|
|
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 server = require('vite-node/server');
|
|
16
|
-
var client = require('vite-node/client');
|
|
17
|
-
var sourceMap = require('vite-node/source-map');
|
|
18
|
-
var importViteEsmSync = require('./import-vite-esm-sync.js');
|
|
19
|
-
|
|
20
|
-
async function createContext(viteConfig = {}) {
|
|
21
|
-
await importViteEsmSync.preloadViteEsm();
|
|
22
|
-
const vite = importViteEsmSync.importViteEsmSync();
|
|
23
|
-
const devServer = await vite.createServer(vite.mergeConfig({
|
|
24
|
-
server: {
|
|
25
|
-
preTransformRequests: false,
|
|
26
|
-
hmr: false
|
|
27
|
-
},
|
|
28
|
-
optimizeDeps: {
|
|
29
|
-
noDiscovery: true
|
|
30
|
-
},
|
|
31
|
-
configFile: false,
|
|
32
|
-
envFile: false,
|
|
33
|
-
plugins: []
|
|
34
|
-
}, viteConfig));
|
|
35
|
-
await devServer.pluginContainer.buildStart({});
|
|
36
|
-
const server$1 = new server.ViteNodeServer(devServer);
|
|
37
|
-
sourceMap.installSourcemapsSupport({
|
|
38
|
-
getSourceMap: source => server$1.getSourceMap(source)
|
|
39
|
-
});
|
|
40
|
-
const runner = new client.ViteNodeRunner({
|
|
41
|
-
root: devServer.config.root,
|
|
42
|
-
base: devServer.config.base,
|
|
43
|
-
fetchModule(id) {
|
|
44
|
-
return server$1.fetchModule(id);
|
|
45
|
-
},
|
|
46
|
-
resolveId(id, importer) {
|
|
47
|
-
return server$1.resolveId(id, importer);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
return {
|
|
51
|
-
devServer,
|
|
52
|
-
server: server$1,
|
|
53
|
-
runner
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
exports.createContext = createContext;
|
package/dist/vite/vmod.d.ts
DELETED
package/dist/vite/vmod.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @react-router/dev v7.0.0-pre.2
|
|
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;
|