@esportsplus/reactivity 0.25.3 → 0.25.4
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/constants.d.ts +8 -1
- package/build/constants.js +8 -1
- package/build/index.d.ts +2 -2
- package/build/index.js +2 -2
- package/build/reactive/array.js +18 -27
- package/build/reactive/index.d.ts +14 -13
- package/build/reactive/index.js +2 -1
- package/build/system.d.ts +2 -2
- package/build/system.js +10 -10
- package/build/transformer/detector.d.ts +2 -2
- package/build/transformer/detector.js +14 -14
- package/build/transformer/index.d.ts +3 -7
- package/build/transformer/index.js +21 -39
- package/build/transformer/plugins/tsc.js +7 -2
- package/build/transformer/plugins/vite.js +7 -9
- package/build/transformer/transforms/array.d.ts +3 -3
- package/build/transformer/transforms/array.js +16 -22
- package/build/transformer/transforms/object.d.ts +3 -3
- package/build/transformer/transforms/object.js +40 -56
- package/build/transformer/transforms/primitives.d.ts +3 -3
- package/build/transformer/transforms/primitives.js +54 -112
- package/build/types.d.ts +2 -2
- package/package.json +6 -6
- package/readme.md +5 -5
- package/src/constants.ts +20 -13
- package/src/index.ts +2 -2
- package/src/reactive/array.ts +18 -32
- package/src/reactive/index.ts +18 -15
- package/src/system.ts +14 -21
- package/src/transformer/detector.ts +16 -25
- package/src/transformer/index.ts +24 -46
- package/src/transformer/plugins/tsc.ts +8 -2
- package/src/transformer/plugins/vite.ts +9 -12
- package/src/transformer/transforms/array.ts +20 -37
- package/src/transformer/transforms/object.ts +54 -78
- package/src/transformer/transforms/primitives.ts +65 -140
- package/src/types.ts +5 -3
- package/test/vite.config.ts +1 -1
- package/build/transformer/transforms/utilities.d.ts +0 -8
- package/build/transformer/transforms/utilities.js +0 -27
- package/src/transformer/transforms/utilities.ts +0 -45
- package/storage/tsc-transform-analysis-2026-01-04.md +0 -125
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { addImport, applyReplacements } from '@esportsplus/typescript/transformer';
|
|
2
|
-
const addMissingImports = (code, needed, extraImports) => {
|
|
3
|
-
let extraSpecifiers = new Set(), reactivitySpecifiers = [];
|
|
4
|
-
if (extraImports) {
|
|
5
|
-
for (let i = 0, n = extraImports.length; i < n; i++) {
|
|
6
|
-
extraSpecifiers.add(extraImports[i].specifier);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
for (let imp of needed) {
|
|
10
|
-
if (!extraSpecifiers.has(imp)) {
|
|
11
|
-
reactivitySpecifiers.push(imp);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
if (reactivitySpecifiers.length > 0) {
|
|
15
|
-
code = addImport(code, '@esportsplus/reactivity', reactivitySpecifiers);
|
|
16
|
-
}
|
|
17
|
-
if (extraImports) {
|
|
18
|
-
for (let i = 0, n = extraImports.length; i < n; i++) {
|
|
19
|
-
let extra = extraImports[i];
|
|
20
|
-
if (needed.has(extra.specifier)) {
|
|
21
|
-
code = addImport(code, extra.module, [extra.specifier]);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return code;
|
|
26
|
-
};
|
|
27
|
-
export { addMissingImports, applyReplacements };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { addImport, applyReplacements, type Replacement } from '@esportsplus/typescript/transformer';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type ExtraImport = {
|
|
5
|
-
module: string;
|
|
6
|
-
specifier: string;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const addMissingImports = (code: string, needed: Set<string>, extraImports?: ExtraImport[]): string => {
|
|
11
|
-
let extraSpecifiers = new Set<string>(),
|
|
12
|
-
reactivitySpecifiers: string[] = [];
|
|
13
|
-
|
|
14
|
-
if (extraImports) {
|
|
15
|
-
for (let i = 0, n = extraImports.length; i < n; i++) {
|
|
16
|
-
extraSpecifiers.add(extraImports[i].specifier);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
for (let imp of needed) {
|
|
21
|
-
if (!extraSpecifiers.has(imp)) {
|
|
22
|
-
reactivitySpecifiers.push(imp);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (reactivitySpecifiers.length > 0) {
|
|
27
|
-
code = addImport(code, '@esportsplus/reactivity', reactivitySpecifiers);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (extraImports) {
|
|
31
|
-
for (let i = 0, n = extraImports.length; i < n; i++) {
|
|
32
|
-
let extra = extraImports[i];
|
|
33
|
-
|
|
34
|
-
if (needed.has(extra.specifier)) {
|
|
35
|
-
code = addImport(code, extra.module, [extra.specifier]);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return code;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
export { addMissingImports, applyReplacements };
|
|
45
|
-
export type { ExtraImport, Replacement };
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
# TSC Transform Analysis Report: @esportsplus/reactivity
|
|
2
|
-
|
|
3
|
-
## Executive Summary
|
|
4
|
-
|
|
5
|
-
1. **The library build is working as designed** - the reactivity library itself doesn't need transformation
|
|
6
|
-
2. **Test build transformations work correctly** - vite plugin transforms `reactive()` calls
|
|
7
|
-
3. **Confusion point**: The library PROVIDES transformers, it doesn't CONSUME them
|
|
8
|
-
|
|
9
|
-
## Findings
|
|
10
|
-
|
|
11
|
-
### How @esportsplus/typescript Custom TSC Works
|
|
12
|
-
|
|
13
|
-
| File | Purpose |
|
|
14
|
-
|------|---------|
|
|
15
|
-
| [bin/tsc](node_modules/.pnpm/@esportsplus+typescript@0.17.3/node_modules/@esportsplus/typescript/bin/tsc) | Entry point - calls build/cli/tsc.js |
|
|
16
|
-
| [build/cli/tsc.js:122-137](node_modules/.pnpm/@esportsplus+typescript@0.17.3/node_modules/@esportsplus/typescript/build/cli/tsc.js#L122-L137) | Main logic - checks for plugins in tsconfig |
|
|
17
|
-
|
|
18
|
-
**Critical Logic** (cli/tsc.js:128-131):
|
|
19
|
-
```javascript
|
|
20
|
-
let plugins = getPlugins(tsconfig);
|
|
21
|
-
if (plugins.length === 0) {
|
|
22
|
-
passthrough(); // Falls back to standard tsc
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
**Plugin Detection** (cli/tsc.js:97-98):
|
|
28
|
-
```javascript
|
|
29
|
-
return config?.compilerOptions?.plugins?.filter(
|
|
30
|
-
(p) => typeof p === 'object' && p !== null && 'transform' in p
|
|
31
|
-
) ?? [];
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
### Why Library Build Has No Transformations
|
|
35
|
-
|
|
36
|
-
| Issue | Evidence |
|
|
37
|
-
|-------|----------|
|
|
38
|
-
| No plugins configured | [tsconfig.json:1-3](tsconfig.json#L1-L3) only extends base config, no `compilerOptions.plugins` |
|
|
39
|
-
| Library defines `reactive()` | [src/reactive/index.ts:42-47](src/reactive/index.ts#L42-L47) - throws at runtime by design |
|
|
40
|
-
| Library doesn't use `reactive()` | Source files don't call `reactive()` as a consumer would |
|
|
41
|
-
|
|
42
|
-
### Test Build Works Correctly
|
|
43
|
-
|
|
44
|
-
**Source** ([test/primitives.ts:11](test/primitives.ts#L11)):
|
|
45
|
-
```typescript
|
|
46
|
-
let count = reactive(0);
|
|
47
|
-
count = 10;
|
|
48
|
-
console.log('Initial count:', count);
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
**Transformed Output** ([test/build/primitives.js:48-51](test/build/primitives.js#L48-L51)):
|
|
52
|
-
```javascript
|
|
53
|
-
let count = signal(0);
|
|
54
|
-
set(count, 10);
|
|
55
|
-
console.log("Initial count:", read(count));
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
**Reactive Objects** transform to classes with signal-backed getters/setters:
|
|
59
|
-
```javascript
|
|
60
|
-
class ReactiveObject_xxx {
|
|
61
|
-
#count = signal(0);
|
|
62
|
-
get count() { return read(this.#count); }
|
|
63
|
-
set count(v) { set(this.#count, v); }
|
|
64
|
-
}
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
## Architecture
|
|
68
|
-
|
|
69
|
-
```
|
|
70
|
-
@esportsplus/reactivity
|
|
71
|
-
├── src/ # Library source (NOT transformed)
|
|
72
|
-
│ ├── reactive/ # reactive() function definition
|
|
73
|
-
│ └── transformer/ # Transformer implementation
|
|
74
|
-
│ └── plugins/
|
|
75
|
-
│ ├── tsc.ts # TSC plugin for consumers
|
|
76
|
-
│ └── vite.ts # Vite plugin for consumers
|
|
77
|
-
├── build/ # Compiled library (standard tsc output)
|
|
78
|
-
└── test/ # Test files USING reactive()
|
|
79
|
-
└── build/ # Transformed test output (via vite)
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
## Build Commands
|
|
83
|
-
|
|
84
|
-
| Command | What It Does | Uses Transformer? |
|
|
85
|
-
|---------|--------------|-------------------|
|
|
86
|
-
| `pnpm build` | Compiles library src/ to build/ | No - intentional |
|
|
87
|
-
| `pnpm build:test` | Compiles test/ via vite | Yes - via vite plugin |
|
|
88
|
-
|
|
89
|
-
## Expected Behavior
|
|
90
|
-
|
|
91
|
-
The reactivity library follows a **compile-time transformation** pattern:
|
|
92
|
-
|
|
93
|
-
1. **Library provides**: `reactive()` function + transformer plugins
|
|
94
|
-
2. **Consumers configure**: transformer plugin in their build (vite/tsc)
|
|
95
|
-
3. **At build time**: `reactive()` calls → signal/read/set/computed calls
|
|
96
|
-
4. **At runtime**: If transformation didn't happen, `reactive()` throws with helpful error
|
|
97
|
-
|
|
98
|
-
## If You Want TSC Plugins in Library Build
|
|
99
|
-
|
|
100
|
-
Add to [tsconfig.json](tsconfig.json):
|
|
101
|
-
```json
|
|
102
|
-
{
|
|
103
|
-
"extends": "@esportsplus/typescript/tsconfig.package.json",
|
|
104
|
-
"compilerOptions": {
|
|
105
|
-
"plugins": [
|
|
106
|
-
{ "transform": "@esportsplus/reactivity/plugins/tsc" }
|
|
107
|
-
]
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
**Note**: This would only affect files that actually use `reactive()` - the library source doesn't, so no change would occur.
|
|
113
|
-
|
|
114
|
-
## Recommended Actions
|
|
115
|
-
|
|
116
|
-
1. **If transformations ARE expected in library build**: Add plugins config to tsconfig.json
|
|
117
|
-
2. **If testing transformer**: Run `pnpm build:test` to see transformations
|
|
118
|
-
3. **If issue is in consuming project**: Ensure plugin is configured in consumer's build
|
|
119
|
-
|
|
120
|
-
## Next Steps
|
|
121
|
-
|
|
122
|
-
Clarify the specific scenario where transformations aren't working:
|
|
123
|
-
- "Show me the file that should be transformed"
|
|
124
|
-
- "What build command are you running?"
|
|
125
|
-
- "Is this the library or a consuming project?"
|