@barefootjs/hono 0.31.3 → 0.31.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/dist/adapter/hono-adapter.d.ts.map +1 -1
- package/dist/adapter/index.js +6 -3
- package/dist/index.js +6 -3
- package/dist/vite.js +141 -86
- package/package.json +2 -2
- package/src/adapter/hono-adapter.ts +14 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hono-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/hono-adapter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,MAAM,EACX,KAAK,SAAS,EACd,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,MAAM,EACX,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,KAAK,MAAM,EAIX,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAElB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,UAAU,EAEf,UAAU,
|
|
1
|
+
{"version":3,"file":"hono-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/hono-adapter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,MAAM,EACX,KAAK,SAAS,EACd,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,MAAM,EACX,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,KAAK,MAAM,EAIX,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAElB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,UAAU,EAEf,UAAU,EAQX,MAAM,iBAAiB,CAAA;AAExB;;;;;GAKG;AACH,KAAK,aA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yB5B,OAAO,CAAC,iBAAiB;IAYzB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,0BAA0B;CAInC;AAGD,eAAO,MAAM,WAAW,aAAoB,CAAA"}
|
package/dist/adapter/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
JsxAdapter,
|
|
4
4
|
isBooleanAttr,
|
|
5
5
|
rewriteImportsForTemplate,
|
|
6
|
+
rewriteDynamicImportsInSource,
|
|
6
7
|
emitIRNode,
|
|
7
8
|
emitAttrValue,
|
|
8
9
|
buildLoopChainExpr,
|
|
@@ -53,9 +54,11 @@ class HonoAdapter extends JsxAdapter {
|
|
|
53
54
|
this.scriptAssets = options?.scriptAssets;
|
|
54
55
|
this.preloadAssets = options?.preloadAssets;
|
|
55
56
|
}
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
const
|
|
57
|
+
const reanchor = this.rewriteRelativeImport;
|
|
58
|
+
const withRewrittenDynamicImports = (text) => reanchor && text ? rewriteDynamicImportsInSource(text, reanchor) : text;
|
|
59
|
+
const component = withRewrittenDynamicImports(this.generateComponent(ir));
|
|
60
|
+
const types = withRewrittenDynamicImports(this.generateTypes(ir));
|
|
61
|
+
const moduleConstants = withRewrittenDynamicImports(this.generateModuleScopeDeclarations(ir));
|
|
59
62
|
const componentCode = [moduleConstants, types, component].filter(Boolean).join(`
|
|
60
63
|
`);
|
|
61
64
|
const imports = this.generateImports(ir, componentCode);
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
JsxAdapter,
|
|
4
4
|
isBooleanAttr,
|
|
5
5
|
rewriteImportsForTemplate,
|
|
6
|
+
rewriteDynamicImportsInSource,
|
|
6
7
|
emitIRNode,
|
|
7
8
|
emitAttrValue,
|
|
8
9
|
buildLoopChainExpr,
|
|
@@ -53,9 +54,11 @@ class HonoAdapter extends JsxAdapter {
|
|
|
53
54
|
this.scriptAssets = options?.scriptAssets;
|
|
54
55
|
this.preloadAssets = options?.preloadAssets;
|
|
55
56
|
}
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
const
|
|
57
|
+
const reanchor = this.rewriteRelativeImport;
|
|
58
|
+
const withRewrittenDynamicImports = (text) => reanchor && text ? rewriteDynamicImportsInSource(text, reanchor) : text;
|
|
59
|
+
const component = withRewrittenDynamicImports(this.generateComponent(ir));
|
|
60
|
+
const types = withRewrittenDynamicImports(this.generateTypes(ir));
|
|
61
|
+
const moduleConstants = withRewrittenDynamicImports(this.generateModuleScopeDeclarations(ir));
|
|
59
62
|
const componentCode = [moduleConstants, types, component].filter(Boolean).join(`
|
|
60
63
|
`);
|
|
61
64
|
const imports = this.generateImports(ir, componentCode);
|
package/dist/vite.js
CHANGED
|
@@ -124,6 +124,20 @@ function templatePartsToJsExpr(parts, opts) {
|
|
|
124
124
|
return result;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
// ../jsx/src/identifier-pattern.ts
|
|
128
|
+
function withUnicodeFlag(flags) {
|
|
129
|
+
return flags.includes("u") ? flags : `${flags}u`;
|
|
130
|
+
}
|
|
131
|
+
function escapeIdentifierForRegex(name) {
|
|
132
|
+
return name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
133
|
+
}
|
|
134
|
+
var ID_BOUNDARY_BEFORE = "(?<![\\p{ID_Continue}$])";
|
|
135
|
+
var ID_BOUNDARY_AFTER = "(?![\\p{ID_Continue}$])";
|
|
136
|
+
function identifierPattern(name, flags = "") {
|
|
137
|
+
const esc = escapeIdentifierForRegex(name);
|
|
138
|
+
return new RegExp(`${ID_BOUNDARY_BEFORE}${esc}${ID_BOUNDARY_AFTER}`, withUnicodeFlag(flags));
|
|
139
|
+
}
|
|
140
|
+
|
|
127
141
|
// ../jsx/src/scanner/js-scanner.ts
|
|
128
142
|
import ts2 from "typescript";
|
|
129
143
|
|
|
@@ -240,6 +254,83 @@ function extractFreeIdentifiersFromText(text) {
|
|
|
240
254
|
return extractFreeIdentifiersFromNode(expr);
|
|
241
255
|
}
|
|
242
256
|
|
|
257
|
+
// ../jsx/src/scope/binding-scope.ts
|
|
258
|
+
class BindingScope {
|
|
259
|
+
frames;
|
|
260
|
+
static EMPTY = new BindingScope([]);
|
|
261
|
+
constructor(frames) {
|
|
262
|
+
this.frames = frames;
|
|
263
|
+
}
|
|
264
|
+
enterLoopRow(loop) {
|
|
265
|
+
const bindings = new Map;
|
|
266
|
+
if (loop.paramBindings && loop.paramBindings.length > 0) {
|
|
267
|
+
for (const b of loop.paramBindings)
|
|
268
|
+
bindings.set(b.name, { source: "destructure" });
|
|
269
|
+
} else {
|
|
270
|
+
bindings.set(loop.param, { source: "item" });
|
|
271
|
+
}
|
|
272
|
+
if (loop.index != null)
|
|
273
|
+
bindings.set(loop.index, { source: "index" });
|
|
274
|
+
for (const name of loop.preamble?.declaredNames ?? [])
|
|
275
|
+
bindings.set(name, { source: "preamble" });
|
|
276
|
+
const frame = { kind: "loop-row", bindings };
|
|
277
|
+
return new BindingScope([frame, ...this.frames]);
|
|
278
|
+
}
|
|
279
|
+
enterCallback(params) {
|
|
280
|
+
const bindings = new Map;
|
|
281
|
+
for (const name of params)
|
|
282
|
+
bindings.set(name, { source: "param" });
|
|
283
|
+
const frame = { kind: "callback", bindings };
|
|
284
|
+
return new BindingScope([frame, ...this.frames]);
|
|
285
|
+
}
|
|
286
|
+
isBound(name) {
|
|
287
|
+
for (const frame of this.frames) {
|
|
288
|
+
if (frame.bindings.has(name))
|
|
289
|
+
return true;
|
|
290
|
+
}
|
|
291
|
+
return false;
|
|
292
|
+
}
|
|
293
|
+
lookup(name) {
|
|
294
|
+
for (let depth = 0;depth < this.frames.length; depth++) {
|
|
295
|
+
const frame = this.frames[depth];
|
|
296
|
+
const binding = frame.bindings.get(name);
|
|
297
|
+
if (binding)
|
|
298
|
+
return { depth, frame, binding };
|
|
299
|
+
}
|
|
300
|
+
return null;
|
|
301
|
+
}
|
|
302
|
+
boundNames() {
|
|
303
|
+
if (this.boundNamesCache)
|
|
304
|
+
return this.boundNamesCache;
|
|
305
|
+
const names = new Set;
|
|
306
|
+
for (const frame of this.frames) {
|
|
307
|
+
for (const name of frame.bindings.keys())
|
|
308
|
+
names.add(name);
|
|
309
|
+
}
|
|
310
|
+
this.boundNamesCache = names;
|
|
311
|
+
return names;
|
|
312
|
+
}
|
|
313
|
+
boundNamesCache;
|
|
314
|
+
valueBoundNamesCache;
|
|
315
|
+
valueBoundNames() {
|
|
316
|
+
if (this.valueBoundNamesCache)
|
|
317
|
+
return this.valueBoundNamesCache;
|
|
318
|
+
const names = new Set;
|
|
319
|
+
for (const frame of this.frames) {
|
|
320
|
+
for (const [name, binding] of frame.bindings) {
|
|
321
|
+
if (binding.source === "item" || binding.source === "index" || binding.source === "destructure") {
|
|
322
|
+
names.add(name);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
this.valueBoundNamesCache = names;
|
|
327
|
+
return names;
|
|
328
|
+
}
|
|
329
|
+
asShadowPredicate() {
|
|
330
|
+
return (name) => this.isBound(name);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
243
334
|
// ../jsx/src/ir-to-client-js/html-template.ts
|
|
244
335
|
var VOID_ELEMENTS = new Set([
|
|
245
336
|
"area",
|
|
@@ -660,7 +751,7 @@ function findReachableNames(primaryRefs, declarations) {
|
|
|
660
751
|
const reachable = new Set;
|
|
661
752
|
const queue = [];
|
|
662
753
|
for (const name of allNames) {
|
|
663
|
-
if (
|
|
754
|
+
if (identifierPattern(name).test(primaryRefs)) {
|
|
664
755
|
reachable.add(name);
|
|
665
756
|
queue.push(name);
|
|
666
757
|
}
|
|
@@ -669,7 +760,7 @@ function findReachableNames(primaryRefs, declarations) {
|
|
|
669
760
|
const current = queue.shift();
|
|
670
761
|
const body = bodyMap.get(current) || "";
|
|
671
762
|
for (const name of allNames) {
|
|
672
|
-
if (!reachable.has(name) &&
|
|
763
|
+
if (!reachable.has(name) && identifierPattern(name).test(body)) {
|
|
673
764
|
reachable.add(name);
|
|
674
765
|
queue.push(name);
|
|
675
766
|
}
|
|
@@ -1000,83 +1091,6 @@ var toLocaleDatePlugin = {
|
|
|
1000
1091
|
}
|
|
1001
1092
|
};
|
|
1002
1093
|
|
|
1003
|
-
// ../jsx/src/scope/binding-scope.ts
|
|
1004
|
-
class BindingScope {
|
|
1005
|
-
frames;
|
|
1006
|
-
static EMPTY = new BindingScope([]);
|
|
1007
|
-
constructor(frames) {
|
|
1008
|
-
this.frames = frames;
|
|
1009
|
-
}
|
|
1010
|
-
enterLoopRow(loop) {
|
|
1011
|
-
const bindings = new Map;
|
|
1012
|
-
if (loop.paramBindings && loop.paramBindings.length > 0) {
|
|
1013
|
-
for (const b of loop.paramBindings)
|
|
1014
|
-
bindings.set(b.name, { source: "destructure" });
|
|
1015
|
-
} else {
|
|
1016
|
-
bindings.set(loop.param, { source: "item" });
|
|
1017
|
-
}
|
|
1018
|
-
if (loop.index != null)
|
|
1019
|
-
bindings.set(loop.index, { source: "index" });
|
|
1020
|
-
for (const name of loop.preamble?.declaredNames ?? [])
|
|
1021
|
-
bindings.set(name, { source: "preamble" });
|
|
1022
|
-
const frame = { kind: "loop-row", bindings };
|
|
1023
|
-
return new BindingScope([frame, ...this.frames]);
|
|
1024
|
-
}
|
|
1025
|
-
enterCallback(params) {
|
|
1026
|
-
const bindings = new Map;
|
|
1027
|
-
for (const name of params)
|
|
1028
|
-
bindings.set(name, { source: "param" });
|
|
1029
|
-
const frame = { kind: "callback", bindings };
|
|
1030
|
-
return new BindingScope([frame, ...this.frames]);
|
|
1031
|
-
}
|
|
1032
|
-
isBound(name) {
|
|
1033
|
-
for (const frame of this.frames) {
|
|
1034
|
-
if (frame.bindings.has(name))
|
|
1035
|
-
return true;
|
|
1036
|
-
}
|
|
1037
|
-
return false;
|
|
1038
|
-
}
|
|
1039
|
-
lookup(name) {
|
|
1040
|
-
for (let depth = 0;depth < this.frames.length; depth++) {
|
|
1041
|
-
const frame = this.frames[depth];
|
|
1042
|
-
const binding = frame.bindings.get(name);
|
|
1043
|
-
if (binding)
|
|
1044
|
-
return { depth, frame, binding };
|
|
1045
|
-
}
|
|
1046
|
-
return null;
|
|
1047
|
-
}
|
|
1048
|
-
boundNames() {
|
|
1049
|
-
if (this.boundNamesCache)
|
|
1050
|
-
return this.boundNamesCache;
|
|
1051
|
-
const names = new Set;
|
|
1052
|
-
for (const frame of this.frames) {
|
|
1053
|
-
for (const name of frame.bindings.keys())
|
|
1054
|
-
names.add(name);
|
|
1055
|
-
}
|
|
1056
|
-
this.boundNamesCache = names;
|
|
1057
|
-
return names;
|
|
1058
|
-
}
|
|
1059
|
-
boundNamesCache;
|
|
1060
|
-
valueBoundNamesCache;
|
|
1061
|
-
valueBoundNames() {
|
|
1062
|
-
if (this.valueBoundNamesCache)
|
|
1063
|
-
return this.valueBoundNamesCache;
|
|
1064
|
-
const names = new Set;
|
|
1065
|
-
for (const frame of this.frames) {
|
|
1066
|
-
for (const [name, binding] of frame.bindings) {
|
|
1067
|
-
if (binding.source === "item" || binding.source === "index" || binding.source === "destructure") {
|
|
1068
|
-
names.add(name);
|
|
1069
|
-
}
|
|
1070
|
-
}
|
|
1071
|
-
}
|
|
1072
|
-
this.valueBoundNamesCache = names;
|
|
1073
|
-
return names;
|
|
1074
|
-
}
|
|
1075
|
-
asShadowPredicate() {
|
|
1076
|
-
return (name) => this.isBound(name);
|
|
1077
|
-
}
|
|
1078
|
-
}
|
|
1079
|
-
|
|
1080
1094
|
// ../jsx/src/jsx-to-ir.ts
|
|
1081
1095
|
var EMPTY_BOUND = new Set;
|
|
1082
1096
|
var constInitializerCache = new WeakMap;
|
|
@@ -1613,7 +1627,7 @@ class JsxAdapter extends BaseAdapter {
|
|
|
1613
1627
|
lines.push(` const ${signal.getter} = () => ${initialValue}`);
|
|
1614
1628
|
}
|
|
1615
1629
|
if (signal.setter) {
|
|
1616
|
-
const setterUsed =
|
|
1630
|
+
const setterUsed = identifierPattern(signal.setter).test(setterRefText);
|
|
1617
1631
|
if (setterUsed) {
|
|
1618
1632
|
lines.push(` const ${signal.setter} = (..._args: any[]) => {}`);
|
|
1619
1633
|
}
|
|
@@ -1811,6 +1825,7 @@ class JsxAdapter extends BaseAdapter {
|
|
|
1811
1825
|
}
|
|
1812
1826
|
|
|
1813
1827
|
// ../jsx/src/adapters/template-imports.ts
|
|
1828
|
+
import ts25 from "typescript";
|
|
1814
1829
|
var CLIENT_PACKAGE_SOURCES = new Set([
|
|
1815
1830
|
"@barefootjs/client",
|
|
1816
1831
|
"@barefootjs/client/runtime"
|
|
@@ -1857,6 +1872,44 @@ function rewriteImportsForTemplate(imports, shimSource, rewriteRelative) {
|
|
|
1857
1872
|
function specKey(s) {
|
|
1858
1873
|
return `${s.isDefault ? "d" : ""}${s.isNamespace ? "n" : ""}:${s.name}:${s.alias ?? ""}`;
|
|
1859
1874
|
}
|
|
1875
|
+
function rewriteDynamicImportsInSource(sourceText, rewriteRelative) {
|
|
1876
|
+
if (!sourceText.includes("import"))
|
|
1877
|
+
return sourceText;
|
|
1878
|
+
const sf = ts25.createSourceFile("bf-template-fragment.tsx", sourceText, ts25.ScriptTarget.Latest, false, ts25.ScriptKind.TSX);
|
|
1879
|
+
const edits = [];
|
|
1880
|
+
const visit = (node) => {
|
|
1881
|
+
if (ts25.isCallExpression(node) && node.expression.kind === ts25.SyntaxKind.ImportKeyword && node.arguments.length > 0 && ts25.isStringLiteralLike(node.arguments[0])) {
|
|
1882
|
+
collect(node.arguments[0]);
|
|
1883
|
+
}
|
|
1884
|
+
if (ts25.isImportTypeNode(node) && ts25.isLiteralTypeNode(node.argument)) {
|
|
1885
|
+
const literal = node.argument.literal;
|
|
1886
|
+
if (ts25.isStringLiteralLike(literal))
|
|
1887
|
+
collect(literal);
|
|
1888
|
+
}
|
|
1889
|
+
ts25.forEachChild(node, visit);
|
|
1890
|
+
};
|
|
1891
|
+
const collect = (literal) => {
|
|
1892
|
+
const specifier = literal.text;
|
|
1893
|
+
if (!specifier.startsWith("."))
|
|
1894
|
+
return;
|
|
1895
|
+
const next = rewriteRelative(specifier);
|
|
1896
|
+
if (next === specifier)
|
|
1897
|
+
return;
|
|
1898
|
+
edits.push({
|
|
1899
|
+
start: literal.getStart(sf),
|
|
1900
|
+
end: literal.getEnd(),
|
|
1901
|
+
text: `'${next}'`
|
|
1902
|
+
});
|
|
1903
|
+
};
|
|
1904
|
+
ts25.forEachChild(sf, visit);
|
|
1905
|
+
if (edits.length === 0)
|
|
1906
|
+
return sourceText;
|
|
1907
|
+
let out = sourceText;
|
|
1908
|
+
for (const edit of edits.sort((a, b) => b.start - a.start)) {
|
|
1909
|
+
out = out.slice(0, edit.start) + edit.text + out.slice(edit.end);
|
|
1910
|
+
}
|
|
1911
|
+
return out;
|
|
1912
|
+
}
|
|
1860
1913
|
|
|
1861
1914
|
// ../jsx/src/adapters/test-adapter.ts
|
|
1862
1915
|
class TestAdapter extends JsxAdapter {
|
|
@@ -2255,11 +2308,11 @@ function emitAttrValue(value, emitter, name) {
|
|
|
2255
2308
|
}
|
|
2256
2309
|
}
|
|
2257
2310
|
// ../jsx/src/combine-client-js.ts
|
|
2258
|
-
import ts25 from "typescript";
|
|
2259
|
-
// ../jsx/src/debug.ts
|
|
2260
2311
|
import ts26 from "typescript";
|
|
2261
|
-
// ../jsx/src/
|
|
2312
|
+
// ../jsx/src/debug.ts
|
|
2262
2313
|
import ts27 from "typescript";
|
|
2314
|
+
// ../jsx/src/profiler.ts
|
|
2315
|
+
import ts28 from "typescript";
|
|
2263
2316
|
|
|
2264
2317
|
// ../jsx/src/index.ts
|
|
2265
2318
|
registerBuiltinLoweringPlugins();
|
|
@@ -2309,9 +2362,11 @@ class HonoAdapter extends JsxAdapter {
|
|
|
2309
2362
|
this.scriptAssets = options?.scriptAssets;
|
|
2310
2363
|
this.preloadAssets = options?.preloadAssets;
|
|
2311
2364
|
}
|
|
2312
|
-
const
|
|
2313
|
-
const
|
|
2314
|
-
const
|
|
2365
|
+
const reanchor = this.rewriteRelativeImport;
|
|
2366
|
+
const withRewrittenDynamicImports = (text) => reanchor && text ? rewriteDynamicImportsInSource(text, reanchor) : text;
|
|
2367
|
+
const component = withRewrittenDynamicImports(this.generateComponent(ir));
|
|
2368
|
+
const types = withRewrittenDynamicImports(this.generateTypes(ir));
|
|
2369
|
+
const moduleConstants = withRewrittenDynamicImports(this.generateModuleScopeDeclarations(ir));
|
|
2315
2370
|
const componentCode = [moduleConstants, types, component].filter(Boolean).join(`
|
|
2316
2371
|
`);
|
|
2317
2372
|
const imports = this.generateImports(ir, componentCode);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barefootjs/hono",
|
|
3
|
-
"version": "0.31.
|
|
3
|
+
"version": "0.31.4",
|
|
4
4
|
"description": "Hono integration for BarefootJS",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
},
|
|
123
123
|
"devDependencies": {
|
|
124
124
|
"@barefootjs/adapter-tests": "0.1.0",
|
|
125
|
-
"@barefootjs/vite": "0.31.
|
|
125
|
+
"@barefootjs/vite": "0.31.4",
|
|
126
126
|
"@types/jsdom": "^27.0.0",
|
|
127
127
|
"hono": "^4.6.0",
|
|
128
128
|
"jsdom": "^27.3.0",
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
JsxAdapter,
|
|
32
32
|
isBooleanAttr,
|
|
33
33
|
rewriteImportsForTemplate,
|
|
34
|
+
rewriteDynamicImportsInSource,
|
|
34
35
|
emitIRNode,
|
|
35
36
|
emitAttrValue,
|
|
36
37
|
buildLoopChainExpr,
|
|
@@ -195,9 +196,19 @@ export class HonoAdapter extends JsxAdapter implements IRNodeEmitter<HonoRenderC
|
|
|
195
196
|
// `generateModuleScopeDeclarations`; they join the scan text so a
|
|
196
197
|
// helper referenced only from a hoisted declaration still pulls its
|
|
197
198
|
// import.
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
199
|
+
// Re-anchor relative specifiers that ride along INSIDE emitted source
|
|
200
|
+
// text — dynamic `import('./x')` and `typeof import('./x')` — which
|
|
201
|
+
// never reach `metadata.templateImports` and so are invisible to
|
|
202
|
+
// `rewriteImportsForTemplate` below (#2588). Applied to every section
|
|
203
|
+
// that can carry verbatim source: module-scope declarations, the
|
|
204
|
+
// component body's local handlers, and type declarations.
|
|
205
|
+
const reanchor = this.rewriteRelativeImport
|
|
206
|
+
const withRewrittenDynamicImports = <T extends string | null>(text: T): T =>
|
|
207
|
+
reanchor && text ? (rewriteDynamicImportsInSource(text, reanchor) as T) : text
|
|
208
|
+
|
|
209
|
+
const component = withRewrittenDynamicImports(this.generateComponent(ir))
|
|
210
|
+
const types = withRewrittenDynamicImports(this.generateTypes(ir))
|
|
211
|
+
const moduleConstants = withRewrittenDynamicImports(this.generateModuleScopeDeclarations(ir))
|
|
201
212
|
const componentCode = [moduleConstants, types, component].filter(Boolean).join('\n')
|
|
202
213
|
const imports = this.generateImports(ir, componentCode)
|
|
203
214
|
|