@esportsplus/template 0.30.1 → 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 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,5 +1,5 @@
1
1
  import type { ReactiveCallInfo, TemplateInfo } from './ts-parser.js';
2
- import ts from 'typescript';
2
+ import { ts } from '@esportsplus/typescript';
3
3
  type CodegenResult = {
4
4
  changed: boolean;
5
5
  code: string;
@@ -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,5 +1,5 @@
1
1
  import { mightNeedTransform } from '@esportsplus/typescript/transformer';
2
- import ts from 'typescript';
2
+ import { ts } from '@esportsplus/typescript';
3
3
  type TransformResult = {
4
4
  changed: boolean;
5
5
  code: string;
@@ -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,3 +1,3 @@
1
- import ts from 'typescript';
1
+ import { ts } from '@esportsplus/typescript';
2
2
  declare const _default: (program: ts.Program) => ts.TransformerFactory<ts.SourceFile>;
3
3
  export default _default;
@@ -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 ReactiveCallInfo = {
3
3
  arrayArg: ts.Expression;
4
4
  callbackArg: ts.Expression;
@@ -1,4 +1,4 @@
1
- import ts from 'typescript';
1
+ import { ts } from '@esportsplus/typescript';
2
2
  function extractTemplateInfo(node, depth) {
3
3
  let expressions = [], literals = [], template = node.template;
4
4
  if (ts.isNoSubstitutionTemplateLiteral(template)) {
@@ -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.2",
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.13.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,10 +21,6 @@
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",
32
26
  "require": "./build/transformer/plugins/tsc.js",
@@ -46,9 +40,9 @@
46
40
  },
47
41
  "type": "module",
48
42
  "types": "./build/index.d.ts",
49
- "version": "0.30.1",
43
+ "version": "0.31.0",
50
44
  "scripts": {
51
- "build": "tsc && tsc-alias",
45
+ "build": "tsc",
52
46
  "build:test": "vite build --config test/vite.config.ts",
53
47
  "-": "-"
54
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
 
@@ -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,5 +1,5 @@
1
1
  import { createTransformer } from '../index';
2
- import ts from 'typescript';
2
+ import { ts } from '@esportsplus/typescript';
3
3
 
4
4
 
5
5
  export default (program: ts.Program): ts.TransformerFactory<ts.SourceFile> => {
@@ -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,4 +1,4 @@
1
- import ts from 'typescript';
1
+ import { ts } from '@esportsplus/typescript';
2
2
 
3
3
 
4
4
  type ReactiveCallInfo = {
@@ -1,6 +1,6 @@
1
1
  import { getNames } from './codegen';
2
2
  import { DIRECT_ATTACH_EVENTS, LIFECYCLE_EVENTS } from '../event/constants';
3
- import ts from 'typescript';
3
+ import { ts } from '@esportsplus/typescript';
4
4
 
5
5
 
6
6
  type AnalyzerContext = {
@@ -1,5 +0,0 @@
1
- import type { Plugin } from 'esbuild';
2
- declare const _default: (options?: {
3
- root?: string;
4
- }) => Plugin;
5
- export default _default;
@@ -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
- };