nuxt / content

The file-based CMS for your Nuxt application, powered by Markdown and Vue components.
https://content.nuxt.com
MIT License
3.07k stars 623 forks source link

Stop build with unsupported filenames #2609

Open KidSysco opened 5 months ago

KidSysco commented 5 months ago

Environment

Not needed.

Reproduction

Not needed.

Describe the bug

When there are .ts files in the content folder, we get a warning message in the Build console output from line 47 of content/src/runtime/transformers/index.ts...

https://github.com/nuxt/content/blob/f753723d3cd4d8f8a92d050b9be59489c522c35f/src/runtime/transformers/index.ts#L47

Perhaps this should throw an error to stop the build and force it to break.

Otherwise, here is the scenario that played out today, and could break production builds for others too...

When developing in dev mode, there is no warning about putting .ts files in the content folder. Everything just works perfectly. There are also no docs about keeping .ts files in the content folder.

When doing a build there is no error, only this one warning (from line 47) that is embedded within thousands of lines of build output, and the build does not fail.

CI or Devops thinks all is good. So they deploy the site to production where the website totally breaks because it cannot find the code it needs.

Additional context

If we don't stop the build when things are not correct, then it can lead to broken websites getting deployed to production. We should also add to the docs about unsupported file extensions in the content folder.

Logs

Not needed.
KidSysco commented 5 months ago

Why did I have .ts files in the content folder?

Because we are implementing I18n, which calls for language files. While these files are TS, they look, and feel a lot like typical content files. So we figured the content folder was a really good fit. It worked perfectly in dev, broke badly in production.