Skip to content

Commit

Permalink
fix(localizations): Fix building of retheme subpath exports
Browse files Browse the repository at this point in the history
Before the localizations subpath exports change
we had a single entrypoint, the `index`. Based
on the CLERK_RETHEME env we were using the
index.retheme.ts or the index.ts as entrypoint
during build. To support that type of conditional
output for all the exported subpaths we need to
either define a callback to replace the *.retheme
files with the *.ts files or conditional choose them
in buiild configuration.
Due to some issues with the tsup `onSuccess` callback
i manually defined all the subpath exports.

We need to be careful in the future and add the new
localization files in both package.json#files, tsup.config.ts
and in subpaths.mjs file to support subpath
exports successfully
  • Loading branch information
dimkl committed Dec 1, 2023
1 parent 0d52e23 commit d208107
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .changeset/slimy-brooms-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
32 changes: 29 additions & 3 deletions packages/localizations/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,35 @@ export default defineConfig(_overrideOptions => {
const uiRetheme = process.env.CLERK_RETHEME === '1' || process.env.CLERK_RETHEME === 'true';

return {
entry: uiRetheme
? ['src', '!src/index.ts', '!src/en-US.ts']
: ['src', '!src/index.retheme.ts', '!src/en-US.retheme.ts'],
entry: {
index: uiRetheme ? 'src/index.retheme.ts' : 'src/index.ts',
'en-US': uiRetheme ? 'src/en-US.retheme.ts' : 'src/en-US.ts',
'ar-SA': 'src/ar-SA.ts',
'cs-CZ': 'src/cs-CZ.ts',
'da-DK': 'src/da-DK.ts',
'de-DE': 'src/de-DE.ts',
'el-GR': 'src/el-GR.ts',
'es-ES': 'src/es-ES.ts',
'fr-FR': 'src/fr-FR.ts',
'he-IL': 'src/he-IL.ts',
'it-IT': 'src/it-IT.ts',
'ja-JP': 'src/ja-JP.ts',
'ko-KR': 'src/ko-KR.ts',
'nb-NO': 'src/nb-NO.ts',
'nl-NL': 'src/nl-NL.ts',
'pl-PL': 'src/pl-PL.ts',
'pt-BR': 'src/pt-BR.ts',
'pt-PT': 'src/pt-PT.ts',
'ro-RO': 'src/ro-RO.ts',
'ru-RU': 'src/ru-RU.ts',
'sk-SK': 'src/sk-SK.ts',
'sv-SE': 'src/sv-SE.ts',
'tr-TR': 'src/tr-TR.ts',
'uk-UA': 'src/uk-UA.ts',
'vi-VN': 'src/vi-VN.ts',
'zh-CN': 'src/zh-CN.ts',
'zh-TW': 'src/zh-TW.ts',
},
format: ['cjs', 'esm'],
bundle: true,
clean: true,
Expand Down

0 comments on commit d208107

Please sign in to comment.