Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exporting additional items from eleventy.config.js results in a reset of settings (v3.0.0) #3169

Closed
noelforte opened this issue Jan 20, 2024 · 5 comments

Comments

@noelforte
Copy link
Contributor

Operating system

macOS Sonoma 14.2.1

Eleventy

v3.0.0-alpha.4

Describe the bug

I've been converting my site to version 3.0.0 of Eleventy and have come across a reproducible bug when exporting additional items from the eleventy.config.js file. I first noticed it when errors started getting thrown about my lack of an _includes directory, although now having done a reduced test case, I see that the error stems from settings apparently being reset to the defaults even if there's a default function that exports a configuration object.

Reproduction steps

In the reduced test case repository:

  1. npm install
  2. npx eleventy - should output to "build" directory
  3. Uncomment the exported const in eleventy.config.js
  4. npx eleventy - outputs to ./_site (the default) not ./build, essentially ignoring the config file

Expected behavior

Exporting a named variable, object, or the like from the configuration file should not alter the output of the build. If this behavior is intentional, there should be documentation around the correct way to export named exports from eleventy.config.js

Reproduction URL

https://github.com/noelforte/11ty-multi-exports

Screenshots

No response

@noelforte
Copy link
Contributor Author

Adding DEBUG output if that helps diagnose this!

Full output: (collapsed for brevity)
  Eleventy:cmd command: eleventy { _: [], quiet: null, version: false, watch: false, dryrun: false, help: false, serve: false, incremental: false, 'ignore-initial': false } +0ms
  Eleventy:EventBus Setting up global EventBus. +0ms
  Eleventy:UserConfig Resetting EleventyConfig to initial values. +0ms
  Eleventy:UserConfig Adding universal filter 'slug' +5ms
  Eleventy:UserConfig Adding universal filter 'slugify' +0ms
  Eleventy:UserConfig Adding universal filter 'url' +0ms
  Eleventy:UserConfig Adding universal filter 'log' +0ms
  Eleventy:UserConfig Adding universal filter 'getCollectionItemIndex' +0ms
  Eleventy:UserConfig Adding universal filter 'getCollectionItem' +1ms
  Eleventy:UserConfig Adding universal filter 'getPreviousCollectionItem' +0ms
  Eleventy:UserConfig Adding universal filter 'getNextCollectionItem' +0ms
  Eleventy:TemplateConfig rootConfig { templateFormats: [ 'liquid', 'md', 'njk', 'html', '11ty.js' ], pathPrefix: '/', markdownTemplateEngine: 'liquid', htmlTemplateEngine: 'liquid', htmlOutputSuffix: '-o', dataFileSuffixes: [ '.11tydata', '' ], dataFileDirBaseNameOverride: false, keys: { package: 'pkg', layout: 'layout', permalink: 'permalink', permalinkRoot: 'permalinkBypassOutputDir', engineOverride: 'templateEngineOverride', computed: 'eleventyComputed' }, dir: { input: '.', includes: '_includes', data: '_data', output: '_site' }, nunjucksFilters: {} } +0ms
  Eleventy:TemplateConfig Merging config with eleventy.config.js +0ms
  Eleventy:TemplateConfig overrides: {} +1ms
  Eleventy:TemplateConfig Current configuration: { pathPrefix: '/', markdownTemplateEngine: 'liquid', htmlTemplateEngine: 'liquid', htmlOutputSuffix: '-o', dataFileSuffixes: [ '.11tydata', '' ], dataFileDirBaseNameOverride: false, keys: { package: 'pkg', layout: 'layout', permalink: 'permalink', permalinkRoot: 'permalinkBypassOutputDir', engineOverride: 'templateEngineOverride', computed: 'eleventyComputed' }, dir: { input: '.', includes: '_includes', data: '_data', output: '_site' }, nunjucksFilters: { slug: [Function (anonymous)], slugify: [Function (anonymous)], url: [Function (anonymous)], log: [Function (anonymous)], getCollectionItemIndex: [Function (anonymous)], getCollectionItem: [Function (anonymous)], getPreviousCollectionItem: [Function (anonymous)], getNextCollectionItem: [Function (anonymous)] }, default: [Function: default], test: 'hi!', templateFormats: [ 'liquid', 'md', 'njk', 'html', '11ty.js' ], transforms: {}, linters: {}, globalData: {}, layoutAliases: {}, layoutResolution: true, passthroughCopies: {}, liquidOptions: {}, liquidTags: {}, liquidFilters: { slug: [Function (anonymous)], slugify: [Function (anonymous)], url: [Function (anonymous)], log: [Function (anonymous)], getCollectionItemIndex: [Function (anonymous)], getCollectionItem: [Function (anonymous)], getPreviousCollectionItem: [Function (anonymous)], getNextCollectionItem: [Function (anonymous)] }, liquidShortcodes: {}, liquidPairedShortcodes: {}, nunjucksEnvironmentOptions: {}, nunjucksPrecompiledTemplates: {}, nunjucksAsyncFilters: {}, nunjucksTags: {}, nunjucksGlobals: {}, nunjucksAsyncShortcodes: {}, nunjucksShortcodes: {}, nunjucksAsyncPairedShortcodes: {}, nunjucksPairedShortcodes: {}, javascriptFunctions: { slug: [Function (anonymous)], slugify: [Function (anonymous)], url: [Function (anonymous)], log: [Function (anonymous)], getCollectionItemIndex: [Function (anonymous)], getCollectionItem: [Function (anonymous)], getPreviousCollectionItem: [Function (anonymous)], getNextCollectionItem: [Function (anonymous)] }, markdownHighlighter: null, libraryOverrides: {}, dynamicPermalinks: true, useGitIgnore: true, ignores: Set(2) { '**/node_modules/**', '.git/**' }, watchIgnores: Set(2) { '**/node_modules/**', '.git/**' }, dataDeepMerge: true, watchJavaScriptDependencies: true, additionalWatchTargets: [], serverOptions: {}, chokidarConfig: {}, watchThrottleWaitTime: 0, frontMatterParsingOptions: { engines: { node: [Function: node] } }, dataExtensions: Map(0) {}, extensionMap: Set(0) {}, quietMode: false, events: AsyncEventEmitter { _events: [Object: null prototype] {}, _eventsCount: 0, _maxListeners: undefined, [Symbol(shapeMode)]: false, [Symbol(kCapture)]: false }, benchmarkManager: BenchmarkManager { benchmarkGroups: { Configuration: [BenchmarkGroup], Aggregate: [BenchmarkGroup] }, isVerbose: true, start: 148.53925001621246 }, plugins: [], useTemplateCache: true, precompiledCollections: {}, dataFilterSelectors: Set(0) {}, libraryAmendments: {}, serverPassthroughCopyBehavior: 'copy', urlTransforms: [] } +0ms
  Eleventy:TemplatePassthroughManager Resetting counts to 0 +0ms
  Eleventy:EleventyFiles .gitignore,.eleventyignore,.eleventyignore ignoring: ./node_modules/** +0ms
  Eleventy:EleventyFiles .gitignore,.eleventyignore,.eleventyignore ignoring: ./build/** +0ms
  Eleventy:EleventyFiles .gitignore,.eleventyignore,.eleventyignore ignoring: ./_site/** +0ms
  Eleventy:EleventyFiles Searching for: [ './**/*.{liquid,md,njk,html,11ty.js,11ty.cjs,11ty.mjs}' ] +1ms
  Eleventy:FastGlobManager Glob search ('templates') searching for: [ './**/*.{liquid,md,njk,html,11ty.js,11ty.cjs,11ty.mjs}' ] +0ms
  Eleventy:FastGlobManager Glob search ('templates') ignoring: [ 'node_modules/**', 'build/**', '_site/**', '_includes/**', '_data/**', '**/node_modules/**', '.git/**' ] +0ms
  Eleventy:TemplatePassthroughManager TemplatePassthrough copy started. +8ms
  Eleventy:TemplatePassthroughManager `addPassthroughCopy` config API paths: {} +0ms
  Eleventy:TemplatePassthroughManager `addPassthroughCopy` config API normalized paths: [] +0ms
  Eleventy:TemplateData Using [ '.11tydata', '' ] suffixes to find data files. +0ms
  Eleventy:TemplateData getLocalDataPaths('./src/index.njk'): [ './src/index.11tydata.js', './src/index.11tydata.cjs', './src/index.11tydata.mjs', './src/index.11tydata.json', './src/index.json', './src/src.11tydata.js', './src/src.11tydata.cjs', './src/src.11tydata.mjs', './src/src.11tydata.json', './src/src.json' ] +0ms
  Eleventy:TemplateWriter ./src/index.njk adding to template map. +0ms
  Eleventy:TemplatePassthroughManager TemplatePassthrough copy finished. Current count: 0 +2ms
  Eleventy:FastGlobManager Glob search ('global-data') searching for: [ './_data/**/*.{json,mjs,cjs,js}' ] +9ms
  Eleventy:Template Template date: using file’s 'birthtimeMs' for './src/index.njk' of 2024-01-20T04:37:55.672Z (from 1705725475672.5615) +0ms
  Eleventy:TemplateMap Caching collections objects. +0ms
  Eleventy:TemplateMap Collection: collections.all size: 1 +1ms
  Eleventy:TemplateMap Collection: collections.all size: 1 +0ms
  Eleventy:TemplateWriter Template map created. +17ms
  Eleventy:Logger Writing _site/src/index.html from ./src/index.njk +0ms
  Eleventy:Template _site/src/index.html written.. +8ms
  Eleventy:Logger Benchmark      7ms  20%     1× (Aggregate) Searching the file system (templates) +2ms
  Eleventy:Benchmark Benchmark      7ms  20%     1× (Aggregate) Searching the file system (templates) +0ms
  Eleventy:Benchmark Benchmark      2ms   4%     1× (Aggregate) Searching the file system (data) +0ms
  Eleventy:Benchmark Benchmark      2ms   6%     1× (Aggregate) Template Compile +0ms
  Eleventy:Benchmark Benchmark      2ms   6%     1× (Aggregate) > Compile > ./src/index.njk +0ms
  Eleventy:Benchmark Benchmark      2ms   4%     1× (Aggregate) Template Write +0ms
[11ty] Wrote 1 file in 0.03 seconds (v3.0.0-alpha.4)

@zachleat
Copy link
Member

zachleat commented Apr 8, 2024

Ah—hmm. Your configuration file is not what I’d expect.

Per the ESM example on https://www.11ty.dev/docs/config/, we expect:

export default function(eleventyConfig) {

You have

export function eleventyConfig(config) {

In your case Eleventy isn’t picking up any configuration from your file.

@zachleat
Copy link
Member

zachleat commented Apr 8, 2024

This is an automated message to let you know that a helpful response was posted to your issue and for the health of the repository issue tracker the issue will be closed. This is to help alleviate issues hanging open waiting for a response from the original poster.

If the response works to solve your problem—great! But if you’re still having problems, do not let the issue’s closing deter you if you have additional questions! Post another comment and we will reopen the issue. Thanks!

@zachleat zachleat closed this as completed Apr 8, 2024
@noelforte
Copy link
Contributor Author

Hey @zachleat thanks for responding to this one. I've just applied a fresh push to my RTC linked above and the issue still persists, settings are reset when there are additional exports besides the default.

Same test, commenting out the exported const in eleventy.config.js allows the files to be read from/sent to the correct input/output, but when that export is there the configuration stops getting applied. I tried moving the export order around but no dice. Any ideas?

@noelforte
Copy link
Contributor Author

@zachleat Sorry for double-pinging you, wanted to follow up on this after stumbling across #3246. Resolving that issue appears to have fixed this one since allowing for the config export also enabled other exports from the config file so long as they're not causing a conflict by being const config. Verified to be working with 3.0.0-alpha.9.

No need to reopen, cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants