@esportsplus/reactivity 0.25.11 → 0.25.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/transformer/index.js +5 -5
- package/build/transformer/plugins/tsc.d.ts +2 -2
- package/build/transformer/plugins/tsc.js +3 -9
- package/build/transformer/plugins/vite.d.ts +12 -2
- package/build/transformer/plugins/vite.js +6 -25
- package/build/types.d.ts +1 -1
- package/package.json +2 -2
- package/src/transformer/index.ts +6 -6
- package/src/transformer/plugins/tsc.ts +3 -12
- package/src/transformer/plugins/vite.ts +7 -32
- package/src/types.ts +1 -1
|
@@ -40,22 +40,22 @@ function visit(ctx, node) {
|
|
|
40
40
|
ts.forEachChild(node, n => visit(ctx, n));
|
|
41
41
|
}
|
|
42
42
|
const transform = (sourceFile) => {
|
|
43
|
-
let bindings = new Map(), code = sourceFile.getFullText(), current = sourceFile, result
|
|
43
|
+
let bindings = new Map(), changed = false, code = sourceFile.getFullText(), current = sourceFile, result;
|
|
44
44
|
if (!contains(code)) {
|
|
45
|
-
return { code, sourceFile
|
|
45
|
+
return { changed: false, code, sourceFile };
|
|
46
46
|
}
|
|
47
47
|
for (let i = 0, n = transforms.length; i < n; i++) {
|
|
48
48
|
result = transforms[i](current, bindings, COMPILER_NAMESPACE);
|
|
49
49
|
if (result !== code) {
|
|
50
50
|
current = ts.createSourceFile(sourceFile.fileName, result, sourceFile.languageVersion, true);
|
|
51
51
|
code = result;
|
|
52
|
-
|
|
52
|
+
changed = true;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
if (
|
|
55
|
+
if (changed) {
|
|
56
56
|
code = `import * as ${COMPILER_NAMESPACE} from '@esportsplus/reactivity';\n` + code;
|
|
57
57
|
sourceFile = ts.createSourceFile(sourceFile.fileName, code, sourceFile.languageVersion, true);
|
|
58
58
|
}
|
|
59
|
-
return { code, sourceFile
|
|
59
|
+
return { changed, code, sourceFile };
|
|
60
60
|
};
|
|
61
61
|
export { transform };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const _default:
|
|
1
|
+
import { plugin } from '@esportsplus/typescript/transformer';
|
|
2
|
+
declare const _default: ReturnType<typeof plugin.tsc>;
|
|
3
3
|
export default _default;
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return (sourceFile) => {
|
|
5
|
-
let result = transform(sourceFile);
|
|
6
|
-
return result.transformed ? result.sourceFile : sourceFile;
|
|
7
|
-
};
|
|
8
|
-
};
|
|
9
|
-
};
|
|
1
|
+
import { plugin } from '@esportsplus/typescript/transformer';
|
|
2
|
+
import { transform } from '../index.js';
|
|
3
|
+
export default plugin.tsc(transform);
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
declare const _default: ({ root }?: {
|
|
2
|
+
root?: string;
|
|
3
|
+
}) => {
|
|
4
|
+
configResolved(config: import("vite").ResolvedConfig): void;
|
|
5
|
+
enforce: string;
|
|
6
|
+
name: string;
|
|
7
|
+
transform(code: string, id: string): {
|
|
8
|
+
code: string;
|
|
9
|
+
map: null;
|
|
10
|
+
} | null;
|
|
11
|
+
watchChange(id: string): void;
|
|
12
|
+
};
|
|
3
13
|
export default _default;
|
|
@@ -1,26 +1,7 @@
|
|
|
1
|
-
import { ts } from '@esportsplus/typescript';
|
|
2
|
-
import { TRANSFORM_PATTERN } from '@esportsplus/typescript/transformer';
|
|
3
|
-
import { transform } from '../../transformer/index.js';
|
|
4
1
|
import { PACKAGE } from '../../constants.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
try {
|
|
14
|
-
let result = transform(ts.createSourceFile(id, code, ts.ScriptTarget.Latest, true));
|
|
15
|
-
if (!result.transformed) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
return { code: result.code, map: null };
|
|
19
|
-
}
|
|
20
|
-
catch (error) {
|
|
21
|
-
console.error(`${PACKAGE}: Error transforming ${id}:`, error);
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
};
|
|
2
|
+
import { plugin } from '@esportsplus/typescript/transformer';
|
|
3
|
+
import { transform } from '../index.js';
|
|
4
|
+
export default plugin.vite({
|
|
5
|
+
name: PACKAGE,
|
|
6
|
+
transform
|
|
7
|
+
});
|
package/build/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"@esportsplus/utilities": "^0.27.2"
|
|
5
5
|
},
|
|
6
6
|
"devDependencies": {
|
|
7
|
-
"@esportsplus/typescript": "^0.
|
|
7
|
+
"@esportsplus/typescript": "^0.18.0",
|
|
8
8
|
"@types/node": "^25.0.3",
|
|
9
9
|
"vite": "^7.3.0"
|
|
10
10
|
},
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"type": "module",
|
|
38
38
|
"types": "build/index.d.ts",
|
|
39
|
-
"version": "0.25.
|
|
39
|
+
"version": "0.25.13",
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "tsc",
|
|
42
42
|
"build:test": "pnpm build && vite build --config test/vite.config.ts",
|
package/src/transformer/index.ts
CHANGED
|
@@ -61,13 +61,13 @@ function visit(ctx: { imported: boolean; used: boolean; }, node: ts.Node): void
|
|
|
61
61
|
|
|
62
62
|
const transform = (sourceFile: ts.SourceFile): TransformResult => {
|
|
63
63
|
let bindings: Bindings = new Map(),
|
|
64
|
+
changed = false,
|
|
64
65
|
code = sourceFile.getFullText(),
|
|
65
66
|
current = sourceFile,
|
|
66
|
-
result: string
|
|
67
|
-
transformed = false;
|
|
67
|
+
result: string;
|
|
68
68
|
|
|
69
69
|
if (!contains(code)) {
|
|
70
|
-
return { code, sourceFile
|
|
70
|
+
return { changed: false, code, sourceFile };
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
for (let i = 0, n = transforms.length; i < n; i++) {
|
|
@@ -76,16 +76,16 @@ const transform = (sourceFile: ts.SourceFile): TransformResult => {
|
|
|
76
76
|
if (result !== code) {
|
|
77
77
|
current = ts.createSourceFile(sourceFile.fileName, result, sourceFile.languageVersion, true);
|
|
78
78
|
code = result;
|
|
79
|
-
|
|
79
|
+
changed = true;
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
if (
|
|
83
|
+
if (changed) {
|
|
84
84
|
code = `import * as ${COMPILER_NAMESPACE} from '@esportsplus/reactivity';\n` + code;
|
|
85
85
|
sourceFile = ts.createSourceFile(sourceFile.fileName, code, sourceFile.languageVersion, true);
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
return { code, sourceFile
|
|
88
|
+
return { changed, code, sourceFile };
|
|
89
89
|
};
|
|
90
90
|
|
|
91
91
|
|
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { plugin } from '@esportsplus/typescript/transformer';
|
|
2
|
+
import { transform } from '..';
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
export default (_program: ts.Program): ts.TransformerFactory<ts.SourceFile> => {
|
|
7
|
-
return () => {
|
|
8
|
-
return (sourceFile: ts.SourceFile): ts.SourceFile => {
|
|
9
|
-
let result = transform(sourceFile);
|
|
10
|
-
|
|
11
|
-
return result.transformed ? result.sourceFile : sourceFile;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
};
|
|
5
|
+
export default plugin.tsc(transform) as ReturnType<typeof plugin.tsc>;
|
|
@@ -1,34 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { transform } from '~/transformer';
|
|
5
|
-
import { PACKAGE } from '~/constants';
|
|
1
|
+
import { PACKAGE } from '../../constants';
|
|
2
|
+
import { plugin } from '@esportsplus/typescript/transformer';
|
|
3
|
+
import { transform } from '..';
|
|
6
4
|
|
|
7
5
|
|
|
8
|
-
export default (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
transform(code: string, id: string) {
|
|
13
|
-
if (!TRANSFORM_PATTERN.test(id) || id.includes('node_modules')) {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
try {
|
|
18
|
-
let result = transform(
|
|
19
|
-
ts.createSourceFile(id, code, ts.ScriptTarget.Latest, true)
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
if (!result.transformed) {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return { code: result.code, map: null };
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
console.error(`${PACKAGE}: Error transforming ${id}:`, error);
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
};
|
|
6
|
+
export default plugin.vite({
|
|
7
|
+
name: PACKAGE,
|
|
8
|
+
transform
|
|
9
|
+
});
|