Skip to content

Commit

Permalink
Optimize typia.llm.application<App>() function for bundling.
Browse files Browse the repository at this point in the history
Do not import `typia.llm.application<App>()` embeded function when no parameter argument assigned to reduce bundling size in the frontend application.
  • Loading branch information
samchon committed Sep 13, 2024
1 parent 9e0b22f commit b421278
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion benchmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@
"suppress-warnings": "^1.0.2",
"tstl": "^3.0.0",
"uuid": "^9.0.1",
"typia": "../typia-6.10.0.tgz"
"typia": "../typia-6.10.1-dev.20240913.tgz"
}
}
2 changes: 1 addition & 1 deletion errors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
"typescript": "^5.3.2"
},
"dependencies": {
"typia": "../typia-6.10.0.tgz"
"typia": "../typia-6.10.1-dev.20240913.tgz"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typia",
"version": "6.10.0",
"version": "6.10.1-dev.20240913",
"description": "Superfast runtime validators with only one line",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
10 changes: 3 additions & 7 deletions src/transformers/features/llm/LlmApplicationTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ export namespace LlmApplicationTransformer {
const schema: ILlmApplication = LlmApplicationProgrammer.write(
result.data,
);

const literal: ts.Expression = LiteralFactory.generate(schema);
if (!expression.arguments?.[0]) return literal;
return ExpressionFactory.selfCall(
ts.factory.createBlock(
[
Expand All @@ -68,12 +69,7 @@ export namespace LlmApplicationTransformer {
TypeFactory.keyword("any"),
),
undefined,
[
ts.factory.createIdentifier("app"),
...(expression.arguments?.[0]
? [expression.arguments[0]]
: []),
],
[ts.factory.createIdentifier("app"), expression.arguments[0]],
),
),
ts.factory.createReturnStatement(
Expand Down
2 changes: 1 addition & 1 deletion test-esm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@
"typescript": "^5.4.5"
},
"dependencies": {
"typia": "../typia-6.10.0.tgz"
"typia": "../typia-6.10.1-dev.20240913.tgz"
}
}
2 changes: 1 addition & 1 deletion test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@
"suppress-warnings": "^1.0.2",
"tstl": "^3.0.0",
"uuid": "^9.0.1",
"typia": "../typia-6.10.0.tgz"
"typia": "../typia-6.10.1-dev.20240913.tgz"
}
}

0 comments on commit b421278

Please sign in to comment.