Skip to content

Commit c4084be

Browse files
author
smtdfc
committed
feat(compiler): Improve performace of reactive system
1 parent 7c51ba1 commit c4084be

4 files changed

Lines changed: 172 additions & 91 deletions

File tree

packages/compiler/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 smtdfc
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

packages/compiler/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rumious/compiler",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"description": "A compiler for the Rumious framework",
55
"license": "MIT",
66
"author": "smtdfc <me.smtdfc@gmail.com>",
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import * as t from '@babel/types';
2+
import _traverse, { NodePath } from '@babel/traverse';
3+
4+
const traverse = (typeof _traverse === 'function' ? _traverse : (_traverse as any).default) as any;
5+
6+
export class ExpressionTransform {
7+
transform(ast: t.Expression): [t.Expression, Set<t.Identifier>] {
8+
const deps = new Set < t.Identifier > ();
9+
const newAst = t.cloneNode(ast);
10+
11+
traverse(
12+
t.file(t.program([t.expressionStatement(newAst)])),
13+
{
14+
MemberExpression(path: NodePath < t.MemberExpression > ) {
15+
if (t.isIdentifier(path.node.property, { name: 'get' }) && !path.node.computed) {
16+
const obj = path.node.object;
17+
if (t.isIdentifier(obj)) {
18+
deps.add(obj);
19+
}
20+
}
21+
},
22+
},
23+
undefined,
24+
undefined
25+
);
26+
27+
return [
28+
t.arrowFunctionExpression([], newAst),
29+
deps
30+
];
31+
}
32+
}

0 commit comments

Comments
 (0)