@stati/core 1.23.2 → 1.23.4
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/core/dev.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/core/dev.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAe,MAAM,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/core/dev.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAe,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAoC7D,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;CACb;AAybD,wBAAsB,eAAe,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,SAAS,CAAC,CAqgBxF"}
|
package/dist/core/dev.js
CHANGED
|
@@ -6,6 +6,8 @@ import chokidar from 'chokidar';
|
|
|
6
6
|
import { build } from './build.js';
|
|
7
7
|
import { invalidate } from './invalidate.js';
|
|
8
8
|
import { loadConfig } from '../config/loader.js';
|
|
9
|
+
import { clearTemplateEngineCache } from './templates.js';
|
|
10
|
+
import { clearMarkdownProcessorCache } from './markdown.js';
|
|
9
11
|
import { loadCacheManifest, saveCacheManifest, computeNavigationHash, DevServerLockManager, } from './isg/index.js';
|
|
10
12
|
import { loadContent } from './content.js';
|
|
11
13
|
import { buildNavigation } from './navigation.js';
|
|
@@ -217,6 +219,10 @@ async function performIncrementalRebuild(changedPath, eventType, configPath, sta
|
|
|
217
219
|
async function handleTemplateChange(templatePath, configPath, logger) {
|
|
218
220
|
const cacheDir = resolveCacheDir();
|
|
219
221
|
try {
|
|
222
|
+
// Drop the cached Eta engine so the changed template (and any compiled partials)
|
|
223
|
+
// are recompiled on the next build. This keeps rebuilds correct while still
|
|
224
|
+
// reusing the engine across the common markdown-only edit path.
|
|
225
|
+
clearTemplateEngineCache();
|
|
220
226
|
// Load existing cache manifest
|
|
221
227
|
const cacheManifest = await loadCacheManifest(cacheDir);
|
|
222
228
|
if (!cacheManifest) {
|
|
@@ -782,6 +788,9 @@ export async function createDevServer(options = {}) {
|
|
|
782
788
|
});
|
|
783
789
|
httpServer = null;
|
|
784
790
|
}
|
|
791
|
+
// Release cached dev-session engines so they can be garbage collected
|
|
792
|
+
clearTemplateEngineCache();
|
|
793
|
+
clearMarkdownProcessorCache();
|
|
785
794
|
logger.info?.('Dev server stopped');
|
|
786
795
|
},
|
|
787
796
|
};
|
package/dist/core/templates.d.ts
CHANGED
|
@@ -9,6 +9,11 @@ export interface RenderResult {
|
|
|
9
9
|
/** Number of templates loaded (layout + partials) */
|
|
10
10
|
templatesLoaded: number;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Clear the cached template engine. Call this when templates change in dev mode
|
|
14
|
+
* so the next build recompiles them, or when shutting down a dev session.
|
|
15
|
+
*/
|
|
16
|
+
export declare function clearTemplateEngineCache(): void;
|
|
12
17
|
export declare function createTemplateEngine(config: StatiConfig): Eta;
|
|
13
18
|
export declare function renderPage(page: PageModel, body: string, config: StatiConfig, eta: Eta, navigation?: NavNode[], allPages?: PageModel[], assets?: import('../types/index.js').StatiAssets, toc?: TocEntry[], logger?: Logger): Promise<RenderResult>;
|
|
14
19
|
//# sourceMappingURL=templates.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/core/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAG1B,OAAO,KAAK,EACV,WAAW,EACX,SAAS,EACT,OAAO,EAEP,QAAQ,EACR,MAAM,EACP,MAAM,mBAAmB,CAAC;AAkB3B;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,eAAe,EAAE,MAAM,CAAC;CACzB;
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/core/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAG1B,OAAO,KAAK,EACV,WAAW,EACX,SAAS,EACT,OAAO,EAEP,QAAQ,EACR,MAAM,EACP,MAAM,mBAAmB,CAAC;AAkB3B;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,eAAe,EAAE,MAAM,CAAC;CACzB;AAgND;;;GAGG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAE/C;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,WAAW,GAAG,GAAG,CAwB7D;AAED,wBAAsB,UAAU,CAC9B,IAAI,EAAE,SAAS,EACf,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,EACnB,GAAG,EAAE,GAAG,EACR,UAAU,CAAC,EAAE,OAAO,EAAE,EACtB,QAAQ,CAAC,EAAE,SAAS,EAAE,EACtB,MAAM,CAAC,EAAE,OAAO,mBAAmB,EAAE,WAAW,EAChD,GAAG,CAAC,EAAE,QAAQ,EAAE,EAChB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,YAAY,CAAC,CAuMvB"}
|
package/dist/core/templates.js
CHANGED
|
@@ -173,14 +173,43 @@ async function discoverPartials(pagePath, config) {
|
|
|
173
173
|
}
|
|
174
174
|
return partials;
|
|
175
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* Cached template engine for dev mode to avoid re-creating on each rebuild.
|
|
178
|
+
*
|
|
179
|
+
* Recreating the Eta instance and recompiling every template on each dev rebuild
|
|
180
|
+
* generates large transient native allocations that the V8 allocator does not
|
|
181
|
+
* return to the OS, causing monotonic RSS growth and increasing rebuild times
|
|
182
|
+
* over a long dev session. Reusing a single instance (with template caching on)
|
|
183
|
+
* keeps rebuild cost flat. The cache is keyed by template directory so a config
|
|
184
|
+
* change pointing to a different srcDir still produces a fresh engine.
|
|
185
|
+
*/
|
|
186
|
+
let cachedTemplateEngine = null;
|
|
187
|
+
/**
|
|
188
|
+
* Clear the cached template engine. Call this when templates change in dev mode
|
|
189
|
+
* so the next build recompiles them, or when shutting down a dev session.
|
|
190
|
+
*/
|
|
191
|
+
export function clearTemplateEngineCache() {
|
|
192
|
+
cachedTemplateEngine = null;
|
|
193
|
+
}
|
|
176
194
|
export function createTemplateEngine(config) {
|
|
177
195
|
const templateDir = resolveSrcDir(config);
|
|
196
|
+
// In dev mode, reuse a single cached engine across rebuilds to avoid
|
|
197
|
+
// per-rebuild compile churn and the associated native-memory growth.
|
|
198
|
+
if (isDevelopment() && cachedTemplateEngine && cachedTemplateEngine.templateDir === templateDir) {
|
|
199
|
+
return cachedTemplateEngine.eta;
|
|
200
|
+
}
|
|
201
|
+
// Enable the template cache in dev too so partials/layouts compile once and are
|
|
202
|
+
// reused across rebuilds; template edits clear this cache via clearTemplateEngineCache().
|
|
203
|
+
const useCache = isDevelopment() || isProduction();
|
|
178
204
|
const eta = new Eta({
|
|
179
205
|
views: templateDir,
|
|
180
|
-
cache:
|
|
181
|
-
cacheFilepaths:
|
|
206
|
+
cache: useCache,
|
|
207
|
+
cacheFilepaths: useCache,
|
|
182
208
|
varName: 'stati',
|
|
183
209
|
});
|
|
210
|
+
if (isDevelopment()) {
|
|
211
|
+
cachedTemplateEngine = { templateDir, eta };
|
|
212
|
+
}
|
|
184
213
|
return eta;
|
|
185
214
|
}
|
|
186
215
|
export async function renderPage(page, body, config, eta, navigation, allPages, assets, toc, logger) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stati/core",
|
|
3
|
-
"version": "1.23.
|
|
3
|
+
"version": "1.23.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"chokidar": "^3.6.0",
|
|
42
|
-
"esbuild": "^0.
|
|
42
|
+
"esbuild": "^0.28.1",
|
|
43
43
|
"eta": "^3.5.0",
|
|
44
44
|
"fast-glob": "^3.3.3",
|
|
45
45
|
"fs-extra": "^11.2.0",
|