Skip to content

Commit

Permalink
Update three-olives-reflect.md
Browse files Browse the repository at this point in the history
  • Loading branch information
florian-lefebvre authored Sep 18, 2024
1 parent 3edbe68 commit 0c30ceb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions .changeset/three-olives-reflect.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
'astro': minor
---

Adds `codegenDir` to integrations `astro:config:setup` hook
Adds a new `codegenDir` URL to integrations `astro:config:setup` hook

In 4.14, we introduced `injectTypes` on `astro:config:done`. Under the hood, it creates a file at `<root>/.astro/integrations/<normalized_integration_name>`.
In 4.14, we introduced the `injectTypes` utility on the `astro:config:done` hook. It allows to create `.d.ts` files and make their types available to users projects automatically. Under the hood, it creates a file in `<root>/.astro/integrations/<normalized_integration_name>`.

In this release, the folder URL is now available in `astro:config:setup` as `codegenDir`. It allows you to have space without risking being overriden by another integration, Astro or overriding another integration. This directory is always created before any hook so it's safe to write files directly:
While `.astro` has always been the preferred place to write code generated files, it has also been prone to mistakes. For example, you can write a `.astro/types.d.ts` file, breaking Astro types. Or you can create a file that overrides a file created by another integration.

In this release, `<root>/.astro/integrations/<normalized_integration_name>` is now exposed in the `astro:config:setup` hook as `codegenDir`. It allows you to have a dedicated folder, avoiding conflicts with another integration or Astro. This directory is always created before any hook runs so it's safe to write files to it directly:

```js
import { writeFileSync } from 'node:fs'
Expand Down

0 comments on commit 0c30ceb

Please sign in to comment.