Skip to content

Commit

Permalink
Fix issue with resetting config
Browse files Browse the repository at this point in the history
[11ty] File changed: .eleventy.js
[11ty] Eleventy fatal watch error: (more in DEBUG output)
[11ty] It’s not allowed to set config on EleventyServe. Set eleventyConfig instead. (via Error)
[11ty]
[11ty] Original error stack trace: Error: It’s not allowed to set config on EleventyServe. Set eleventyConfig instead.
[11ty]     at set config [as config] (file:///Users/zachleat/Code/eleventy/src/EleventyServe.js:44:11)
[11ty]     at Eleventy.resetConfig (file:///Users/zachleat/Code/eleventy/src/Eleventy.js:752:31)
[11ty]     at async Eleventy._watch (file:///Users/zachleat/Code/eleventy/src/Eleventy.js:846:7)
[11ty]     at async watchRun (file:///Users/zachleat/Code/eleventy/src/Eleventy.js:1102:9)
[11ty]     at async FSWatcher.<anonymous> (file:///Users/zachleat/Code/eleventy/src/Eleventy.js:1120:7)
  • Loading branch information
zachleat committed Nov 1, 2023
1 parent 20fb44c commit eee7719
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions src/Eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ class Eleventy {
logFinished() {
if (!this.writer) {
throw new Error(
"Did you call Eleventy.init to create the TemplateWriter instance? Hint: you probably didn’t."
"Did you call Eleventy.init to create the TemplateWriter instance? Hint: you probably didn’t.",
);
}

Expand All @@ -348,7 +348,7 @@ class Eleventy {
slashRet.push(
`Wrote ${writeCount} ${simplePlural(writeCount, "file", "files")}${
skippedCount ? ` (skipped ${skippedCount})` : ""
}`
}`,
);

if (slashRet.length) {
Expand Down Expand Up @@ -437,7 +437,7 @@ class Eleventy {
this.inputDir,
this.outputDir,
formats,
this.eleventyConfig
this.eleventyConfig,
);
this.eleventyFiles.setFileSystemSearch(this.fileSystemSearch);
this.eleventyFiles.setInput(this.inputDir, this.input);
Expand All @@ -449,7 +449,7 @@ class Eleventy {

if (checkPassthroughCopyBehavior(this.config, this.runMode)) {
this.eleventyServe.watchPassthroughCopy(
this.eleventyFiles.getGlobWatcherFilesForPassthroughCopy()
this.eleventyFiles.getGlobWatcherFilesForPassthroughCopy(),
);
}

Expand All @@ -471,7 +471,7 @@ class Eleventy {
this.outputDir,
formats,
this.templateData,
this.eleventyConfig
this.eleventyConfig,
);

if (!options.viaConfigReset) {
Expand Down Expand Up @@ -749,7 +749,6 @@ Arguments:
await this.eleventyConfig.reset();

this.config = this.eleventyConfig.getConfig();
this.eleventyServe.config = this.config;
this.eleventyServe.eleventyConfig = this.eleventyConfig;

// only use config quietMode if --quiet not set on CLI
Expand All @@ -770,7 +769,7 @@ Arguments:
let usedByDependants = [];
if (this.watchTargets) {
usedByDependants = this.watchTargets.getDependantsOf(
TemplatePath.addLeadingDotSlash(changedFilePath)
TemplatePath.addLeadingDotSlash(changedFilePath),
);
}

Expand Down Expand Up @@ -816,7 +815,7 @@ Arguments:
return this.shouldTriggerConfigReset(
activeQueue.map((path) => {
return PathNormalizer.normalizeSeperator(TemplatePath.addLeadingDotSlash(path));
})
}),
);
}

Expand Down Expand Up @@ -909,7 +908,7 @@ Arguments:
this.logger.log(
`You saved while Eleventy was running, let’s run again. (${queueSize} change${
queueSize !== 1 ? "s" : ""
})`
})`,
);
await this._watch();
} else {
Expand Down Expand Up @@ -947,7 +946,7 @@ Arguments:
this.watchTargets.add(await this.eleventyFiles.getGlobWatcherTemplateDataFiles());

let benchmark = this.watcherBench.get(
"Watching JavaScript Dependencies (disable with `eleventyConfig.setWatchJavaScriptDependencies(false)`)"
"Watching JavaScript Dependencies (disable with `eleventyConfig.setWatchJavaScriptDependencies(false)`)",
);
benchmark.before();
await this._initWatchDependencies();
Expand Down Expand Up @@ -996,15 +995,15 @@ Arguments:
// Config file dependencies
await this.watchTargets.addDependencies(
this.eleventyConfig.getLocalProjectConfigFiles(),
filterOutGlobalDataFiles
filterOutGlobalDataFiles,
);

// Deps from Global Data (that aren’t in the global data directory, everything is watched there)
let globalDataDeps = this.templateData.getWatchPathCache();
await this.watchTargets.addDependencies(globalDataDeps, filterOutGlobalDataFiles);

await this.watchTargets.addDependencies(
await this.eleventyFiles.getWatcherTemplateJavaScriptDataFiles()
await this.eleventyFiles.getWatcherTemplateJavaScriptDataFiles(),
);
}

Expand Down Expand Up @@ -1038,7 +1037,7 @@ Arguments:
pollInterval: 25,
},
},
configOptions
configOptions,
);
}

Expand Down Expand Up @@ -1205,9 +1204,9 @@ Arguments:
if (!this.writer) {
this.errorHandler.fatal(
new Error(
"Eleventy didn’t run init() properly and wasn’t able to create a TemplateWriter."
"Eleventy didn’t run init() properly and wasn’t able to create a TemplateWriter.",
),
"Problem writing Eleventy templates"
"Problem writing Eleventy templates",
);
}

Expand Down Expand Up @@ -1239,7 +1238,7 @@ Arguments:
promise = this.writer.getJSON("ndjson");
} else {
throw new Error(
`Invalid argument for \`Eleventy->executeBuild(${to})\`, expected "json", "ndjson", or "fs".`
`Invalid argument for \`Eleventy->executeBuild(${to})\`, expected "json", "ndjson", or "fs".`,
);
}

Expand Down

0 comments on commit eee7719

Please sign in to comment.