From ea06cddcc3209c7eeceef6e413d2d096d59b9b36 Mon Sep 17 00:00:00 2001 From: LorisSigrist Date: Mon, 25 Mar 2024 15:59:36 +0100 Subject: [PATCH 1/3] Document `data` side-effect quirk --- .../paraglide/paraglide-js-adapter-sveltekit/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/README.md b/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/README.md index 218b14518c..7d2fcb3a17 100644 --- a/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/README.md +++ b/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/README.md @@ -309,10 +309,13 @@ export async function load({ depends }) { } ``` +There currently is a caveat with this. When switching languages, any side-effects triggererd by `data` changing will be run twice if the data is language dependent. Once with the new language + old data and then with the new language + new data. We're working to fix this. + ## Caveats 1. Links in the same Layout Component as `` will not be translated. This will also log a warngin in development. 2. Messages are not reactive. Don't use them in server-side module scope. +3. Sideeffects triggered by `data` changing will be run twice if the data is language dependent. ### Using messages in `+layout.svelte` From 7dce5819d1d257d69262a9b999e74487239cee49 Mon Sep 17 00:00:00 2001 From: LorisSigrist Date: Mon, 25 Mar 2024 16:00:09 +0100 Subject: [PATCH 2/3] Fix how `openRepository` is used in unplugin-plugin & paraglide init --- .changeset/mighty-brooms-leave.md | 6 ++++++ .../paraglide/paraglide-js-adapter-unplugin/src/index.ts | 2 +- .../paraglide/paraglide-js/src/cli/commands/init.ts | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changeset/mighty-brooms-leave.md diff --git a/.changeset/mighty-brooms-leave.md b/.changeset/mighty-brooms-leave.md new file mode 100644 index 0000000000..2bf55b745b --- /dev/null +++ b/.changeset/mighty-brooms-leave.md @@ -0,0 +1,6 @@ +--- +"@inlang/paraglide-js-adapter-unplugin": patch +"@inlang/paraglide-js": patch +--- + +fix `openRepository` crash in non-git environments diff --git a/inlang/source-code/paraglide/paraglide-js-adapter-unplugin/src/index.ts b/inlang/source-code/paraglide/paraglide-js-adapter-unplugin/src/index.ts index 4ca1cba8c3..e576933b84 100644 --- a/inlang/source-code/paraglide/paraglide-js-adapter-unplugin/src/index.ts +++ b/inlang/source-code/paraglide/paraglide-js-adapter-unplugin/src/index.ts @@ -64,7 +64,7 @@ export const paraglide = createUnplugin((config: UserConfig) => { const repoRoot = await findRepoRoot({ nodeishFs: fs, path: projectPath }) - const repo = await openRepository(repoRoot || process.cwd(), { + const repo = await openRepository(repoRoot || "file://" + process.cwd(), { nodeishFs: fs, }) diff --git a/inlang/source-code/paraglide/paraglide-js/src/cli/commands/init.ts b/inlang/source-code/paraglide/paraglide-js/src/cli/commands/init.ts index 35b557da1c..20f9655bbc 100644 --- a/inlang/source-code/paraglide/paraglide-js/src/cli/commands/init.ts +++ b/inlang/source-code/paraglide/paraglide-js/src/cli/commands/init.ts @@ -44,7 +44,7 @@ export const initCommand = new Command() // We are risking that there is no git repo. As long as we only use FS features and no Git features // from the SDK we should be fine. // Basic operations like `loadProject` should always work without a repo since it's used in CI. - const repo = await openRepository(repoRoot ?? process.cwd(), { + const repo = await openRepository(repoRoot ?? "file://" + process.cwd(), { nodeishFs: nodeFsPromises, }) From 5083daa3e1f5af75808baa50ca431a0f4d2e7c8f Mon Sep 17 00:00:00 2001 From: LorisSigrist Date: Mon, 25 Mar 2024 16:19:49 +0100 Subject: [PATCH 3/3] Change wording --- .../paraglide/paraglide-js-adapter-sveltekit/README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/README.md b/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/README.md index 7d2fcb3a17..aa181bbd43 100644 --- a/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/README.md +++ b/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/README.md @@ -309,13 +309,11 @@ export async function load({ depends }) { } ``` -There currently is a caveat with this. When switching languages, any side-effects triggererd by `data` changing will be run twice if the data is language dependent. Once with the new language + old data and then with the new language + new data. We're working to fix this. - ## Caveats 1. Links in the same Layout Component as `` will not be translated. This will also log a warngin in development. 2. Messages are not reactive. Don't use them in server-side module scope. -3. Sideeffects triggered by `data` changing will be run twice if the data is language dependent. +3. Sideeffects triggered by `data` will run on language changes even if the data didn't change. If the data is language-dependent the sideeffect will run twice. ### Using messages in `+layout.svelte`