Skip to content

Commit 7b75d7c

Browse files
authored
Make formatter a required option for config bucket (#4)
* Make formatter a required option for config bucket, remove support for non js/ts config files
1 parent 0a4b8aa commit 7b75d7c

File tree

15 files changed

+36
-212
lines changed

15 files changed

+36
-212
lines changed

.changeset/plain-oranges-wonder.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@saykit/config": patch
3+
---
4+
5+
Make formatter a required option for config bucket

examples/carbon-tsdown/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"devDependencies": {
1919
"@cloudflare/workers-types": "^4.20260210.0",
2020
"@saykit/config": "workspace:^",
21+
"@saykit/format-po": "workspace:^",
2122
"typescript": "^5.9.3",
2223
"unplugin-saykit": "workspace:^",
2324
"wrangler": "^4.64.0"

examples/carbon-tsdown/saykit.config.json

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { defineConfig } from '@saykit/config';
2+
import createFormatter from '@saykit/format-po';
3+
4+
export default defineConfig({
5+
sourceLocale: 'en',
6+
locales: ['en', 'fr'],
7+
buckets: [
8+
{
9+
include: ['src/**/*.{ts,tsx}'],
10+
output: 'src/locales/{locale}/messages.{extension}',
11+
formatter: createFormatter(),
12+
},
13+
],
14+
});

examples/nextjs-babel/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"devDependencies": {
2121
"@saykit/babel-plugin": "workspace:^",
2222
"@saykit/config": "workspace:^",
23+
"@saykit/format-po": "workspace:^",
2324
"@types/react": "^19.2.13"
2425
}
2526
}

examples/nextjs-babel/saykit.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { defineConfig } from '@saykit/config';
2+
import createFormatter from '@saykit/format-po';
23

34
export default defineConfig({
45
sourceLocale: 'en',
@@ -7,6 +8,7 @@ export default defineConfig({
78
{
89
include: ['src/**/*.{ts,tsx}'],
910
output: 'src/locales/{locale}/messages.{extension}',
11+
formatter: createFormatter(),
1012
},
1113
],
1214
});

packages/config/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
"@commander-js/extra-typings": "^14.0.0",
4646
"@saykit/babel-plugin": "workspace:*",
4747
"commander": "^14.0.3",
48-
"neverthrow": "^8.2.0",
4948
"picomatch": "^4.0.3",
5049
"zod": "^4.3.6"
5150
},

packages/config/src/features/compile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export async function writeTranslationsToDisk(
6363
bucket: Bucket,
6464
locale: string,
6565
translations: Record<string, string>,
66-
path = expandOutputPath(bucket, locale, 'json'),
66+
path = expandOutputPath(bucket, locale, '.json'),
6767
) {
6868
const content = JSON.stringify(translations, null, 2);
6969
await mkdir(dirname(path), { recursive: true });

packages/config/src/features/extract.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export function expandOutputPath(
7272
) {
7373
const outputMessageTemplate = bucket.output
7474
.replaceAll('{locale}', locale)
75-
.replaceAll('{extension}', extension);
75+
.replaceAll('{extension}', extension.slice(1));
7676
return resolve(outputMessageTemplate);
7777
}
7878

packages/config/src/features/loader/explorer.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,12 @@ import { join } from 'node:path';
33

44
function getFilesToTry<Name extends string>(name: Name) {
55
return [
6-
`.${name}rc`,
7-
`.${name}rc.json`,
8-
`.${name}rc.yaml`,
9-
`.${name}rc.yml`,
10-
`.${name}rc.js`,
11-
`.${name}rc.cjs`,
12-
`.${name}rc.mjs`,
13-
`.${name}rc.ts`,
14-
`.${name}rc.mts`,
15-
`.${name}rc.cts`,
16-
17-
`${name}.config.json`,
186
`${name}.config.js`,
197
`${name}.config.cjs`,
208
`${name}.config.mjs`,
219
`${name}.config.ts`,
2210
`${name}.config.mts`,
2311
`${name}.config.cts`,
24-
25-
'package.json',
2612
] as const;
2713
}
2814

0 commit comments

Comments
 (0)