@esportsplus/template 0.30.0 → 0.31.0
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/README.md +1 -1
- package/build/transformer/codegen.d.ts +1 -1
- package/build/transformer/codegen.js +1 -1
- package/build/transformer/index.d.ts +1 -1
- package/build/transformer/index.js +1 -1
- package/build/transformer/plugins/tsc.d.ts +1 -1
- package/build/transformer/plugins/vite.js +1 -1
- package/build/transformer/ts-parser.d.ts +1 -1
- package/build/transformer/ts-parser.js +1 -1
- package/build/transformer/type-analyzer.d.ts +1 -1
- package/build/transformer/type-analyzer.js +1 -1
- package/package.json +5 -10
- package/src/transformer/codegen.ts +1 -1
- package/src/transformer/index.ts +1 -1
- package/src/transformer/plugins/tsc.ts +1 -1
- package/src/transformer/plugins/vite.ts +1 -1
- package/src/transformer/ts-parser.ts +1 -1
- package/src/transformer/type-analyzer.ts +1 -1
- package/build/transformer/plugins/esbuild.d.ts +0 -5
- package/build/transformer/plugins/esbuild.js +0 -35
- package/src/transformer/plugins/esbuild.ts +0 -46
package/README.md
CHANGED
|
@@ -86,7 +86,7 @@ For direct `tsc` compilation, use the transformer factory:
|
|
|
86
86
|
Or programmatically:
|
|
87
87
|
|
|
88
88
|
```typescript
|
|
89
|
-
import ts from 'typescript';
|
|
89
|
+
import { ts } from '@esportsplus/typescript';
|
|
90
90
|
import templateTransformer from '@esportsplus/template/plugins/tsc';
|
|
91
91
|
|
|
92
92
|
const program = ts.createProgram(['src/index.ts'], {});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { addImport, applyReplacementsReverse, uid } from '@esportsplus/typescript/transformer';
|
|
2
2
|
import { analyzeExpression, generateAttributeBinding, generateSpreadBindings } from './type-analyzer.js';
|
|
3
|
-
import ts from 'typescript';
|
|
3
|
+
import { ts } from '@esportsplus/typescript';
|
|
4
4
|
import parser from './parser.js';
|
|
5
5
|
const ARROW_EMPTY_PARAMS = /\(\s*\)\s*=>\s*$/;
|
|
6
6
|
let currentChecker, hoistedFactories = new Map(), htmlToTemplateId = new Map(), nameArraySlot = '', nameAttr = '', nameEffectSlot = '', nameEvent = '', nameSlot = '', nameTemplate = '', needsArraySlot = false, needsAttr = false, needsEffectSlot = false, needsEvent = false, needsSlot = false;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mightNeedTransform } from '@esportsplus/typescript/transformer';
|
|
2
2
|
import { addArraySlotImport, generateCode, generateReactiveInlining, needsArraySlotImport, setTypeChecker } from './codegen.js';
|
|
3
3
|
import { findHtmlTemplates, findReactiveCalls } from './ts-parser.js';
|
|
4
|
-
import ts from 'typescript';
|
|
4
|
+
import { ts } from '@esportsplus/typescript';
|
|
5
5
|
const PATTERNS = ['html`', 'html.reactive'];
|
|
6
6
|
function createTransformer(program) {
|
|
7
7
|
let typeChecker = program.getTypeChecker();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mightNeedTransform, PATTERNS, transform } from '../index.js';
|
|
2
2
|
import { program, TRANSFORM_PATTERN } from '@esportsplus/typescript/transformer';
|
|
3
|
-
import ts from 'typescript';
|
|
3
|
+
import { ts } from '@esportsplus/typescript';
|
|
4
4
|
export default (options) => {
|
|
5
5
|
let root;
|
|
6
6
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import ts from 'typescript';
|
|
1
|
+
import { ts } from '@esportsplus/typescript';
|
|
2
2
|
type SlotType = 'array-slot' | 'document-fragment' | 'effect' | 'node' | 'primitive' | 'static' | 'unknown';
|
|
3
3
|
declare const analyzeExpression: (expr: ts.Expression, checker?: ts.TypeChecker) => SlotType;
|
|
4
4
|
declare const generateAttributeBinding: (elementVar: string, name: string, expr: string, staticValue: string) => string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getNames } from './codegen.js';
|
|
2
2
|
import { DIRECT_ATTACH_EVENTS, LIFECYCLE_EVENTS } from '../event/constants.js';
|
|
3
|
-
import ts from 'typescript';
|
|
3
|
+
import { ts } from '@esportsplus/typescript';
|
|
4
4
|
function analyzeSpread(expr, checker) {
|
|
5
5
|
while (ts.isParenthesizedExpression(expr)) {
|
|
6
6
|
expr = expr.expression;
|
package/package.json
CHANGED
|
@@ -2,15 +2,13 @@
|
|
|
2
2
|
"author": "ICJR",
|
|
3
3
|
"dependencies": {
|
|
4
4
|
"@esportsplus/queue": "^0.2.0",
|
|
5
|
-
"@esportsplus/reactivity": "^0.23.
|
|
5
|
+
"@esportsplus/reactivity": "^0.23.5",
|
|
6
6
|
"@esportsplus/utilities": "^0.27.2",
|
|
7
7
|
"serve": "^14.2.5"
|
|
8
8
|
},
|
|
9
9
|
"devDependencies": {
|
|
10
|
-
"@esportsplus/typescript": "^0.
|
|
10
|
+
"@esportsplus/typescript": "^0.15.0",
|
|
11
11
|
"@types/node": "^25.0.3",
|
|
12
|
-
"esbuild": "^0.27.2",
|
|
13
|
-
"typescript": "^5.9.3",
|
|
14
12
|
"vite": "^7.3.0",
|
|
15
13
|
"vite-tsconfig-paths": "^6.0.3"
|
|
16
14
|
},
|
|
@@ -23,12 +21,9 @@
|
|
|
23
21
|
"import": "./build/constants.js",
|
|
24
22
|
"types": "./build/constants.d.ts"
|
|
25
23
|
},
|
|
26
|
-
"./plugins/esbuild": {
|
|
27
|
-
"import": "./build/transformer/plugins/esbuild.js",
|
|
28
|
-
"types": "./build/transformer/plugins/esbuild.d.ts"
|
|
29
|
-
},
|
|
30
24
|
"./plugins/tsc": {
|
|
31
25
|
"import": "./build/transformer/plugins/tsc.js",
|
|
26
|
+
"require": "./build/transformer/plugins/tsc.js",
|
|
32
27
|
"types": "./build/transformer/plugins/tsc.d.ts"
|
|
33
28
|
},
|
|
34
29
|
"./plugins/vite": {
|
|
@@ -45,9 +40,9 @@
|
|
|
45
40
|
},
|
|
46
41
|
"type": "module",
|
|
47
42
|
"types": "./build/index.d.ts",
|
|
48
|
-
"version": "0.
|
|
43
|
+
"version": "0.31.0",
|
|
49
44
|
"scripts": {
|
|
50
|
-
"build": "tsc
|
|
45
|
+
"build": "tsc",
|
|
51
46
|
"build:test": "vite build --config test/vite.config.ts",
|
|
52
47
|
"-": "-"
|
|
53
48
|
}
|
|
@@ -2,7 +2,7 @@ import { addImport, applyReplacementsReverse, uid } from '@esportsplus/typescrip
|
|
|
2
2
|
import type { Replacement } from '@esportsplus/typescript/transformer';
|
|
3
3
|
import type { ReactiveCallInfo, TemplateInfo } from './ts-parser';
|
|
4
4
|
import { analyzeExpression, generateAttributeBinding, generateSpreadBindings } from './type-analyzer';
|
|
5
|
-
import ts from 'typescript';
|
|
5
|
+
import { ts } from '@esportsplus/typescript';
|
|
6
6
|
import parser from './parser';
|
|
7
7
|
|
|
8
8
|
|
package/src/transformer/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mightNeedTransform } from '@esportsplus/typescript/transformer';
|
|
2
2
|
import { addArraySlotImport, generateCode, generateReactiveInlining, needsArraySlotImport, setTypeChecker } from './codegen';
|
|
3
3
|
import { findHtmlTemplates, findReactiveCalls } from './ts-parser';
|
|
4
|
-
import ts from 'typescript';
|
|
4
|
+
import { ts } from '@esportsplus/typescript';
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
type TransformResult = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mightNeedTransform, PATTERNS, transform } from '../index';
|
|
2
2
|
import { program, TRANSFORM_PATTERN } from '@esportsplus/typescript/transformer';
|
|
3
3
|
import type { Plugin, ResolvedConfig } from 'vite';
|
|
4
|
-
import ts from 'typescript';
|
|
4
|
+
import { ts } from '@esportsplus/typescript';
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
export default (options?: { root?: string }): Plugin => {
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { mightNeedTransform, PATTERNS, transform } from '../index.js';
|
|
2
|
-
import { program, TRANSFORM_PATTERN } from '@esportsplus/typescript/transformer';
|
|
3
|
-
import fs from 'fs';
|
|
4
|
-
import ts from 'typescript';
|
|
5
|
-
export default (options) => {
|
|
6
|
-
let root = options?.root ?? process.cwd();
|
|
7
|
-
return {
|
|
8
|
-
name: '@esportsplus/template/plugin-esbuild',
|
|
9
|
-
setup(build) {
|
|
10
|
-
build.onLoad({ filter: TRANSFORM_PATTERN }, async (args) => {
|
|
11
|
-
let code = await fs.promises.readFile(args.path, 'utf8');
|
|
12
|
-
if (!mightNeedTransform(code, { patterns: PATTERNS })) {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
try {
|
|
16
|
-
let sourceFile = ts.createSourceFile(args.path, code, ts.ScriptTarget.Latest, true), result = transform(sourceFile, program.get(root));
|
|
17
|
-
if (!result.changed) {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
return {
|
|
21
|
-
contents: result.code,
|
|
22
|
-
loader: args.path.endsWith('x') ? 'tsx' : 'ts'
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
catch (error) {
|
|
26
|
-
console.error(`@esportsplus/template: Error transforming ${args.path}:`, error);
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
build.onEnd(() => {
|
|
31
|
-
program.delete(root);
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { mightNeedTransform, PATTERNS, transform } from '../index';
|
|
2
|
-
import { program, TRANSFORM_PATTERN } from '@esportsplus/typescript/transformer';
|
|
3
|
-
import type { OnLoadArgs, Plugin, PluginBuild } from 'esbuild';
|
|
4
|
-
import fs from 'fs';
|
|
5
|
-
import ts from 'typescript';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export default (options?: { root?: string }): Plugin => {
|
|
9
|
-
let root = options?.root ?? process.cwd();
|
|
10
|
-
|
|
11
|
-
return {
|
|
12
|
-
name: '@esportsplus/template/plugin-esbuild',
|
|
13
|
-
|
|
14
|
-
setup(build: PluginBuild) {
|
|
15
|
-
build.onLoad({ filter: TRANSFORM_PATTERN }, async (args: OnLoadArgs) => {
|
|
16
|
-
let code = await fs.promises.readFile(args.path, 'utf8');
|
|
17
|
-
|
|
18
|
-
if (!mightNeedTransform(code, { patterns: PATTERNS })) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
try {
|
|
23
|
-
let sourceFile = ts.createSourceFile(args.path, code, ts.ScriptTarget.Latest, true),
|
|
24
|
-
result = transform(sourceFile, program.get(root));
|
|
25
|
-
|
|
26
|
-
if (!result.changed) {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return {
|
|
31
|
-
contents: result.code,
|
|
32
|
-
loader: args.path.endsWith('x') ? 'tsx' : 'ts'
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
console.error(`@esportsplus/template: Error transforming ${args.path}:`, error);
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
build.onEnd(() => {
|
|
42
|
-
program.delete(root);
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
};
|