@esportsplus/template 0.31.4 → 0.31.6
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.
|
@@ -3,6 +3,7 @@ import { analyzeExpression, generateAttributeBinding, generateSpreadBindings } f
|
|
|
3
3
|
import { ts } from '@esportsplus/typescript';
|
|
4
4
|
import parser from './parser.js';
|
|
5
5
|
const ARROW_EMPTY_PARAMS = /\(\s*\)\s*=>\s*$/;
|
|
6
|
+
const TEMPLATE_IMPORT = /import\s+\{[^}]*\}\s+from\s+['"]@esportsplus\/template['"];?\s*\n?/g;
|
|
6
7
|
let currentChecker, hoistedFactories = new Map(), htmlToTemplateId = new Map(), ns = '';
|
|
7
8
|
function collectNestedTemplateReplacements(node, exprStart, sourceFile, replacements) {
|
|
8
9
|
if (isNestedHtmlTemplate(node)) {
|
|
@@ -198,7 +199,7 @@ function rewriteExpression(expr, sourceFile) {
|
|
|
198
199
|
return applyReplacementsReverse(expr.getText(sourceFile), replacements);
|
|
199
200
|
}
|
|
200
201
|
const addArraySlotImport = (code) => {
|
|
201
|
-
return `import * as ${ns} from '@esportsplus/template';\n\n` + code;
|
|
202
|
+
return `import * as ${ns} from '@esportsplus/template';\n\n` + code.replace(TEMPLATE_IMPORT, '');
|
|
202
203
|
};
|
|
203
204
|
const generateCode = (templates, originalCode, sourceFile) => {
|
|
204
205
|
if (templates.length === 0) {
|
|
@@ -238,6 +239,7 @@ const generateCode = (templates, originalCode, sourceFile) => {
|
|
|
238
239
|
for (let [id, html] of hoistedFactories) {
|
|
239
240
|
factories.push(`const ${id} = ${ns}.template(\`${html}\`);`);
|
|
240
241
|
}
|
|
242
|
+
code = code.replace(TEMPLATE_IMPORT, '');
|
|
241
243
|
code = generateImports() + '\n\n' + factories.join('\n') + '\n\n' + code;
|
|
242
244
|
}
|
|
243
245
|
return { changed, code };
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"author": "ICJR",
|
|
3
3
|
"dependencies": {
|
|
4
4
|
"@esportsplus/queue": "^0.2.0",
|
|
5
|
-
"@esportsplus/reactivity": "^0.24.
|
|
5
|
+
"@esportsplus/reactivity": "^0.24.5",
|
|
6
6
|
"@esportsplus/utilities": "^0.27.2",
|
|
7
7
|
"serve": "^14.2.5"
|
|
8
8
|
},
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
},
|
|
41
41
|
"type": "module",
|
|
42
42
|
"types": "./build/index.d.ts",
|
|
43
|
-
"version": "0.31.
|
|
43
|
+
"version": "0.31.6",
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "tsc",
|
|
46
46
|
"build:test": "vite build --config test/vite.config.ts",
|
|
@@ -33,6 +33,8 @@ type ParseResult = {
|
|
|
33
33
|
|
|
34
34
|
const ARROW_EMPTY_PARAMS = /\(\s*\)\s*=>\s*$/;
|
|
35
35
|
|
|
36
|
+
const TEMPLATE_IMPORT = /import\s+\{[^}]*\}\s+from\s+['"]@esportsplus\/template['"];?\s*\n?/g;
|
|
37
|
+
|
|
36
38
|
|
|
37
39
|
let currentChecker: ts.TypeChecker | undefined,
|
|
38
40
|
hoistedFactories = new Map<string, string>(),
|
|
@@ -344,7 +346,8 @@ function rewriteExpression(expr: ts.Expression, sourceFile: ts.SourceFile): stri
|
|
|
344
346
|
|
|
345
347
|
|
|
346
348
|
const addArraySlotImport = (code: string): string => {
|
|
347
|
-
|
|
349
|
+
// Strip original @esportsplus/template imports (they lose symbol bindings in TS 5.9.3)
|
|
350
|
+
return `import * as ${ns} from '@esportsplus/template';\n\n` + code.replace(TEMPLATE_IMPORT, '');
|
|
348
351
|
};
|
|
349
352
|
|
|
350
353
|
const generateCode = (templates: TemplateInfo[], originalCode: string, sourceFile: ts.SourceFile): CodegenResult => {
|
|
@@ -409,6 +412,8 @@ const generateCode = (templates: TemplateInfo[], originalCode: string, sourceFil
|
|
|
409
412
|
factories.push(`const ${id} = ${ns}.template(\`${html}\`);`);
|
|
410
413
|
}
|
|
411
414
|
|
|
415
|
+
// Strip original @esportsplus/template imports (they lose symbol bindings in TS 5.9.3)
|
|
416
|
+
code = code.replace(TEMPLATE_IMPORT, '');
|
|
412
417
|
code = generateImports() + '\n\n' + factories.join('\n') + '\n\n' + code;
|
|
413
418
|
}
|
|
414
419
|
|