-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(localizations): Allow usage of subpath exports (#2236)
* feat(localizations): Allow usage of subpath exports The addition of `.gitignore` and `subpaths.mjs` is used to support Expo framework. This fix is also used in `@clerk/shared` package. original PR: #2046 Co-authored-by: Andrew <[email protected]> * update changeset --------- Co-authored-by: Andrew <[email protected]> Co-authored-by: Lennart <[email protected]>
- Loading branch information
1 parent
0551488
commit 2d383e4
Showing
7 changed files
with
119 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
'@clerk/localizations': patch | ||
--- | ||
|
||
The package now allows for [subpath exports](https://nodejs.org/api/packages.html#subpath-exports). You can now import specific languages like so: | ||
|
||
```diff | ||
# Single language | ||
- import { frFR } from "@clerk/localizations" | ||
+ import { frFR } from "@clerk/localizations/fr-FR" | ||
|
||
# Multiple languages | ||
- import { enUS, esES } from "@clerk/localizations" | ||
+ import { enUS } from "@clerk/localizations/en-US" | ||
+ import { esES } from "@clerk/localizations/es-ES" | ||
``` | ||
|
||
This helps with tree-shaking and will reduce your total bundle size in most cases. | ||
|
||
You can continue to use the top-level `@clerk/localizations` import as this is a non-breaking change. You can gradually opt-in to this optimization. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/*/ | ||
!/src/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// This file is a helper for the "subpath-workaround.mjs" script | ||
// We have to polyfill our "exports" subpaths :cry: | ||
|
||
export const subpathNames = [ | ||
'ar-SA', | ||
'cs-CZ', | ||
'da-DK', | ||
'de-DE', | ||
'el-GR', | ||
'en-US', | ||
'es-ES', | ||
'fr-FR', | ||
'he-IL', | ||
'it-IT', | ||
'ja-JP', | ||
'ko-KR', | ||
'nb-NO', | ||
'nl-NL', | ||
'pl-PL', | ||
'pt-BR', | ||
'pt-PT', | ||
'ro-RO', | ||
'ru-RU', | ||
'sk-SK', | ||
'sv-SE', | ||
'tr-TR', | ||
'uk-UA', | ||
'vi-VN', | ||
'zh-CN', | ||
'zh-TW', | ||
]; | ||
|
||
export const subpathFoldersBarrel = []; | ||
|
||
export const ignoredFolders = []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
import { defineConfig } from 'tsup'; | ||
|
||
export default defineConfig(() => { | ||
export default defineConfig(_overrideOptions => { | ||
const uiRetheme = process.env.CLERK_RETHEME === '1' || process.env.CLERK_RETHEME === 'true'; | ||
|
||
return { | ||
entry: { | ||
index: uiRetheme ? 'src/index.retheme.ts' : 'src/index.ts', | ||
}, | ||
minify: false, | ||
entry: uiRetheme | ||
? ['src', '!src/index.ts', '!src/en-US.ts'] | ||
: ['src', '!src/index.retheme.ts', '!src/en-US.retheme.ts'], | ||
format: ['cjs', 'esm'], | ||
bundle: true, | ||
clean: true, | ||
minify: false, | ||
sourcemap: true, | ||
format: ['cjs', 'esm'], | ||
legacyOutput: true, | ||
dts: true, | ||
splitting: false, | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters