Skip to content

Commit

Permalink
fix(content-collections): warn about allowJs only when content di…
Browse files Browse the repository at this point in the history
…rectory exists (#6293)

* warn only when `content` directory exists

* chore: changeset
  • Loading branch information
MoustaphaDev authored Feb 18, 2023
1 parent a857727 commit a156ecb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/kind-cameras-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Warn about setting the `allowJs` compiler option only when the `content` directory exists.
5 changes: 2 additions & 3 deletions packages/astro/src/content/server-listeners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand Down

0 comments on commit a156ecb

Please sign in to comment.