-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…-of-paraglide-translation-files-since speed up compiler
- Loading branch information
Showing
13 changed files
with
129 additions
and
188 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,5 @@ | ||
--- | ||
"@inlang/sdk": patch | ||
--- | ||
|
||
improve performance: only write db changes to lix on close |
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,5 @@ | ||
--- | ||
"@lix-js/sdk": patch | ||
--- | ||
|
||
fix: account for db close via "driver has already been destroyed" in file queue |
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,15 @@ | ||
import { compile } from "@inlang/paraglide-js/compiler"; | ||
|
||
console.log("Compiling project..."); | ||
|
||
const startTime = Date.now(); | ||
|
||
await compile({ | ||
project: "./project.inlang", | ||
outdir: "./src/paraglide", | ||
}); | ||
|
||
const endTime = Date.now(); | ||
|
||
console.log("Project compiled successfully!"); | ||
console.log(`Time taken: ${endTime - startTime}ms`); |
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
57 changes: 57 additions & 0 deletions
57
inlang/packages/paraglide-js/src/compiler/compile.bench.ts
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,57 @@ | ||
import { bench } from "vitest"; | ||
import nodeFs from "node:fs"; | ||
import path from "node:path"; | ||
import { memfs } from "memfs"; | ||
import { compile } from "./compile.js"; | ||
|
||
bench("compile 1000 messages", async () => { | ||
const numMessages = 1000; | ||
|
||
// the root of the repo | ||
const repositoryRoot = import.meta.url | ||
.slice(0, import.meta.url.lastIndexOf("inlang/packages")) | ||
.replace("file://", ""); | ||
|
||
// load the inlang message format plugin to simulate a real project | ||
const pluginAsText = nodeFs.readFileSync( | ||
path.join( | ||
repositoryRoot, | ||
"inlang/packages/plugins/inlang-message-format/dist/index.js" | ||
), | ||
"utf8" | ||
); | ||
|
||
const mockMessages = Object.fromEntries( | ||
Array.from({ length: numMessages }, (_, i) => [ | ||
`message_${i}`, | ||
`Hello world {username}`, | ||
]) | ||
); | ||
|
||
const fs = memfs({ | ||
"/plugin.js": pluginAsText, | ||
"/en.json": JSON.stringify(mockMessages), | ||
"/project.inlang/settings.json": JSON.stringify({ | ||
baseLocale: "en", | ||
locales: ["en"], | ||
modules: ["/plugin.js"], | ||
"plugin.inlang.messageFormat": { | ||
pathPattern: "/{locale}.json", | ||
}, | ||
}), | ||
}).fs as unknown as typeof import("node:fs"); | ||
|
||
const start = performance.now(); | ||
|
||
await compile({ | ||
project: "/project.inlang", | ||
outdir: "/output", | ||
fs: fs, | ||
}); | ||
|
||
const end = performance.now(); | ||
|
||
const duration = end - start; | ||
|
||
console.log(`Compiled ${numMessages} messages in ${duration}ms`); | ||
}); |
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
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,10 @@ | ||
import { defineConfig } from "vitest/config"; | ||
|
||
export default defineConfig({ | ||
test: { | ||
coverage: { | ||
include: ["src/**/*"], | ||
exclude: ["src/cli/**/*", "src/bundler-plugins/**/*"], | ||
}, | ||
}, | ||
}); |
93 changes: 0 additions & 93 deletions
93
inlang/packages/sdk/src/project/initHandleSaveToLixOnChange.ts
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.