11ty / eleventy

A simpler site generator. Transforms a directory of templates (of varying types) into HTML.
https://www.11ty.dev/
MIT License
17.07k stars 494 forks source link

Build error when using "git Last Modified" as date on AWS CodeBuild #2423

Closed kareldonk closed 2 years ago

kareldonk commented 2 years ago

Describe the bug When using git Last Modified as the date in a markdown file, the build fails with the following on AWS CodeBuild with nodeJS 14:

[11ty] Problem writing Eleventy templates: (more in DEBUG output)
[11ty] mapA.date.getTime is not a function (via TypeError)
[11ty] 
[11ty] Original error stack trace: TypeError: mapA.date.getTime is not a function
[11ty]     at sortFunctionDateInputPath (/codebuild/output/src505448918/src/node_modules/@11ty/eleventy/src/Util/Sortable.js:107:17)
[11ty]     at Array.sort (<anonymous>)
[11ty]     at TemplateCollection.sort (/codebuild/output/src505448918/src/node_modules/@11ty/eleventy/src/Util/Sortable.js:45:31)
[11ty]     at TemplateCollection.getAllSorted (/codebuild/output/src505448918/src/node_modules/@11ty/eleventy/src/TemplateCollection.js:25:17)
[11ty]     at TemplateMap.getTaggedCollection (/codebuild/output/src505448918/src/node_modules/@11ty/eleventy/src/TemplateMap.js:513:32)
[11ty]     at TemplateMap.setCollectionByTagName (/codebuild/output/src505448918/src/node_modules/@11ty/eleventy/src/TemplateMap.js:262:44)
[11ty]     at TemplateMap.initDependencyMap (/codebuild/output/src505448918/src/node_modules/@11ty/eleventy/src/TemplateMap.js:284:20)
[11ty]     at async TemplateMap.cache (/codebuild/output/src505448918/src/node_modules/@11ty/eleventy/src/TemplateMap.js:333:5)
[11ty]     at async TemplateWriter._createTemplateMap (/codebuild/output/src505448918/src/node_modules/@11ty/eleventy/src/TemplateWriter.js:244:5)
[11ty]     at async TemplateWriter.generateTemplates (/codebuild/output/src505448918/src/node_modules/@11ty/eleventy/src/TemplateWriter.js:277:5)
[11ty] Wrote 0 files in 0.60 seconds (v1.0.1)

When I build locally on my dev machine the build does succeed. Just not on AWS CodeBuild.

Expected behavior Expect build to succeed.

Repro This was the contents of the markdown file:

---
layout: page-navigation.njk
title: Code Quality
date: git Last Modified
eleventyNavigation:
  key: Code Quality
  parent: Guidelines
  order: 50
---

Text goes here.

Environment:

AWS Codebuild with nodeJS 14.

Additional context Add any other context about the problem here.

kareldonk commented 2 years ago

This could be because CodeBuild copies files from CodeCommit instead of doing a clone, and the git information is not available in the copied folder.

kareldonk commented 2 years ago

I had to update CodePipeline Source action to do a full clone:

image

The build succeeds now, but all files get the date of the last commit. So it doesn't work correctly yet.

kareldonk commented 2 years ago

It works now, I had to configure CodeBuild on AWS to clone the full depth:

image