From a156ecbb7f4df6a46124a9a12eb712f9163db2ed Mon Sep 17 00:00:00 2001 From: Happydev <81974850+MoustaphaDev@users.noreply.github.com> Date: Sat, 18 Feb 2023 14:24:33 +0000 Subject: [PATCH] fix(content-collections): warn about `allowJs` only when `content` directory exists (#6293) * warn only when `content` directory exists * chore: changeset --- .changeset/kind-cameras-type.md | 5 +++++ packages/astro/src/content/server-listeners.ts | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 .changeset/kind-cameras-type.md diff --git a/.changeset/kind-cameras-type.md b/.changeset/kind-cameras-type.md new file mode 100644 index 000000000000..7b4621cd3243 --- /dev/null +++ b/.changeset/kind-cameras-type.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Warn about setting the `allowJs` compiler option only when the `content` directory exists. \ No newline at end of file diff --git a/packages/astro/src/content/server-listeners.ts b/packages/astro/src/content/server-listeners.ts index 4631aa2bdda0..52efc0331449 100644 --- a/packages/astro/src/content/server-listeners.ts +++ b/packages/astro/src/content/server-listeners.ts @@ -25,9 +25,6 @@ export async function attachContentServerListeners({ }: ContentServerListenerParams) { const contentPaths = getContentPaths(settings.config, fs); - const maybeTsConfigStats = getTSConfigStatsWhenAllowJsFalse({ contentPaths, settings }); - if (maybeTsConfigStats) warnAllowJsIsFalse({ ...maybeTsConfigStats, logging }); - if (fs.existsSync(contentPaths.contentDir)) { info( logging, @@ -36,6 +33,8 @@ export async function attachContentServerListeners({ contentPaths.contentDir.href.replace(settings.config.root.href, '') )} for changes` ); + const maybeTsConfigStats = getTSConfigStatsWhenAllowJsFalse({ contentPaths, settings }); + if (maybeTsConfigStats) warnAllowJsIsFalse({ ...maybeTsConfigStats, logging }); await attachListeners(); } else { viteServer.watcher.on('addDir', contentDirListener);