@tanstack/start-plugin-core 1.166.12 → 1.166.14
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/esm/build-sitemap.js +94 -123
- package/dist/esm/build-sitemap.js.map +1 -1
- package/dist/esm/constants.js +15 -20
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/dev-server-plugin/dev-styles.js +137 -150
- package/dist/esm/dev-server-plugin/dev-styles.js.map +1 -1
- package/dist/esm/dev-server-plugin/extract-html-scripts.js +16 -15
- package/dist/esm/dev-server-plugin/extract-html-scripts.js.map +1 -1
- package/dist/esm/dev-server-plugin/plugin.js +125 -195
- package/dist/esm/dev-server-plugin/plugin.js.map +1 -1
- package/dist/esm/import-protection-plugin/ast.js +6 -5
- package/dist/esm/import-protection-plugin/ast.js.map +1 -1
- package/dist/esm/import-protection-plugin/constants.js +20 -22
- package/dist/esm/import-protection-plugin/constants.js.map +1 -1
- package/dist/esm/import-protection-plugin/defaults.js +35 -25
- package/dist/esm/import-protection-plugin/defaults.js.map +1 -1
- package/dist/esm/import-protection-plugin/extensionlessAbsoluteIdResolver.js +93 -92
- package/dist/esm/import-protection-plugin/extensionlessAbsoluteIdResolver.js.map +1 -1
- package/dist/esm/import-protection-plugin/matchers.js +23 -24
- package/dist/esm/import-protection-plugin/matchers.js.map +1 -1
- package/dist/esm/import-protection-plugin/plugin.js +1045 -1361
- package/dist/esm/import-protection-plugin/plugin.js.map +1 -1
- package/dist/esm/import-protection-plugin/postCompileUsage.js +58 -55
- package/dist/esm/import-protection-plugin/postCompileUsage.js.map +1 -1
- package/dist/esm/import-protection-plugin/rewriteDeniedImports.js +187 -259
- package/dist/esm/import-protection-plugin/rewriteDeniedImports.js.map +1 -1
- package/dist/esm/import-protection-plugin/sourceLocation.js +238 -248
- package/dist/esm/import-protection-plugin/sourceLocation.js.map +1 -1
- package/dist/esm/import-protection-plugin/trace.js +173 -184
- package/dist/esm/import-protection-plugin/trace.js.map +1 -1
- package/dist/esm/import-protection-plugin/utils.js +132 -111
- package/dist/esm/import-protection-plugin/utils.js.map +1 -1
- package/dist/esm/import-protection-plugin/virtualModules.js +216 -196
- package/dist/esm/import-protection-plugin/virtualModules.js.map +1 -1
- package/dist/esm/index.js +2 -7
- package/dist/esm/load-env-plugin/plugin.js +12 -11
- package/dist/esm/load-env-plugin/plugin.js.map +1 -1
- package/dist/esm/output-directory.js +10 -10
- package/dist/esm/output-directory.js.map +1 -1
- package/dist/esm/plugin.js +275 -355
- package/dist/esm/plugin.js.map +1 -1
- package/dist/esm/post-server-build.js +39 -53
- package/dist/esm/post-server-build.js.map +1 -1
- package/dist/esm/prerender.js +177 -239
- package/dist/esm/prerender.js.map +1 -1
- package/dist/esm/preview-server-plugin/plugin.js +41 -44
- package/dist/esm/preview-server-plugin/plugin.js.map +1 -1
- package/dist/esm/queue.js +115 -126
- package/dist/esm/queue.js.map +1 -1
- package/dist/esm/resolve-entries.js +31 -32
- package/dist/esm/resolve-entries.js.map +1 -1
- package/dist/esm/schema.js +156 -179
- package/dist/esm/schema.js.map +1 -1
- package/dist/esm/start-compiler-plugin/compiler.js +655 -812
- package/dist/esm/start-compiler-plugin/compiler.js.map +1 -1
- package/dist/esm/start-compiler-plugin/handleClientOnlyJSX.js +25 -8
- package/dist/esm/start-compiler-plugin/handleClientOnlyJSX.js.map +1 -1
- package/dist/esm/start-compiler-plugin/handleCreateIsomorphicFn.js +22 -19
- package/dist/esm/start-compiler-plugin/handleCreateIsomorphicFn.js.map +1 -1
- package/dist/esm/start-compiler-plugin/handleCreateMiddleware.js +20 -22
- package/dist/esm/start-compiler-plugin/handleCreateMiddleware.js.map +1 -1
- package/dist/esm/start-compiler-plugin/handleCreateServerFn.js +187 -255
- package/dist/esm/start-compiler-plugin/handleCreateServerFn.js.map +1 -1
- package/dist/esm/start-compiler-plugin/handleEnvOnly.js +23 -33
- package/dist/esm/start-compiler-plugin/handleEnvOnly.js.map +1 -1
- package/dist/esm/start-compiler-plugin/plugin.js +247 -291
- package/dist/esm/start-compiler-plugin/plugin.js.map +1 -1
- package/dist/esm/start-compiler-plugin/utils.js +27 -27
- package/dist/esm/start-compiler-plugin/utils.js.map +1 -1
- package/dist/esm/start-manifest-plugin/manifestBuilder.js +272 -378
- package/dist/esm/start-manifest-plugin/manifestBuilder.js.map +1 -1
- package/dist/esm/start-manifest-plugin/plugin.js +35 -44
- package/dist/esm/start-manifest-plugin/plugin.js.map +1 -1
- package/dist/esm/start-router-plugin/constants.js +6 -5
- package/dist/esm/start-router-plugin/constants.js.map +1 -1
- package/dist/esm/start-router-plugin/generator-plugins/prerender-routes-plugin.js +24 -19
- package/dist/esm/start-router-plugin/generator-plugins/prerender-routes-plugin.js.map +1 -1
- package/dist/esm/start-router-plugin/generator-plugins/routes-manifest-plugin.js +28 -29
- package/dist/esm/start-router-plugin/generator-plugins/routes-manifest-plugin.js.map +1 -1
- package/dist/esm/start-router-plugin/plugin.js +146 -199
- package/dist/esm/start-router-plugin/plugin.js.map +1 -1
- package/dist/esm/start-router-plugin/pruneServerOnlySubtrees.js +32 -31
- package/dist/esm/start-router-plugin/pruneServerOnlySubtrees.js.map +1 -1
- package/dist/esm/utils.js +14 -14
- package/dist/esm/utils.js.map +1 -1
- package/package.json +7 -7
- package/dist/esm/index.js.map +0 -1
|
@@ -1,404 +1,298 @@
|
|
|
1
|
-
import { joinURL } from "ufo";
|
|
2
1
|
import { rootRouteId } from "@tanstack/router-core";
|
|
2
|
+
import { joinURL } from "ufo";
|
|
3
3
|
import { tsrSplit } from "@tanstack/router-plugin";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
//#region src/start-manifest-plugin/manifestBuilder.ts
|
|
5
|
+
var ROUTER_MANAGED_MODE = 1;
|
|
6
|
+
var NON_ROUTE_DYNAMIC_MODE = 2;
|
|
7
|
+
var VISITING_CHUNK = 1;
|
|
7
8
|
function appendUniqueStrings(target, source) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
seen.add(value);
|
|
21
|
-
if (!result) {
|
|
22
|
-
result = target.slice();
|
|
23
|
-
}
|
|
24
|
-
result.push(value);
|
|
25
|
-
}
|
|
26
|
-
return result ?? target;
|
|
9
|
+
if (source.length === 0) return target;
|
|
10
|
+
if (!target || target.length === 0) return source;
|
|
11
|
+
const seen = new Set(target);
|
|
12
|
+
let result;
|
|
13
|
+
for (const value of source) {
|
|
14
|
+
if (seen.has(value)) continue;
|
|
15
|
+
seen.add(value);
|
|
16
|
+
if (!result) result = target.slice();
|
|
17
|
+
result.push(value);
|
|
18
|
+
}
|
|
19
|
+
return result ?? target;
|
|
27
20
|
}
|
|
28
21
|
function appendUniqueAssets(target, source) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
seen.add(identity);
|
|
43
|
-
if (!result) {
|
|
44
|
-
result = target.slice();
|
|
45
|
-
}
|
|
46
|
-
result.push(asset);
|
|
47
|
-
}
|
|
48
|
-
return result ?? target;
|
|
22
|
+
if (source.length === 0) return target;
|
|
23
|
+
if (!target || target.length === 0) return source;
|
|
24
|
+
const seen = new Set(target.map(getAssetIdentity));
|
|
25
|
+
let result;
|
|
26
|
+
for (const asset of source) {
|
|
27
|
+
const identity = getAssetIdentity(asset);
|
|
28
|
+
if (seen.has(identity)) continue;
|
|
29
|
+
seen.add(identity);
|
|
30
|
+
if (!result) result = target.slice();
|
|
31
|
+
result.push(asset);
|
|
32
|
+
}
|
|
33
|
+
return result ?? target;
|
|
49
34
|
}
|
|
50
35
|
function getAssetIdentity(asset) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
36
|
+
if (asset.tag === "link" || asset.tag === "script") {
|
|
37
|
+
const attrs = asset.attrs ?? {};
|
|
38
|
+
return [
|
|
39
|
+
asset.tag,
|
|
40
|
+
"href" in attrs ? String(attrs.href) : "",
|
|
41
|
+
"src" in attrs ? String(attrs.src) : "",
|
|
42
|
+
"rel" in attrs ? String(attrs.rel) : "",
|
|
43
|
+
"type" in attrs ? String(attrs.type) : "",
|
|
44
|
+
asset.children ?? ""
|
|
45
|
+
].join("|");
|
|
46
|
+
}
|
|
47
|
+
return JSON.stringify(asset);
|
|
63
48
|
}
|
|
64
49
|
function mergeRouteChunkData(options) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
options.route.preloads,
|
|
70
|
-
chunkPreloads
|
|
71
|
-
);
|
|
50
|
+
const chunkAssets = options.getChunkCssAssets(options.chunk);
|
|
51
|
+
const chunkPreloads = options.getChunkPreloads(options.chunk);
|
|
52
|
+
options.route.assets = appendUniqueAssets(options.route.assets, chunkAssets);
|
|
53
|
+
options.route.preloads = appendUniqueStrings(options.route.preloads, chunkPreloads);
|
|
72
54
|
}
|
|
73
55
|
function buildStartManifest(options) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return {
|
|
101
|
-
routes,
|
|
102
|
-
clientEntry: assetResolvers.getAssetPath(scannedChunks.entryChunk.fileName)
|
|
103
|
-
};
|
|
56
|
+
const scannedChunks = scanClientChunks(options.clientBundle);
|
|
57
|
+
const hashedCssFiles = collectDynamicImportCss(scannedChunks.routeEntryChunks, scannedChunks.chunksByFileName, scannedChunks.entryChunk);
|
|
58
|
+
const assetResolvers = createManifestAssetResolvers({
|
|
59
|
+
basePath: options.basePath,
|
|
60
|
+
hashedCssFiles
|
|
61
|
+
});
|
|
62
|
+
const routes = buildRouteManifestRoutes({
|
|
63
|
+
routeTreeRoutes: options.routeTreeRoutes,
|
|
64
|
+
routeChunksByFilePath: scannedChunks.routeChunksByFilePath,
|
|
65
|
+
chunksByFileName: scannedChunks.chunksByFileName,
|
|
66
|
+
entryChunk: scannedChunks.entryChunk,
|
|
67
|
+
assetResolvers
|
|
68
|
+
});
|
|
69
|
+
dedupeNestedRoutePreloads(routes[rootRouteId], routes);
|
|
70
|
+
for (const routeId of Object.keys(routes)) {
|
|
71
|
+
const route = routes[routeId];
|
|
72
|
+
const hasAssets = route.assets && route.assets.length > 0;
|
|
73
|
+
const hasPreloads = route.preloads && route.preloads.length > 0;
|
|
74
|
+
if (!hasAssets && !hasPreloads) delete routes[routeId];
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
routes,
|
|
78
|
+
clientEntry: assetResolvers.getAssetPath(scannedChunks.entryChunk.fileName)
|
|
79
|
+
};
|
|
104
80
|
}
|
|
105
81
|
function scanClientChunks(clientBundle) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
if (!entryChunk) {
|
|
140
|
-
throw new Error("No entry file found");
|
|
141
|
-
}
|
|
142
|
-
return {
|
|
143
|
-
entryChunk,
|
|
144
|
-
chunksByFileName,
|
|
145
|
-
routeChunksByFilePath,
|
|
146
|
-
routeEntryChunks
|
|
147
|
-
};
|
|
82
|
+
let entryChunk;
|
|
83
|
+
const chunksByFileName = /* @__PURE__ */ new Map();
|
|
84
|
+
const routeChunksByFilePath = /* @__PURE__ */ new Map();
|
|
85
|
+
const routeEntryChunks = /* @__PURE__ */ new Set();
|
|
86
|
+
for (const fileName in clientBundle) {
|
|
87
|
+
const bundleEntry = clientBundle[fileName];
|
|
88
|
+
if (bundleEntry.type !== "chunk") continue;
|
|
89
|
+
chunksByFileName.set(bundleEntry.fileName, bundleEntry);
|
|
90
|
+
if (bundleEntry.isEntry) {
|
|
91
|
+
if (entryChunk) throw new Error(`multiple entries detected: ${entryChunk.fileName} ${bundleEntry.fileName}`);
|
|
92
|
+
entryChunk = bundleEntry;
|
|
93
|
+
}
|
|
94
|
+
const routeFilePaths = getRouteFilePathsFromModuleIds(bundleEntry.moduleIds);
|
|
95
|
+
if (routeFilePaths.length === 0) continue;
|
|
96
|
+
routeEntryChunks.add(bundleEntry);
|
|
97
|
+
for (let i = 0; i < routeFilePaths.length; i++) {
|
|
98
|
+
const routeFilePath = routeFilePaths[i];
|
|
99
|
+
let chunks = routeChunksByFilePath.get(routeFilePath);
|
|
100
|
+
if (chunks === void 0) {
|
|
101
|
+
chunks = [];
|
|
102
|
+
routeChunksByFilePath.set(routeFilePath, chunks);
|
|
103
|
+
}
|
|
104
|
+
chunks.push(bundleEntry);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (!entryChunk) throw new Error("No entry file found");
|
|
108
|
+
return {
|
|
109
|
+
entryChunk,
|
|
110
|
+
chunksByFileName,
|
|
111
|
+
routeChunksByFilePath,
|
|
112
|
+
routeEntryChunks
|
|
113
|
+
};
|
|
148
114
|
}
|
|
149
115
|
function getRouteFilePathsFromModuleIds(moduleIds) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
if (routeFilePaths === void 0) {
|
|
169
|
-
routeFilePaths = [];
|
|
170
|
-
seenRouteFilePaths = /* @__PURE__ */ new Set();
|
|
171
|
-
}
|
|
172
|
-
routeFilePaths.push(routeFilePath);
|
|
173
|
-
seenRouteFilePaths.add(routeFilePath);
|
|
174
|
-
}
|
|
175
|
-
return routeFilePaths ?? [];
|
|
116
|
+
let routeFilePaths;
|
|
117
|
+
let seenRouteFilePaths;
|
|
118
|
+
for (const moduleId of moduleIds) {
|
|
119
|
+
const queryIndex = moduleId.indexOf("?");
|
|
120
|
+
if (queryIndex < 0) continue;
|
|
121
|
+
const query = moduleId.slice(queryIndex + 1);
|
|
122
|
+
if (!query.includes(tsrSplit)) continue;
|
|
123
|
+
if (!new URLSearchParams(query).has(tsrSplit)) continue;
|
|
124
|
+
const routeFilePath = moduleId.slice(0, queryIndex);
|
|
125
|
+
if (seenRouteFilePaths?.has(routeFilePath)) continue;
|
|
126
|
+
if (routeFilePaths === void 0) {
|
|
127
|
+
routeFilePaths = [];
|
|
128
|
+
seenRouteFilePaths = /* @__PURE__ */ new Set();
|
|
129
|
+
}
|
|
130
|
+
routeFilePaths.push(routeFilePath);
|
|
131
|
+
seenRouteFilePaths.add(routeFilePath);
|
|
132
|
+
}
|
|
133
|
+
return routeFilePaths ?? [];
|
|
176
134
|
}
|
|
177
135
|
function collectDynamicImportCss(routeEntryChunks, chunksByFileName, entryChunk) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
for (let i = 0; i < chunk.dynamicImports.length; i++) {
|
|
218
|
-
const dynamicImportedChunk = chunksByFileName.get(
|
|
219
|
-
chunk.dynamicImports[i]
|
|
220
|
-
);
|
|
221
|
-
if (dynamicImportedChunk) {
|
|
222
|
-
chunkStack.push(dynamicImportedChunk);
|
|
223
|
-
modeStack.push(
|
|
224
|
-
(mode & NON_ROUTE_DYNAMIC_MODE) !== 0 || !routeEntryChunks.has(dynamicImportedChunk) ? NON_ROUTE_DYNAMIC_MODE : ROUTER_MANAGED_MODE
|
|
225
|
-
);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
for (const cssFile of routerManagedCssFiles) {
|
|
230
|
-
if (nonRouteDynamicCssFiles.has(cssFile)) {
|
|
231
|
-
hashedCssFiles.add(cssFile);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
return hashedCssFiles;
|
|
136
|
+
const routerManagedCssFiles = /* @__PURE__ */ new Set();
|
|
137
|
+
const nonRouteDynamicCssFiles = /* @__PURE__ */ new Set();
|
|
138
|
+
const hashedCssFiles = /* @__PURE__ */ new Set();
|
|
139
|
+
const visitedByChunk = /* @__PURE__ */ new Map();
|
|
140
|
+
const chunkStack = [];
|
|
141
|
+
const modeStack = [];
|
|
142
|
+
for (const routeEntryChunk of routeEntryChunks) {
|
|
143
|
+
chunkStack.push(routeEntryChunk);
|
|
144
|
+
modeStack.push(ROUTER_MANAGED_MODE);
|
|
145
|
+
}
|
|
146
|
+
if (entryChunk) {
|
|
147
|
+
chunkStack.push(entryChunk);
|
|
148
|
+
modeStack.push(ROUTER_MANAGED_MODE);
|
|
149
|
+
}
|
|
150
|
+
while (chunkStack.length > 0) {
|
|
151
|
+
const chunk = chunkStack.pop();
|
|
152
|
+
const mode = modeStack.pop();
|
|
153
|
+
const previousMode = visitedByChunk.get(chunk) ?? 0;
|
|
154
|
+
if ((previousMode & mode) === mode) continue;
|
|
155
|
+
visitedByChunk.set(chunk, previousMode | mode);
|
|
156
|
+
if ((mode & ROUTER_MANAGED_MODE) !== 0) for (const cssFile of chunk.viteMetadata?.importedCss ?? []) routerManagedCssFiles.add(cssFile);
|
|
157
|
+
if ((mode & NON_ROUTE_DYNAMIC_MODE) !== 0) for (const cssFile of chunk.viteMetadata?.importedCss ?? []) nonRouteDynamicCssFiles.add(cssFile);
|
|
158
|
+
for (let i = 0; i < chunk.imports.length; i++) {
|
|
159
|
+
const importedChunk = chunksByFileName.get(chunk.imports[i]);
|
|
160
|
+
if (importedChunk) {
|
|
161
|
+
chunkStack.push(importedChunk);
|
|
162
|
+
modeStack.push(mode);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
for (let i = 0; i < chunk.dynamicImports.length; i++) {
|
|
166
|
+
const dynamicImportedChunk = chunksByFileName.get(chunk.dynamicImports[i]);
|
|
167
|
+
if (dynamicImportedChunk) {
|
|
168
|
+
chunkStack.push(dynamicImportedChunk);
|
|
169
|
+
modeStack.push((mode & NON_ROUTE_DYNAMIC_MODE) !== 0 || !routeEntryChunks.has(dynamicImportedChunk) ? NON_ROUTE_DYNAMIC_MODE : ROUTER_MANAGED_MODE);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
for (const cssFile of routerManagedCssFiles) if (nonRouteDynamicCssFiles.has(cssFile)) hashedCssFiles.add(cssFile);
|
|
174
|
+
return hashedCssFiles;
|
|
235
175
|
}
|
|
236
176
|
function createManifestAssetResolvers(options) {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
preloadsByChunk.set(chunk, preloads);
|
|
276
|
-
return preloads;
|
|
277
|
-
};
|
|
278
|
-
return {
|
|
279
|
-
getAssetPath,
|
|
280
|
-
getChunkPreloads,
|
|
281
|
-
getStylesheetAsset
|
|
282
|
-
};
|
|
177
|
+
const assetPathByFileName = /* @__PURE__ */ new Map();
|
|
178
|
+
const stylesheetAssetByFileName = /* @__PURE__ */ new Map();
|
|
179
|
+
const preloadsByChunk = /* @__PURE__ */ new Map();
|
|
180
|
+
const getAssetPath = (fileName) => {
|
|
181
|
+
const cachedPath = assetPathByFileName.get(fileName);
|
|
182
|
+
if (cachedPath) return cachedPath;
|
|
183
|
+
const assetPath = joinURL(options.basePath, fileName);
|
|
184
|
+
assetPathByFileName.set(fileName, assetPath);
|
|
185
|
+
return assetPath;
|
|
186
|
+
};
|
|
187
|
+
const getStylesheetAsset = (cssFile) => {
|
|
188
|
+
const cachedAsset = stylesheetAssetByFileName.get(cssFile);
|
|
189
|
+
if (cachedAsset) return cachedAsset;
|
|
190
|
+
const href = getAssetPath(cssFile);
|
|
191
|
+
const asset = {
|
|
192
|
+
tag: "link",
|
|
193
|
+
attrs: {
|
|
194
|
+
rel: "stylesheet",
|
|
195
|
+
href: options.hashedCssFiles?.has(cssFile) ? `${href}#` : href,
|
|
196
|
+
type: "text/css"
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
stylesheetAssetByFileName.set(cssFile, asset);
|
|
200
|
+
return asset;
|
|
201
|
+
};
|
|
202
|
+
const getChunkPreloads = (chunk) => {
|
|
203
|
+
const cachedPreloads = preloadsByChunk.get(chunk);
|
|
204
|
+
if (cachedPreloads) return cachedPreloads;
|
|
205
|
+
const preloads = [getAssetPath(chunk.fileName)];
|
|
206
|
+
for (let i = 0; i < chunk.imports.length; i++) preloads.push(getAssetPath(chunk.imports[i]));
|
|
207
|
+
preloadsByChunk.set(chunk, preloads);
|
|
208
|
+
return preloads;
|
|
209
|
+
};
|
|
210
|
+
return {
|
|
211
|
+
getAssetPath,
|
|
212
|
+
getChunkPreloads,
|
|
213
|
+
getStylesheetAsset
|
|
214
|
+
};
|
|
283
215
|
}
|
|
284
216
|
function createChunkCssAssetCollector(options) {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
const importedAssets = getChunkCssAssets(importedChunk);
|
|
306
|
-
for (let j = 0; j < importedAssets.length; j++) {
|
|
307
|
-
assets.push(importedAssets[j]);
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
stateByChunk.delete(chunk);
|
|
311
|
-
assetsByChunk.set(chunk, assets);
|
|
312
|
-
return assets;
|
|
313
|
-
};
|
|
314
|
-
return { getChunkCssAssets };
|
|
217
|
+
const assetsByChunk = /* @__PURE__ */ new Map();
|
|
218
|
+
const stateByChunk = /* @__PURE__ */ new Map();
|
|
219
|
+
const getChunkCssAssets = (chunk) => {
|
|
220
|
+
const cachedAssets = assetsByChunk.get(chunk);
|
|
221
|
+
if (cachedAssets) return cachedAssets;
|
|
222
|
+
if (stateByChunk.get(chunk) === VISITING_CHUNK) return [];
|
|
223
|
+
stateByChunk.set(chunk, VISITING_CHUNK);
|
|
224
|
+
const assets = [];
|
|
225
|
+
for (const cssFile of chunk.viteMetadata?.importedCss ?? []) assets.push(options.getStylesheetAsset(cssFile));
|
|
226
|
+
for (let i = 0; i < chunk.imports.length; i++) {
|
|
227
|
+
const importedChunk = options.chunksByFileName.get(chunk.imports[i]);
|
|
228
|
+
if (!importedChunk) continue;
|
|
229
|
+
const importedAssets = getChunkCssAssets(importedChunk);
|
|
230
|
+
for (let j = 0; j < importedAssets.length; j++) assets.push(importedAssets[j]);
|
|
231
|
+
}
|
|
232
|
+
stateByChunk.delete(chunk);
|
|
233
|
+
assetsByChunk.set(chunk, assets);
|
|
234
|
+
return assets;
|
|
235
|
+
};
|
|
236
|
+
return { getChunkCssAssets };
|
|
315
237
|
}
|
|
316
238
|
function buildRouteManifestRoutes(options) {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
getChunkPreloads: options.assetResolvers.getChunkPreloads
|
|
352
|
-
});
|
|
353
|
-
return routes;
|
|
239
|
+
const routes = {};
|
|
240
|
+
const getChunkCssAssets = createChunkCssAssetCollector({
|
|
241
|
+
chunksByFileName: options.chunksByFileName,
|
|
242
|
+
getStylesheetAsset: options.assetResolvers.getStylesheetAsset
|
|
243
|
+
}).getChunkCssAssets;
|
|
244
|
+
for (const [routeId, route] of Object.entries(options.routeTreeRoutes)) {
|
|
245
|
+
if (!route.filePath) {
|
|
246
|
+
if (routeId === rootRouteId) {
|
|
247
|
+
routes[routeId] = route;
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
throw new Error(`expected filePath to be set for ${routeId}`);
|
|
251
|
+
}
|
|
252
|
+
const chunks = options.routeChunksByFilePath.get(route.filePath);
|
|
253
|
+
if (!chunks) {
|
|
254
|
+
routes[routeId] = route;
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
const existing = routes[routeId];
|
|
258
|
+
const targetRoute = routes[routeId] = existing ? existing : { ...route };
|
|
259
|
+
for (const chunk of chunks) mergeRouteChunkData({
|
|
260
|
+
route: targetRoute,
|
|
261
|
+
chunk,
|
|
262
|
+
getChunkCssAssets,
|
|
263
|
+
getChunkPreloads: options.assetResolvers.getChunkPreloads
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
mergeRouteChunkData({
|
|
267
|
+
route: routes[rootRouteId] = routes[rootRouteId] || {},
|
|
268
|
+
chunk: options.entryChunk,
|
|
269
|
+
getChunkCssAssets,
|
|
270
|
+
getChunkPreloads: options.assetResolvers.getChunkPreloads
|
|
271
|
+
});
|
|
272
|
+
return routes;
|
|
354
273
|
}
|
|
355
274
|
function dedupeNestedRoutePreloads(route, routesById, seenPreloads = /* @__PURE__ */ new Set()) {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
if (route.children) {
|
|
378
|
-
for (const childRouteId of route.children) {
|
|
379
|
-
dedupeNestedRoutePreloads(
|
|
380
|
-
routesById[childRouteId],
|
|
381
|
-
routesById,
|
|
382
|
-
seenPreloads
|
|
383
|
-
);
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
if (routePreloads) {
|
|
387
|
-
for (let i = routePreloads.length - 1; i >= 0; i--) {
|
|
388
|
-
seenPreloads.delete(routePreloads[i]);
|
|
389
|
-
}
|
|
390
|
-
}
|
|
275
|
+
let routePreloads = route.preloads;
|
|
276
|
+
if (routePreloads && routePreloads.length > 0) {
|
|
277
|
+
let dedupedPreloads;
|
|
278
|
+
for (let i = 0; i < routePreloads.length; i++) {
|
|
279
|
+
const preload = routePreloads[i];
|
|
280
|
+
if (seenPreloads.has(preload)) {
|
|
281
|
+
if (dedupedPreloads === void 0) dedupedPreloads = routePreloads.slice(0, i);
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
seenPreloads.add(preload);
|
|
285
|
+
if (dedupedPreloads) dedupedPreloads.push(preload);
|
|
286
|
+
}
|
|
287
|
+
if (dedupedPreloads) {
|
|
288
|
+
routePreloads = dedupedPreloads;
|
|
289
|
+
route.preloads = dedupedPreloads;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
if (route.children) for (const childRouteId of route.children) dedupeNestedRoutePreloads(routesById[childRouteId], routesById, seenPreloads);
|
|
293
|
+
if (routePreloads) for (let i = routePreloads.length - 1; i >= 0; i--) seenPreloads.delete(routePreloads[i]);
|
|
391
294
|
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
buildStartManifest,
|
|
397
|
-
collectDynamicImportCss,
|
|
398
|
-
createChunkCssAssetCollector,
|
|
399
|
-
createManifestAssetResolvers,
|
|
400
|
-
dedupeNestedRoutePreloads,
|
|
401
|
-
getRouteFilePathsFromModuleIds,
|
|
402
|
-
scanClientChunks
|
|
403
|
-
};
|
|
404
|
-
//# sourceMappingURL=manifestBuilder.js.map
|
|
295
|
+
//#endregion
|
|
296
|
+
export { buildStartManifest };
|
|
297
|
+
|
|
298
|
+
//# sourceMappingURL=manifestBuilder.js.map
|