# importFiles

`function` in `utils` · v0.9.0

<https://seedcord.org/docs/packages/utils/0.9.0/functions/import-files>

Imports every .ts, .tsx, .mts, .js, .jsx or .mjs file under a directory, recursively and sorted by path, yielding each module in turn.
It skips type declarations, dotfiles, dot-folders and node_modules. A `break` stops the walk before the next import.
A relative `dir` resolves against `root` from seedcord.config.ts, whichever file calls this.

```ts
importFiles(
    dir: string
): AsyncGenerator<ImportedFile>
```

Imports every .ts, .tsx, .mts, .js, .jsx or .mjs file under a directory, recursively and sorted by path, yielding each module in turn.
It skips type declarations, dotfiles, dot-folders and node_modules. A `break` stops the walk before the next import.
A relative `dir` resolves against `root` from seedcord.config.ts, whichever file calls this.

Parameters.

- `dir` `string`

Returns `AsyncGenerator<ImportedFile>`.
