mikser-io-layouts 2.3.0 → 2.4.1

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/index.js CHANGED
@@ -21,6 +21,7 @@ import {
21
21
  checksumsByCollection,
22
22
  checksum as fileChecksum, checksumOf,
23
23
  useDatabase,
24
+ writeOutput, reportUnchanged,
24
25
  } from 'mikser-io'
25
26
 
26
27
  import { createInspect } from './lib/inspect.js'
@@ -109,9 +110,9 @@ export function layouts(userOptions = {}) {
109
110
  const { relativePath } = context
110
111
 
111
112
  // A .js file under the layouts folder is a SIDECAR (or something
112
- // a sidecar imports), never a layout. It used to have its `.js`
113
- // stripped and be created as an entity, which produced a phantom
114
- // `/layouts/page` — holding JS source as its content — beside the
113
+ // a sidecar imports), never a layout. Treating one as a layout —
114
+ // stripping its `.js` and creating an entity — yields a phantom
115
+ // `/layouts/page` holding JS source as its content, beside the
115
116
  // real `/layouts/page.liquid`.
116
117
  //
117
118
  // Sidecars are inputs to a layout's checksum instead (see
@@ -408,12 +409,20 @@ export function layouts(userOptions = {}) {
408
409
 
409
410
  if (!skipWrite) {
410
411
  const destinationFile = path.join(writeBase, entity.destination)
411
- await mkdir(path.dirname(destinationFile), { recursive: true })
412
- try {
413
- await unlink(destinationFile)
414
- } catch { }
415
- await writeFile(destinationFile, output.result)
416
- logger.debug('Layout render finished: %s', entity.destination.replace(runtime.options.workingFolder, ''))
412
+ // writeOutput skips the write when the bytes already on
413
+ // disk are identical, and owns the mkdir/unlink.
414
+ // Invalidation is deliberately conservative — an entity
415
+ // that merely READS another re-renders, since the engine
416
+ // cannot know which field was read — so byte-identical
417
+ // output is routine, and rewriting it moves mtime for
418
+ // live-reload, rsync and `find -newer` alike.
419
+ const wrote = await writeOutput(destinationFile, output.result)
420
+ if (wrote) {
421
+ logger.debug('Layout render finished: %s', entity.destination.replace(runtime.options.workingFolder, ''))
422
+ } else {
423
+ reportUnchanged(entity)
424
+ logger.debug('Layout render finished, output unchanged: %s', entity.destination.replace(runtime.options.workingFolder, ''))
425
+ }
417
426
  } else {
418
427
  logger.debug('Layout render finished (save:false, bytes only): %s', entity.id)
419
428
  }
package/lib/matching.js CHANGED
@@ -221,14 +221,14 @@ export function createOnProcessed({
221
221
  // pattern-match / auto-layout paths.
222
222
  // Persist the primary destination.
223
223
  //
224
- // entity.destination used to exist ONLY as a field the
225
- // render-task builder set per task, and was never written
226
- // back — so the catalog had none, and runtime.href()
227
- // (which needs the TARGET's destination to make a
228
- // relative URL) fell through and returned the whole
229
- // entity instead of { url }. The catalog is only written
224
+ // The primary destination has to be persisted, not just
225
+ // set per render task. runtime.href() needs the TARGET's
226
+ // destination to build a relative URL, and it reads the
227
+ // catalog: a destination that only ever exists on a
228
+ // task makes href() fall through and return the whole
229
+ // entity instead of { url }. The catalog is written only
230
230
  // through the journal, and this hook is where that
231
- // happens, so it has to be derived here.
231
+ // happens, so it is derived here.
232
232
  //
233
233
  // "Primary" means page 1 / the sole output of the FIRST
234
234
  // matched layout — the same choice entity.layout already
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mikser-io-layouts",
3
- "version": "2.3.0",
3
+ "version": "2.4.1",
4
4
  "description": "SSG-flavor task-production policy for mikser-io. Multi-match layout assignment, per-layout destinations, postprocess chain attachment, layout inspection.",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "homepage": "https://github.com/almero-digital-marketing/mikser-io-layouts#readme",
20
20
  "peerDependencies": {
21
- "mikser-io": "^9.14.0"
21
+ "mikser-io": "^9.18.0"
22
22
  },
23
23
  "dependencies": {
24
24
  "globby": "^14.0.0",