@_linked/server 2.7.2 → 2.7.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
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @\_linked/server
|
|
2
2
|
|
|
3
|
+
## 2.7.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#57](https://github.com/linked-fw/server/pull/57) [`b47d50e`](https://github.com/linked-fw/server/commit/b47d50e818db8d0b7cbfba582213ea8cf2296a30) Thanks [@flyon](https://github.com/flyon)! - Match route `preloadChunks` against the Vite manifest case-insensitively, and warn when one resolves to nothing.
|
|
8
|
+
|
|
9
|
+
Apps carrying webpack-era lowercase chunk names (`['home', 'signin']`) matched nothing in a Vite manifest keyed by source path (`src/pages/Home.tsx`), so no preload tags were emitted at all — silently. Exact matching by source path and by path tail still wins; the case-insensitive basename match is only a fallback, anchored on the path separator so `home` cannot be answered by `MyHome.tsx`. An unresolved chunk name is now logged once per name, not once per request.
|
|
10
|
+
|
|
3
11
|
## 2.7.2
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -14,6 +14,8 @@ export type BundleManifest = Record<string, string | ViteManifestEntry | unknown
|
|
|
14
14
|
export declare const resolveRouteScript: (manifest: BundleManifest, chunkName: string, staticAccessURL: string) => string | null;
|
|
15
15
|
/** Resolve a route chunk's stylesheet URLs. */
|
|
16
16
|
export declare const resolveRouteStyles: (manifest: BundleManifest, chunkName: string, staticAccessURL: string) => string[];
|
|
17
|
+
/** Forget which chunk names have been warned about. For tests. */
|
|
18
|
+
export declare const resetUnresolvedChunkWarnings: () => void;
|
|
17
19
|
/** The preload URLs for every chunk a matched route asked for. */
|
|
18
20
|
export declare const resolveRouteAssets: (manifest: BundleManifest, chunkNames: string[], staticAccessURL: string) => {
|
|
19
21
|
scripts: string[];
|
|
@@ -12,12 +12,40 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { bundleAssetURL } from './releaseManifest.js';
|
|
14
14
|
const isAbsoluteURL = (value) => /^[a-z][a-z0-9+.-]*:\/\//i.test(value);
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Last-resort match for a chunk name whose casing does not line up with the
|
|
17
|
+
* manifest.
|
|
18
|
+
*
|
|
19
|
+
* Webpack named its chunks after the route (`home`, `signin`); Vite keys its
|
|
20
|
+
* manifest by source path (`src/pages/Home.tsx`). An app carrying the old
|
|
21
|
+
* lowercase `preloadChunks` therefore matched nothing at all. This compares the
|
|
22
|
+
* file's basename case-insensitively, anchored on the path separator so
|
|
23
|
+
* `Home` cannot be answered by `MyHome.tsx`.
|
|
24
|
+
*/
|
|
25
|
+
const caseInsensitiveEntryFor = (manifest, chunkName) => {
|
|
26
|
+
const lower = chunkName.toLowerCase();
|
|
27
|
+
const entry = Object.values(manifest).find((e) => {
|
|
28
|
+
const src = typeof (e === null || e === void 0 ? void 0 : e.src) === 'string' ? e.src.toLowerCase() : null;
|
|
29
|
+
if (!src)
|
|
30
|
+
return false;
|
|
31
|
+
return ['tsx', 'ts'].some((ext) => {
|
|
32
|
+
const name = `${lower}.${ext}`;
|
|
33
|
+
return src === name || src.endsWith(`/${name}`);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
return entry && typeof entry === 'object' ? entry : null;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Find the Vite manifest entry for a route chunk, by source path, by tail, or
|
|
40
|
+
* — only once both of those miss — by a case-insensitive basename.
|
|
41
|
+
*/
|
|
16
42
|
const viteEntryFor = (manifest, chunkName) => {
|
|
17
43
|
const direct = manifest[`src/pages/${chunkName}.tsx`] || manifest[`src/pages/${chunkName}.ts`];
|
|
18
44
|
const entry = direct ||
|
|
19
45
|
Object.values(manifest).find((e) => { var _a, _b; return ((_a = e === null || e === void 0 ? void 0 : e.src) === null || _a === void 0 ? void 0 : _a.endsWith(`${chunkName}.tsx`)) || ((_b = e === null || e === void 0 ? void 0 : e.src) === null || _b === void 0 ? void 0 : _b.endsWith(`${chunkName}.ts`)); });
|
|
20
|
-
|
|
46
|
+
if (entry && typeof entry === 'object')
|
|
47
|
+
return entry;
|
|
48
|
+
return caseInsensitiveEntryFor(manifest, chunkName);
|
|
21
49
|
};
|
|
22
50
|
/**
|
|
23
51
|
* Put a value taken from a webpack-shaped manifest on the asset base.
|
|
@@ -58,11 +86,46 @@ export const resolveRouteStyles = (manifest, chunkName, staticAccessURL) => {
|
|
|
58
86
|
? [webpackAssetURL(webpackCss, staticAccessURL)]
|
|
59
87
|
: [];
|
|
60
88
|
};
|
|
89
|
+
/**
|
|
90
|
+
* Chunk names already reported as unresolved.
|
|
91
|
+
*
|
|
92
|
+
* A route's `preloadChunks` are resolved on every render of that route, so a
|
|
93
|
+
* name the manifest does not know would otherwise warn on every request. One
|
|
94
|
+
* line per name is enough: the fix is in the app's source, not in this run.
|
|
95
|
+
*/
|
|
96
|
+
const warnedUnresolvedChunks = new Set();
|
|
97
|
+
/** Forget which chunk names have been warned about. For tests. */
|
|
98
|
+
export const resetUnresolvedChunkWarnings = () => {
|
|
99
|
+
warnedUnresolvedChunks.clear();
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Say so when a declared preload chunk resolves to nothing.
|
|
103
|
+
*
|
|
104
|
+
* Silence here is what let an app ship webpack-era lowercase `preloadChunks`
|
|
105
|
+
* against a Vite manifest and emit no preload tags at all, with nothing
|
|
106
|
+
* visibly broken.
|
|
107
|
+
*/
|
|
108
|
+
const warnUnresolvedChunk = (chunkName) => {
|
|
109
|
+
if (warnedUnresolvedChunks.has(chunkName))
|
|
110
|
+
return;
|
|
111
|
+
warnedUnresolvedChunks.add(chunkName);
|
|
112
|
+
console.warn(`[routeAssets] preloadChunk "${chunkName}" matched nothing in the bundle manifest — ` +
|
|
113
|
+
'no preload tags will be emitted for it. Check that the name matches the ' +
|
|
114
|
+
'page source file (Vite manifest keys look like "src/pages/Home.tsx").');
|
|
115
|
+
};
|
|
61
116
|
/** The preload URLs for every chunk a matched route asked for. */
|
|
62
|
-
export const resolveRouteAssets = (manifest, chunkNames, staticAccessURL) =>
|
|
63
|
-
scripts
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
117
|
+
export const resolveRouteAssets = (manifest, chunkNames, staticAccessURL) => {
|
|
118
|
+
const scripts = [];
|
|
119
|
+
const styles = [];
|
|
120
|
+
for (const chunkName of chunkNames) {
|
|
121
|
+
const script = resolveRouteScript(manifest, chunkName, staticAccessURL);
|
|
122
|
+
const chunkStyles = resolveRouteStyles(manifest, chunkName, staticAccessURL);
|
|
123
|
+
if (script)
|
|
124
|
+
scripts.push(script);
|
|
125
|
+
styles.push(...chunkStyles);
|
|
126
|
+
if (!script && chunkStyles.length === 0)
|
|
127
|
+
warnUnresolvedChunk(chunkName);
|
|
128
|
+
}
|
|
129
|
+
return { scripts, styles };
|
|
130
|
+
};
|
|
68
131
|
//# sourceMappingURL=routeAssets.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routeAssets.js","sourceRoot":"","sources":["../../../src/utils/routeAssets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAgBtD,MAAM,aAAa,GAAG,CAAC,KAAa,EAAW,EAAE,CAC/C,0BAA0B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAEzC,
|
|
1
|
+
{"version":3,"file":"routeAssets.js","sourceRoot":"","sources":["../../../src/utils/routeAssets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAgBtD,MAAM,aAAa,GAAG,CAAC,KAAa,EAAW,EAAE,CAC/C,0BAA0B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAEzC;;;;;;;;;GASG;AACH,MAAM,uBAAuB,GAAG,CAC9B,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