feat: add safe project upgrades and production performance fixes

This commit is contained in:
2026-07-12 16:54:22 +05:30
parent a524c08126
commit 935b3103dd
68 changed files with 555 additions and 107 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@wrnexus/ssr",
"version": "0.2.13",
"version": "0.2.14",
"type": "module",
"main": "src/index.ts",
"exports": {
+5 -1
View File
@@ -55,8 +55,12 @@ export function renderDocument(opts: RenderOptions): string {
const extraHead = opts.extraHead ? `\n ${opts.extraHead}` : "";
const extraBody = opts.extraBody ? `\n ${opts.extraBody}` : "";
const htmlAttrs = /(?:^|\s)lang\s*=/.test(opts.htmlAttrs ?? "")
? (opts.htmlAttrs ?? "")
: `${opts.htmlAttrs ?? ""} lang="en"`;
return `<!doctype html>
<html${opts.htmlAttrs ?? ""}>
<html${htmlAttrs}>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
+13
View File
@@ -22,3 +22,16 @@ test("deduplicates runtime scripts and module preloads", () => {
expect(html.match(/rel="modulepreload"/g)).toHaveLength(1);
expect(html.match(/src="\/app\.js"/g)).toHaveLength(1);
});
test("always emits a document language and preserves an explicit language", () => {
const fallback = renderDocument({ meta: {}, body: "" });
expect(fallback).toContain('<html lang="en">');
const explicit = renderDocument({
meta: {},
body: "",
htmlAttrs: ' data-theme="dark" lang="fr"',
});
expect(explicit).toContain('<html data-theme="dark" lang="fr">');
expect(explicit).not.toContain('lang="en"');
});