Open kotfire opened 4 years ago
@kotfire Sorry for the wait. Thanks for reporting, and for providing a test case. FWIW, I can confirm that this is a problem.
Want to log that this might be related to (fixed with) https://github.com/11ty/eleventy/pull/1956
Using
data.collections
inside a computed data function fails with the following error:Click to show full `DEBUG=Eleventy* npx eleventy` output
```shell Eleventy:UserConfig Resetting EleventyConfig to initial values. +0ms Eleventy:Config Setting up global TemplateConfig. +0ms Eleventy:UserConfig Adding universal filter 'slug' +3ms Eleventy:UserConfig Adding universal filter 'url' +1ms Eleventy:UserConfig Adding universal filter 'log' +0ms Eleventy:UserConfig Adding universal filter 'getCollectionItem' +0ms Eleventy:UserConfig Adding universal filter 'getPreviousCollectionItem' +0ms Eleventy:UserConfig Adding universal filter 'getNextCollectionItem' +0ms Eleventy:TemplateConfig rootConfig { templateFormats: [ 'liquid', 'ejs', 'md', 'hbs', 'mustache', 'haml', 'pug', 'njk', 'html', 'jstl', '11ty.js' ], pathPrefix: '/', markdownTemplateEngine: 'liquid', htmlTemplateEngine: 'liquid', dataTemplateEngine: 'liquid', passthroughFileCopy: true, htmlOutputSuffix: '-o', jsDataFileSuffix: '.11tydata', keys: { package: 'pkg', layout: 'layout', permalink: 'permalink', permalinkRoot: 'permalinkBypassOutputDir', engineOverride: 'templateEngineOverride', computed: 'eleventyComputed' }, dir: { input: '.', includes: '_includes', data: '_data', output: '_site' }, filters: {}, handlebarsHelpers: {}, nunjucksFilters: {} } +0ms Eleventy:TemplateConfig Merging config with /home/user/11ty-computed-use-collections/.eleventy.js +1ms Eleventy:TemplateConfig Eleventy local project config file not found, skipping. +0ms Eleventy:TemplateConfig localConfig: { templateFormats: undefined, filters: {}, linters: {}, layoutAliases: {}, passthroughCopies: {}, liquidOptions: {}, liquidTags: {}, liquidFilters: { slug: [Function], url: [Function], log: [Function], getCollectionItem: [Function], getPreviousCollectionItem: [Function], getNextCollectionItem: [Function] }, liquidShortcodes: {}, liquidPairedShortcodes: {}, nunjucksFilters: { slug: [Function], url: [Function], log: [Function], getCollectionItem: [Function], getPreviousCollectionItem: [Function], getNextCollectionItem: [Function] }, nunjucksAsyncFilters: {}, nunjucksTags: {}, nunjucksAsyncShortcodes: {}, nunjucksShortcodes: {}, nunjucksAsyncPairedShortcodes: {}, nunjucksPairedShortcodes: {}, handlebarsHelpers: { slug: [Function], url: [Function], log: [Function], getCollectionItem: [Function], getPreviousCollectionItem: [Function], getNextCollectionItem: [Function] }, handlebarsShortcodes: {}, handlebarsPairedShortcodes: {}, javascriptFunctions: { slug: [Function], url: [Function], log: [Function], getCollectionItem: [Function], getPreviousCollectionItem: [Function], getNextCollectionItem: [Function] }, pugOptions: {}, ejsOptions: {}, markdownHighlighter: null, libraryOverrides: {}, dynamicPermalinks: true, useGitIgnore: true, dataDeepMerge: false, watchJavaScriptDependencies: true, additionalWatchTargets: [], browserSyncConfig: {}, chokidarConfig: {}, watchThrottleWaitTime: 0, frontMatterParsingOptions: undefined, dataExtensions: Map {}, extensionMap: Set {}, quietMode: false, events: EventEmitter { _events: [Object: null prototype] {}, _eventsCount: 0, _maxListeners: undefined } } +1ms Eleventy:TemplateConfig overrides: {} +1ms Eleventy:TemplateConfig Current configuration: { templateFormats: [ 'liquid', 'ejs', 'md', 'hbs', 'mustache', 'haml', 'pug', 'njk', 'html', 'jstl', '11ty.js' ], pathPrefix: '/', markdownTemplateEngine: 'liquid', htmlTemplateEngine: 'liquid', dataTemplateEngine: 'liquid', passthroughFileCopy: true, htmlOutputSuffix: '-o', jsDataFileSuffix: '.11tydata', keys: { package: 'pkg', layout: 'layout', permalink: 'permalink', permalinkRoot: 'permalinkBypassOutputDir', engineOverride: 'templateEngineOverride', computed: 'eleventyComputed' }, dir: { input: '.', includes: '_includes', data: '_data', output: '_site' }, filters: {}, handlebarsHelpers: { slug: [Function], url: [Function], log: [Function], getCollectionItem: [Function], getPreviousCollectionItem: [Function], getNextCollectionItem: [Function] }, nunjucksFilters: { slug: [Function], url: [Function], log: [Function], getCollectionItem: [Function], getPreviousCollectionItem: [Function], getNextCollectionItem: [Function] }, linters: {}, layoutAliases: {}, passthroughCopies: {}, liquidOptions: {}, liquidTags: {}, liquidFilters: { slug: [Function], url: [Function], log: [Function], getCollectionItem: [Function], getPreviousCollectionItem: [Function], getNextCollectionItem: [Function] }, liquidShortcodes: {}, liquidPairedShortcodes: {}, nunjucksAsyncFilters: {}, nunjucksTags: {}, nunjucksAsyncShortcodes: {}, nunjucksShortcodes: {}, nunjucksAsyncPairedShortcodes: {}, nunjucksPairedShortcodes: {}, handlebarsShortcodes: {}, handlebarsPairedShortcodes: {}, javascriptFunctions: { slug: [Function], url: [Function], log: [Function], getCollectionItem: [Function], getPreviousCollectionItem: [Function], getNextCollectionItem: [Function] }, pugOptions: {}, ejsOptions: {}, markdownHighlighter: null, libraryOverrides: {}, dynamicPermalinks: true, useGitIgnore: true, dataDeepMerge: false, watchJavaScriptDependencies: true, additionalWatchTargets: [], browserSyncConfig: {}, chokidarConfig: {}, watchThrottleWaitTime: 0, frontMatterParsingOptions: undefined, dataExtensions: Map {}, extensionMap: Set {}, quietMode: false, events: EventEmitter { _events: [Object: null prototype] {}, _eventsCount: 0, _maxListeners: undefined } } +1ms Eleventy:CommandCheck command: eleventy +0ms Eleventy Eleventy warm up time (in ms) 191.78277700021863 +0ms Eleventy:TemplatePassthroughManager Resetting counts to 0 +0ms Eleventy:EleventyFiles /home/user/11ty-computed-use-collections/.gitignore ignoring: !./.vscode +0ms Eleventy:EleventyFiles /home/user/11ty-computed-use-collections/.gitignore ignoring: !./_site/** +0ms Eleventy:EleventyFiles /home/user/11ty-computed-use-collections/.gitignore ignoring: !./node_modules/** +0ms Eleventy Directories: Eleventy Input: . Eleventy Data: _data Eleventy Includes: _includes Eleventy Layouts: undefined Eleventy Output: _site Eleventy Template Formats: liquid,ejs,md,hbs,mustache,haml,pug,njk,html,jstl,11ty.js Eleventy Verbose Output: false +3ms Eleventy:EleventyFiles Searching for: [ './**/*.liquid', './**/*.ejs', './**/*.md', './**/*.hbs', './**/*.mustache', './**/*.haml', './**/*.pug', './**/*.njk', './**/*.html', './**/*.jstl', './**/*.11ty.js', './**/*.11ty.cjs', '!./.vscode', '!./_site/**', '!./node_modules/**', '!./_site/**', '!./_includes/**', '!./_data/**' ] +10ms Eleventy:TemplateWriter Found: [ './blog.njk' ] +0ms Eleventy:TemplatePassthroughManager TemplatePassthrough copy started. +17ms Eleventy:TemplatePassthroughManager `passthroughFileCopy` config paths: {} +0ms Eleventy:TemplatePassthroughManager `passthroughFileCopy` config normalized paths: [] +0ms Eleventy:TemplateData Using '.11tydata' to find data files. +0ms Eleventy:TemplateData getLocalDataPaths('./blog.njk'): [ './blog.11tydata.js', './blog.11tydata.cjs', './blog.11tydata.json', './blog.json' ] +0ms Eleventy:TemplatePassthroughManager TemplatePassthrough copy finished. Current count: 0 +1ms Eleventy:Template getMappedDate: using file created time for './blog.njk' of 2020-10-22T03:06:38.040Z (from 1603335998040.7812) +0ms Eleventy:TemplateWriter ./blog.njk added to map. +18ms Eleventy:TemplateMap Caching collections objects. +0ms Eleventy:Template First round of computed data for './blog.njk' +2ms Eleventy:Template Rendering permalink for './blog.njk': (((((11ty(((((permalink)))))11ty))))) becomes '(((((11ty(((((permalink)))))11ty)))))' +3ms Eleventy:ComputedData 'page.url' accesses [ 'permalink' ] variables +0ms Eleventy:Template Rendering permalink for './blog.njk': (((((11ty(((((permalink)))))11ty))))) becomes '(((((11ty(((((permalink)))))11ty)))))' +0ms Eleventy:ComputedData 'page.outputPath' accesses [ 'permalink' ] variables +1ms Eleventy:ComputedData 'permalink' accesses [ 'collections', 'collections.all' ] variables +0ms Eleventy:ComputedData Computed data order of execution: [] +0ms Eleventy:TemplateMap Collection: collections.all size: 1 +7ms Eleventy:TemplateMap Collection: collections.all size: 1 +0ms Eleventy:Template Second round of computed data for './blog.njk' +2ms Eleventy:ComputedData Computed data order of execution: [ 'collections.all', 'permalink', 'page.url', 'page.outputPath' ] +1ms Eleventy:Template Rendering permalink for './blog.njk': /blog/ becomes '/blog/' +0ms Eleventy:Template Rendering permalink for './blog.njk': /blog/ becomes '/blog/' +1ms Eleventy:TemplateWriter Template map created. +10ms Eleventy:Template Writing '' from './blog.njk'. +4ms Eleventy:EleventyErrorHandler Error writing templates: +0ms Eleventy:EleventyErrorHandler Having trouble writing template: Eleventy:EleventyErrorHandler Eleventy:EleventyErrorHandler `TemplateWriterWriteError` was thrown +0ms Eleventy:EleventyErrorHandler (error stack): TemplateWriterWriteError: Having trouble writing template: Eleventy:EleventyErrorHandler at /home/user/11ty-computed-use-collections/node_modules/@11ty/eleventy/src/TemplateWriter.js:216:15 +0ms Eleventy:EleventyErrorHandler ENOENT: no such file or directory, open '' Eleventy:EleventyErrorHandler Eleventy:EleventyErrorHandler `Error` was thrown: +0ms Eleventy:EleventyErrorHandler (error stack): Error: ENOENT: no such file or directory, open '' +0ms Eleventy:EleventyErrorHandler Problem writing Eleventy templates: +0ms Eleventy:EleventyErrorHandler Having trouble writing template: Eleventy:EleventyErrorHandler Eleventy:EleventyErrorHandler `TemplateWriterWriteError` was thrown +0ms Eleventy:EleventyErrorHandler (error stack): TemplateWriterWriteError: Having trouble writing template: Eleventy:EleventyErrorHandler at /home/user/11ty-computed-use-collections/node_modules/@11ty/eleventy/src/TemplateWriter.js:216:15 +0ms Eleventy:EleventyErrorHandler ENOENT: no such file or directory, open '' Eleventy:EleventyErrorHandler Eleventy:EleventyErrorHandler `Error` was thrown: +0ms Eleventy:EleventyErrorHandler (error stack): Error: ENOENT: no such file or directory, open '' +0ms Eleventy:Benchmark Benchmark (Aggregate): Searching the file system took 14ms (14.0%, called 2×, 6.9ms each) +0ms Eleventy:Benchmark Benchmark (Aggregate): Template Read took 1ms (0.8%, called 2×, 0.4ms each) +0ms Eleventy:Benchmark Benchmark (Aggregate): Template Render took 4ms (4.5%, called 5×, 0.9ms each) +0ms Wrote 0 files in 0.05 seconds (v0.11.0) Eleventy Finished writing templates. +47ms Eleventy Eleventy Getting frustrated? Have a suggestion/feature request/feedback? Eleventy I want to hear it! Open an issue: https://github.com/11ty/eleventy/issues/new +0ms Start time: (2020-10-22 03:06:49 UTC) [treshold=1%] # module time % 1 ./src/EleventyErrorHandler (node_mod...eventy/src/EleventyErrorHandler.js) 3ms ▇▇ 2% 2 parse-filepath (node_modules/parse-filepath/index.js) 2ms ▇ 1% 3 ./TemplatePath (node_modules/@11ty/eleventy/src/TemplatePath.js) 3ms ▇▇ 2% 4 graceful-fs (node_modules/graceful-fs/graceful-fs.js) 2ms ▇ 1% 5 ./fs (node_modules/fs-extra/lib/fs/index.js) 4ms ▇▇ 2% 6 ./copy-sync (node_modules/fs-extra/lib/copy-sync/copy-sync.js) 2ms ▇ 1% 7 ./copy-sync (node_modules/fs-extra/lib/copy-sync/index.js) 2ms ▇ 1% 8 ./empty (node_modules/fs-extra/lib/empty/index.js) 2ms ▇ 1% 9 ./json (node_modules/fs-extra/lib/json/index.js) 2ms ▇ 1% 10 fs-extra (node_modules/fs-extra/lib/index.js) 14ms ▇▇▇▇▇▇ 7% 11 braces (node_modules/braces/index.js) 3ms ▇▇ 2% 12 ./lib/picomatch (node_modules/picomatch/lib/picomatch.js) 2ms ▇ 1% 13 picomatch (node_modules/picomatch/index.js) 2ms ▇ 1% 14 micromatch (node_modules/micromatch/index.js) 5ms ▇▇ 3% 15 ./pattern (node_modules/fast-glob/out/utils/pattern.js) 6ms ▇▇▇ 3% 16 ../utils (node_modules/fast-glob/out/utils/index.js) 8ms ▇▇▇▇ 4% 17 ./managers/tasks (node_modules/fast-glob/out/managers/tasks.js) 9ms ▇▇▇▇ 5% 18 @nodelib/fs.scandir (node_modules/@nodelib/fs.scandir/out/index.js) 2ms ▇ 1% 19 ../readers/async (node_modules/@nodelib/fs.walk/out/readers/async.js) 4ms ▇▇ 2% 20 ./providers/async (node_modules/@nodelib/fs.walk/out/providers/async.js) 4ms ▇▇ 2% 21 @nodelib/fs.walk (node_modules/@nodelib/fs.walk/out/index.js) 4ms ▇▇ 2% 22 ../readers/stream (node_modules/fast-glob/out/readers/stream.js) 6ms ▇▇▇ 3% 23 ./providers/async (node_modules/fast-glob/out/providers/async.js) 7ms ▇▇▇ 4% 24 ./settings (node_modules/fast-glob/out/settings.js) 19ms ▇▇▇▇▇▇▇▇ 10% 25 fast-glob (node_modules/fast-glob/out/index.js) 36ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 19% 26 ./_baseIsNative (node_modules/lodash/_baseIsNative.js) 2ms ▇ 1% 27 ./_getNative (node_modules/lodash/_getNative.js) 2ms ▇ 1% 28 ./_defineProperty (node_modules/lodash/_defineProperty.js) 2ms ▇ 1% 29 ./_baseAssignValue (node_modules/lodash/_baseAssignValue.js) 2ms ▇ 1% 30 ./_assignValue (node_modules/lodash/_assignValue.js) 2ms ▇ 1% 31 ./_mapCacheClear (node_modules/lodash/_mapCacheClear.js) 3ms ▇▇ 2% 32 ./_MapCache (node_modules/lodash/_MapCache.js) 3ms ▇▇ 2% 33 ./memoize (node_modules/lodash/memoize.js) 3ms ▇▇ 2% 34 ./_memoizeCapped (node_modules/lodash/_memoizeCapped.js) 3ms ▇▇ 2% 35 ./_stringToPath (node_modules/lodash/_stringToPath.js) 3ms ▇▇ 2% 36 ./toString (node_modules/lodash/toString.js) 2ms ▇ 1% 37 ./_castPath (node_modules/lodash/_castPath.js) 6ms ▇▇▇ 3% 38 ./_baseSet (node_modules/lodash/_baseSet.js) 9ms ▇▇▇▇ 5% 39 lodash/set (node_modules/lodash/set.js) 9ms ▇▇▇▇ 5% 40 ./_baseUniq (node_modules/lodash/_baseUniq.js) 2ms ▇ 1% 41 lodash/uniq (node_modules/lodash/uniq.js) 2ms ▇ 1% 42 ./_baseMergeDeep (node_modules/lodash/_baseMergeDeep.js) 4ms ▇▇ 2% 43 ./_baseMerge (node_modules/lodash/_baseMerge.js) 5ms ▇▇ 3% 44 ./_createAssigner (node_modules/lodash/_createAssigner.js) 2ms ▇ 1% 45 lodash/merge (node_modules/lodash/merge.js) 7ms ▇▇▇ 4% 46 semver (node_modules/semver/index.js) 7ms ▇▇▇ 4% 47 luxon (node_modules/luxon/build/node/luxon.js) 5ms ▇▇ 3% 48 ./UserConfig (node_modules/@11ty/eleventy/src/UserConfig.js) 15ms ▇▇▇▇▇▇ 8% 49 ./EleventyConfig (node_modules/@11ty/eleventy/src/EleventyConfig.js) 16ms ▇▇▇▇▇▇▇ 8% 50 ./TemplateConfig (node_modules/@11ty/eleventy/src/TemplateConfig.js) 24ms ▇▇▇▇▇▇▇▇▇▇ 12% 51 ./defaultConfig.js (node_modules/@11ty/eleventy/src/defaultConfig.js) 2ms ▇ 1% 52 ./Config (node_modules/@11ty/eleventy/src/Config.js) 31ms ▇▇▇▇▇▇▇▇▇▇▇▇ 16% 53 ./TemplateEngineManager (node_module...venty/src/TemplateEngineManager.js) 31ms ▇▇▇▇▇▇▇▇▇▇▇▇ 16% 54 ./EleventyExtensionMap (node_modules...eventy/src/EleventyExtensionMap.js) 31ms ▇▇▇▇▇▇▇▇▇▇▇▇ 16% 55 ./TemplateRender (node_modules/@11ty/eleventy/src/TemplateRender.js) 31ms ▇▇▇▇▇▇▇▇▇▇▇▇ 16% 56 ./TemplateData (node_modules/@11ty/eleventy/src/TemplateData.js) 94ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 49% 57 ./core (node_modules/js-yaml/lib/js-yaml/schema/core.js) 2ms ▇ 1% 58 ./schema/default_safe (node_modules/...lib/js-yaml/schema/default_safe.js) 3ms ▇▇ 2% 59 esprima (node_modules/esprima/dist/esprima.js) 8ms ▇▇▇▇ 4% 60 ../type/js/function (node_modules/js...ml/lib/js-yaml/type/js/function.js) 8ms ▇▇▇▇ 4% 61 ./schema/default_full (node_modules/...lib/js-yaml/schema/default_full.js) 9ms ▇▇▇▇ 5% 62 ./js-yaml/loader (node_modules/js-yaml/lib/js-yaml/loader.js) 14ms ▇▇▇▇▇▇ 7% 63 ./lib/js-yaml.js (node_modules/js-yaml/lib/js-yaml.js) 16ms ▇▇▇▇▇▇▇ 8% 64 js-yaml (node_modules/js-yaml/index.js) 16ms ▇▇▇▇▇▇▇ 8% 65 ./engines (node_modules/gray-matter/lib/engines.js) 17ms ▇▇▇▇▇▇▇ 9% 66 ./lib/defaults (node_modules/gray-matter/lib/defaults.js) 17ms ▇▇▇▇▇▇▇ 9% 67 gray-matter (node_modules/gray-matter/index.js) 19ms ▇▇▇▇▇▇▇▇ 10% 68 ./TemplateContent (node_modules/@11ty/eleventy/src/TemplateContent.js) 20ms ▇▇▇▇▇▇▇▇ 10% 69 ./Template (node_modules/@11ty/eleventy/src/Template.js) 24ms ▇▇▇▇▇▇▇▇▇▇ 12% 70 multimatch (node_modules/multimatch/index.js) 2ms ▇ 1% 71 ./TemplateCollection (node_modules/@...eleventy/src/TemplateCollection.js) 2ms ▇ 1% 72 ./TemplateMap (node_modules/@11ty/eleventy/src/TemplateMap.js) 3ms ▇▇ 2% 73 glob (node_modules/glob/glob.js) 3ms ▇▇ 2% 74 globby (node_modules/globby/index.js) 5ms ▇▇ 3% 75 del (node_modules/del/index.js) 7ms ▇▇▇ 4% 76 ./lib/copy (node_modules/recursive-copy/lib/copy.js) 10ms ▇▇▇▇ 5% 77 recursive-copy (node_modules/recursive-copy/index.js) 10ms ▇▇▇▇ 5% 78 ./TemplatePassthrough (node_modules/...leventy/src/TemplatePassthrough.js) 10ms ▇▇▇▇ 5% 79 ./TemplatePassthroughManager (node_m.../src/TemplatePassthroughManager.js) 10ms ▇▇▇▇ 5% 80 ./EleventyFiles (node_modules/@11ty/eleventy/src/EleventyFiles.js) 11ms ▇▇▇▇▇ 6% 81 ./TemplateWriter (node_modules/@11ty/eleventy/src/TemplateWriter.js) 38ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 20% 82 ./src/Eleventy (node_modules/@11ty/eleventy/src/Eleventy.js) 137ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 71% 83 ./nodes (node_modules/nunjucks/src/nodes.js) 2ms ▇ 1% 84 ./parser (node_modules/nunjucks/src/parser.js) 3ms ▇▇ 2% 85 ./compiler (node_modules/nunjucks/src/compiler.js) 5ms ▇▇ 3% 86 ./src/environment (node_modules/nunjucks/src/environment.js) 8ms ▇▇▇▇ 4% 87 nunjucks (node_modules/nunjucks/index.js) 10ms ▇▇▇▇ 5% 88 ./Engines/Nunjucks (node_modules/@11ty/eleventy/src/Engines/Nunjucks.js) 10ms ▇▇▇▇ 5% Total require(): 1077 Total time: 193ms ```To Reproduce Access
data.collections
from a computed property in a11tydata.js
fileI've created a repository with the minimum data to reproduce the issue: https://github.com/kotfire/11ty-computed-use-collections
Expected behavior Maybe I'm not using this as I'm supposed to.
Computed data function works as expected if the collections are not used.
Environment: