microtags 0.0.13 → 0.1.1
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 +567 -40
- package/dist/build.cjs +412 -0
- package/dist/build.cjs.map +7 -0
- package/dist/build.d.ts +17 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +395 -0
- package/dist/build.js.map +7 -0
- package/dist/builders.d.ts +70 -4
- package/dist/builders.d.ts.map +1 -1
- package/dist/{chunk-CCYWRJW6.js → chunk-46UEUDVX.js} +4 -26
- package/dist/chunk-46UEUDVX.js.map +7 -0
- package/dist/chunk-LS4L5QRD.js +26 -0
- package/dist/chunk-LS4L5QRD.js.map +7 -0
- package/dist/chunk-RKWPTT6P.js +69 -0
- package/dist/chunk-RKWPTT6P.js.map +7 -0
- package/dist/chunk-ZZ4ZLOQY.js +33 -0
- package/dist/chunk-ZZ4ZLOQY.js.map +7 -0
- package/dist/cli.cjs +536 -0
- package/dist/cli.cjs.map +7 -0
- package/dist/context.js +2 -1
- package/dist/esbuild.cjs +451 -0
- package/dist/esbuild.cjs.map +7 -0
- package/dist/esbuild.d.ts +7 -0
- package/dist/esbuild.d.ts.map +1 -0
- package/dist/esbuild.js +434 -0
- package/dist/esbuild.js.map +7 -0
- package/dist/factory.d.ts +7 -1
- package/dist/factory.d.ts.map +1 -1
- package/dist/htm.browser.cjs +591 -0
- package/dist/htm.browser.cjs.map +7 -0
- package/dist/htm.browser.d.ts +30 -0
- package/dist/htm.browser.d.ts.map +1 -0
- package/dist/htm.browser.js +498 -0
- package/dist/htm.browser.js.map +7 -0
- package/dist/htm.browser.min.js +3 -0
- package/dist/htm.browser.min.js.map +7 -0
- package/dist/htm.cjs +284 -0
- package/dist/htm.cjs.map +7 -0
- package/dist/htm.d.ts +14 -0
- package/dist/htm.d.ts.map +1 -0
- package/dist/htm.js +196 -0
- package/dist/htm.js.map +7 -0
- package/dist/htm.min.js +3 -0
- package/dist/htm.min.js.map +7 -0
- package/dist/index.cjs +125 -11
- package/dist/index.cjs.map +2 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +133 -17
- package/dist/index.js.map +2 -2
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +3 -3
- package/dist/meta.json +411 -26
- package/dist/preact-shared.d.ts +61 -0
- package/dist/preact-shared.d.ts.map +1 -0
- package/dist/preact.browser.d.ts +8 -0
- package/dist/preact.browser.d.ts.map +1 -0
- package/dist/preact.browser.js +45 -0
- package/dist/preact.browser.js.map +7 -0
- package/dist/preact.browser.min.js +2 -0
- package/dist/preact.browser.min.js.map +7 -0
- package/dist/preact.cjs +128 -0
- package/dist/preact.cjs.map +7 -0
- package/dist/preact.d.ts +9 -0
- package/dist/preact.d.ts.map +1 -0
- package/dist/preact.js +35 -0
- package/dist/preact.js.map +7 -0
- package/dist/render-support.cjs +86 -0
- package/dist/render-support.cjs.map +7 -0
- package/dist/render-support.d.ts +23 -0
- package/dist/render-support.d.ts.map +1 -0
- package/dist/render-support.js +12 -0
- package/dist/render-support.js.map +7 -0
- package/dist/render-support.min.js +2 -0
- package/dist/render-support.min.js.map +7 -0
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/vite.cjs +448 -0
- package/dist/vite.cjs.map +7 -0
- package/dist/vite.d.ts +7 -0
- package/dist/vite.d.ts.map +1 -0
- package/dist/vite.js +429 -0
- package/dist/vite.js.map +7 -0
- package/package.json +92 -13
- package/dist/chunk-CCYWRJW6.js.map +0 -7
package/dist/vite.cjs
ADDED
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/vite.ts
|
|
22
|
+
var vite_exports = {};
|
|
23
|
+
__export(vite_exports, {
|
|
24
|
+
microtags: () => microtags
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(vite_exports);
|
|
27
|
+
|
|
28
|
+
// src/build.ts
|
|
29
|
+
var ts;
|
|
30
|
+
try {
|
|
31
|
+
ts = require("typescript");
|
|
32
|
+
} catch (err) {
|
|
33
|
+
const { code, message } = err;
|
|
34
|
+
if (code === "MODULE_NOT_FOUND" && message?.includes("'typescript'")) {
|
|
35
|
+
throw new Error(
|
|
36
|
+
'microtags/build requires "typescript" as a peer dependency. Install it with: npm install --save-dev typescript'
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
throw new Error(
|
|
40
|
+
'microtags/build could not load "typescript" because `require` is unavailable or unusable here. Load the entry from its built form (microtags/build, or dist/ in this repo) instead of from source.',
|
|
41
|
+
{ cause: err }
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
function transform(code, options) {
|
|
45
|
+
const keep = options?.keep ?? [];
|
|
46
|
+
const filename = options?.filename;
|
|
47
|
+
const sf = ts.createSourceFile(
|
|
48
|
+
filename ?? "input.ts",
|
|
49
|
+
code,
|
|
50
|
+
ts.ScriptTarget.Latest,
|
|
51
|
+
true
|
|
52
|
+
);
|
|
53
|
+
const defineAliases = findDefineAliases(sf);
|
|
54
|
+
const spans = [];
|
|
55
|
+
const strippedBindings = /* @__PURE__ */ new Set();
|
|
56
|
+
const warnings = [];
|
|
57
|
+
let keptLink = false;
|
|
58
|
+
function visit(node) {
|
|
59
|
+
if (!ts.isCallExpression(node)) {
|
|
60
|
+
ts.forEachChild(node, visit);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (ts.isPropertyAccessExpression(node.expression) && node.expression.name.text === "render") {
|
|
64
|
+
const receiver = node.expression.expression;
|
|
65
|
+
const chainRoot = findChainRoot(receiver);
|
|
66
|
+
if (chainRoot && isDefineCall(chainRoot, defineAliases)) {
|
|
67
|
+
const tagName = getDefineLiteralTag(chainRoot);
|
|
68
|
+
if (tagName === null && keep.length > 0) {
|
|
69
|
+
const line2 = sf.getLineAndCharacterOfPosition(
|
|
70
|
+
chainRoot.getStart()
|
|
71
|
+
).line + 1;
|
|
72
|
+
warnings.push({
|
|
73
|
+
kind: "non-literal-tag",
|
|
74
|
+
file: filename,
|
|
75
|
+
line: line2,
|
|
76
|
+
message: "define() call with non-literal tag name cannot be matched by --keep"
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
if (shouldKeep(node, tagName, keep)) {
|
|
80
|
+
keptLink = true;
|
|
81
|
+
ts.forEachChild(node, visit);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const binding = findBindingName(node);
|
|
85
|
+
if (binding) strippedBindings.add(binding);
|
|
86
|
+
spans.push({
|
|
87
|
+
start: dotPosition(node),
|
|
88
|
+
end: node.getEnd()
|
|
89
|
+
});
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const line = sf.getLineAndCharacterOfPosition(
|
|
93
|
+
node.getStart()
|
|
94
|
+
).line + 1;
|
|
95
|
+
warnings.push({
|
|
96
|
+
kind: "outside-chain",
|
|
97
|
+
file: filename,
|
|
98
|
+
line,
|
|
99
|
+
message: ".render() call outside a define chain"
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
ts.forEachChild(node, visit);
|
|
103
|
+
}
|
|
104
|
+
__name(visit, "visit");
|
|
105
|
+
ts.forEachChild(sf, visit);
|
|
106
|
+
spans.sort((a, b) => b.start - a.start);
|
|
107
|
+
let result = code;
|
|
108
|
+
for (const span of spans) {
|
|
109
|
+
const removed = result.slice(span.start, span.end);
|
|
110
|
+
const newlines = removed.split("\n").length - 1;
|
|
111
|
+
result = result.slice(0, span.start) + "\n".repeat(newlines) + result.slice(span.end);
|
|
112
|
+
}
|
|
113
|
+
if (options?.cascade) {
|
|
114
|
+
result = cascadeRemove(result, filename);
|
|
115
|
+
}
|
|
116
|
+
if (strippedBindings.size > 0) {
|
|
117
|
+
const resultSf = ts.createSourceFile(
|
|
118
|
+
filename ?? "input.ts",
|
|
119
|
+
result,
|
|
120
|
+
ts.ScriptTarget.Latest,
|
|
121
|
+
true
|
|
122
|
+
);
|
|
123
|
+
findStrippedStaticCalls(
|
|
124
|
+
resultSf,
|
|
125
|
+
strippedBindings,
|
|
126
|
+
warnings,
|
|
127
|
+
filename
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
if (keptLink && !importsSupport(sf)) {
|
|
131
|
+
result += `
|
|
132
|
+
import '${SUPPORT}'
|
|
133
|
+
`;
|
|
134
|
+
}
|
|
135
|
+
return { code: result, warnings };
|
|
136
|
+
}
|
|
137
|
+
__name(transform, "transform");
|
|
138
|
+
var SUPPORT = "microtags/render-support";
|
|
139
|
+
function importsSupport(sf) {
|
|
140
|
+
return sf.statements.some(
|
|
141
|
+
(node) => ts.isImportDeclaration(node) && ts.isStringLiteral(node.moduleSpecifier) && node.moduleSpecifier.text === SUPPORT
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
__name(importsSupport, "importsSupport");
|
|
145
|
+
function findDefineAliases(sf) {
|
|
146
|
+
const aliases = /* @__PURE__ */ new Set();
|
|
147
|
+
ts.forEachChild(sf, (node) => {
|
|
148
|
+
if (ts.isImportDeclaration(node) && ts.isStringLiteral(node.moduleSpecifier) && node.moduleSpecifier.text === "microtags" && node.importClause?.namedBindings && ts.isNamedImports(
|
|
149
|
+
node.importClause.namedBindings
|
|
150
|
+
)) {
|
|
151
|
+
for (const spec of node.importClause.namedBindings.elements) {
|
|
152
|
+
const origName = spec.propertyName?.text ?? spec.name.text;
|
|
153
|
+
if (origName === "define") {
|
|
154
|
+
aliases.add(spec.name.text);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
return aliases;
|
|
160
|
+
}
|
|
161
|
+
__name(findDefineAliases, "findDefineAliases");
|
|
162
|
+
function findChainRoot(node) {
|
|
163
|
+
if (ts.isCallExpression(node)) {
|
|
164
|
+
if (ts.isIdentifier(node.expression)) {
|
|
165
|
+
return node;
|
|
166
|
+
}
|
|
167
|
+
if (ts.isPropertyAccessExpression(node.expression)) {
|
|
168
|
+
return findChainRoot(
|
|
169
|
+
node.expression.expression
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
__name(findChainRoot, "findChainRoot");
|
|
176
|
+
function isDefineCall(node, aliases) {
|
|
177
|
+
return ts.isIdentifier(node.expression) && aliases.has(node.expression.text);
|
|
178
|
+
}
|
|
179
|
+
__name(isDefineCall, "isDefineCall");
|
|
180
|
+
function getDefineLiteralTag(node) {
|
|
181
|
+
if (node.arguments.length > 0 && ts.isStringLiteral(node.arguments[0])) {
|
|
182
|
+
return node.arguments[0].text;
|
|
183
|
+
}
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
__name(getDefineLiteralTag, "getDefineLiteralTag");
|
|
187
|
+
function shouldKeep(renderCall, tagName, keep) {
|
|
188
|
+
if (renderCall.arguments.length >= 2) {
|
|
189
|
+
const opts = renderCall.arguments[1];
|
|
190
|
+
if (ts.isObjectLiteralExpression(opts)) {
|
|
191
|
+
for (const prop of opts.properties) {
|
|
192
|
+
if (ts.isPropertyAssignment(prop) && ts.isIdentifier(prop.name) && prop.name.text === "client" && prop.initializer.kind === ts.SyntaxKind.TrueKeyword) {
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (tagName !== null && keep.includes(tagName)) {
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
__name(shouldKeep, "shouldKeep");
|
|
204
|
+
function dotPosition(renderCall) {
|
|
205
|
+
const pa = renderCall.expression;
|
|
206
|
+
return pa.expression.getEnd();
|
|
207
|
+
}
|
|
208
|
+
__name(dotPosition, "dotPosition");
|
|
209
|
+
function findBindingName(node) {
|
|
210
|
+
let current = node;
|
|
211
|
+
while (current.parent) {
|
|
212
|
+
current = current.parent;
|
|
213
|
+
if (ts.isVariableDeclaration(current) && ts.isIdentifier(current.name)) {
|
|
214
|
+
return current.name.text;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
__name(findBindingName, "findBindingName");
|
|
220
|
+
function cascadeRemove(code, filename) {
|
|
221
|
+
let changed = true;
|
|
222
|
+
let result = code;
|
|
223
|
+
while (changed) {
|
|
224
|
+
changed = false;
|
|
225
|
+
const sf = ts.createSourceFile(
|
|
226
|
+
filename ?? "input.ts",
|
|
227
|
+
result,
|
|
228
|
+
ts.ScriptTarget.Latest,
|
|
229
|
+
true
|
|
230
|
+
);
|
|
231
|
+
const refs = collectReferences(sf);
|
|
232
|
+
const removeSpans = [];
|
|
233
|
+
ts.forEachChild(sf, (node) => {
|
|
234
|
+
if (ts.isImportDeclaration(node) && node.importClause) {
|
|
235
|
+
if (isExportedNode(node)) return;
|
|
236
|
+
const nb = node.importClause.namedBindings;
|
|
237
|
+
if (!nb) return;
|
|
238
|
+
if (!ts.isNamedImports(nb)) {
|
|
239
|
+
const name = node.importClause.name;
|
|
240
|
+
if (name && !refs.has(name.text)) {
|
|
241
|
+
removeSpans.push({
|
|
242
|
+
start: node.getStart(),
|
|
243
|
+
end: node.getEnd()
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
const dead = [];
|
|
249
|
+
const live = [];
|
|
250
|
+
for (const el of nb.elements) {
|
|
251
|
+
if (refs.has(el.name.text)) {
|
|
252
|
+
live.push(el);
|
|
253
|
+
} else {
|
|
254
|
+
dead.push(el);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
if (dead.length === 0) return;
|
|
258
|
+
if (live.length === 0) {
|
|
259
|
+
removeSpans.push({
|
|
260
|
+
start: node.getStart(),
|
|
261
|
+
end: node.getEnd()
|
|
262
|
+
});
|
|
263
|
+
} else {
|
|
264
|
+
for (const d of dead) {
|
|
265
|
+
let start = d.getStart();
|
|
266
|
+
let end = d.getEnd();
|
|
267
|
+
const text = result;
|
|
268
|
+
const after = text.slice(end);
|
|
269
|
+
const before = text.slice(0, start);
|
|
270
|
+
if (/^\s*,/.test(after)) {
|
|
271
|
+
end += after.match(
|
|
272
|
+
/^\s*,/
|
|
273
|
+
)[0].length;
|
|
274
|
+
} else if (/,\s*$/.test(before)) {
|
|
275
|
+
start = before.lastIndexOf(",");
|
|
276
|
+
}
|
|
277
|
+
removeSpans.push({ start, end });
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
if (ts.isVariableStatement(node)) {
|
|
283
|
+
if (isExportedNode(node)) return;
|
|
284
|
+
const allDead = node.declarationList.declarations.every(
|
|
285
|
+
(d) => ts.isIdentifier(d.name) && !refs.has(d.name.text)
|
|
286
|
+
);
|
|
287
|
+
if (allDead) {
|
|
288
|
+
removeSpans.push({
|
|
289
|
+
start: node.getStart(),
|
|
290
|
+
end: node.getEnd()
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
if (ts.isFunctionDeclaration(node)) {
|
|
296
|
+
if (isExportedNode(node)) return;
|
|
297
|
+
if (node.name && !refs.has(node.name.text)) {
|
|
298
|
+
removeSpans.push({
|
|
299
|
+
start: node.getStart(),
|
|
300
|
+
end: node.getEnd()
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
if (ts.isClassDeclaration(node)) {
|
|
306
|
+
if (isExportedNode(node)) return;
|
|
307
|
+
if (node.name && !refs.has(node.name.text)) {
|
|
308
|
+
removeSpans.push({
|
|
309
|
+
start: node.getStart(),
|
|
310
|
+
end: node.getEnd()
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
if (removeSpans.length === 0) break;
|
|
316
|
+
changed = true;
|
|
317
|
+
removeSpans.sort((a, b) => b.start - a.start);
|
|
318
|
+
for (const span of removeSpans) {
|
|
319
|
+
const removed = result.slice(
|
|
320
|
+
span.start,
|
|
321
|
+
span.end
|
|
322
|
+
);
|
|
323
|
+
const newlines = removed.split("\n").length - 1;
|
|
324
|
+
result = result.slice(0, span.start) + "\n".repeat(newlines) + result.slice(span.end);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return result;
|
|
328
|
+
}
|
|
329
|
+
__name(cascadeRemove, "cascadeRemove");
|
|
330
|
+
function collectReferences(sf) {
|
|
331
|
+
const refs = /* @__PURE__ */ new Set();
|
|
332
|
+
const declared = /* @__PURE__ */ new Set();
|
|
333
|
+
ts.forEachChild(sf, (node) => {
|
|
334
|
+
if (ts.isImportDeclaration(node)) {
|
|
335
|
+
if (node.importClause?.namedBindings && ts.isNamedImports(
|
|
336
|
+
node.importClause.namedBindings
|
|
337
|
+
)) {
|
|
338
|
+
for (const el of node.importClause.namedBindings.elements) {
|
|
339
|
+
declared.add(el.name.text);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
if (ts.isVariableStatement(node)) {
|
|
345
|
+
for (const d of node.declarationList.declarations) {
|
|
346
|
+
if (ts.isIdentifier(d.name)) {
|
|
347
|
+
declared.add(d.name.text);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
if (ts.isFunctionDeclaration(node) && node.name) {
|
|
352
|
+
declared.add(node.name.text);
|
|
353
|
+
}
|
|
354
|
+
if (ts.isClassDeclaration(node) && node.name) {
|
|
355
|
+
declared.add(node.name.text);
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
function visitRefs(node) {
|
|
359
|
+
if (ts.isIdentifier(node) && declared.has(node.text)) {
|
|
360
|
+
const parent = node.parent;
|
|
361
|
+
if (ts.isImportSpecifier(parent) || ts.isVariableDeclaration(parent) && parent.name === node || ts.isFunctionDeclaration(parent) && parent.name === node || ts.isClassDeclaration(parent) && parent.name === node) {
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
refs.add(node.text);
|
|
365
|
+
}
|
|
366
|
+
ts.forEachChild(node, visitRefs);
|
|
367
|
+
}
|
|
368
|
+
__name(visitRefs, "visitRefs");
|
|
369
|
+
ts.forEachChild(sf, (node) => {
|
|
370
|
+
if (ts.isImportDeclaration(node)) return;
|
|
371
|
+
visitRefs(node);
|
|
372
|
+
});
|
|
373
|
+
return refs;
|
|
374
|
+
}
|
|
375
|
+
__name(collectReferences, "collectReferences");
|
|
376
|
+
function isExportedNode(node) {
|
|
377
|
+
if (!ts.canHaveModifiers(node)) return false;
|
|
378
|
+
const mods = ts.getModifiers(node);
|
|
379
|
+
if (!mods) return false;
|
|
380
|
+
return mods.some(
|
|
381
|
+
(m) => m.kind === ts.SyntaxKind.ExportKeyword
|
|
382
|
+
);
|
|
383
|
+
}
|
|
384
|
+
__name(isExportedNode, "isExportedNode");
|
|
385
|
+
function findStrippedStaticCalls(sf, bindings, warnings, filename) {
|
|
386
|
+
function visit(node) {
|
|
387
|
+
if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(
|
|
388
|
+
node.expression
|
|
389
|
+
) && node.expression.name.text === "render" && ts.isIdentifier(
|
|
390
|
+
node.expression.expression
|
|
391
|
+
) && bindings.has(
|
|
392
|
+
node.expression.expression.text
|
|
393
|
+
)) {
|
|
394
|
+
const line = sf.getLineAndCharacterOfPosition(
|
|
395
|
+
node.getStart()
|
|
396
|
+
).line + 1;
|
|
397
|
+
warnings.push({
|
|
398
|
+
kind: "stripped-static",
|
|
399
|
+
file: filename,
|
|
400
|
+
line,
|
|
401
|
+
message: `${node.expression.expression.text}.render() called but render was stripped`
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
ts.forEachChild(node, visit);
|
|
405
|
+
}
|
|
406
|
+
__name(visit, "visit");
|
|
407
|
+
ts.forEachChild(sf, visit);
|
|
408
|
+
}
|
|
409
|
+
__name(findStrippedStaticCalls, "findStrippedStaticCalls");
|
|
410
|
+
|
|
411
|
+
// src/vite.ts
|
|
412
|
+
function microtags(options) {
|
|
413
|
+
const filter = options?.filter ?? /\.(ts|js|mjs)$/;
|
|
414
|
+
const cascade = options?.cascade;
|
|
415
|
+
const keep = options?.keep;
|
|
416
|
+
return {
|
|
417
|
+
name: "microtags",
|
|
418
|
+
transform(code, id, opts) {
|
|
419
|
+
if (!filter.test(id)) return null;
|
|
420
|
+
const consumer = this.environment?.config.consumer;
|
|
421
|
+
if (consumer ? consumer === "server" : opts?.ssr) {
|
|
422
|
+
return null;
|
|
423
|
+
}
|
|
424
|
+
const result = transform(code, {
|
|
425
|
+
cascade,
|
|
426
|
+
keep,
|
|
427
|
+
filename: id
|
|
428
|
+
});
|
|
429
|
+
for (const w of result.warnings) {
|
|
430
|
+
this.warn({
|
|
431
|
+
message: w.message,
|
|
432
|
+
id,
|
|
433
|
+
pos: void 0
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
return {
|
|
437
|
+
code: result.code,
|
|
438
|
+
map: null
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
__name(microtags, "microtags");
|
|
444
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
445
|
+
0 && (module.exports = {
|
|
446
|
+
microtags
|
|
447
|
+
});
|
|
448
|
+
//# sourceMappingURL=vite.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/vite.ts", "../src/build.ts"],
|
|
4
|
+
"sourcesContent": ["import type { Plugin } from 'vite'\nimport { transform } from './build.js'\nimport type { TransformOptions } from './build.js'\n\nexport interface MicrotagsViteOptions\n extends TransformOptions {\n filter?:RegExp\n}\n\nexport function microtags (\n options?:MicrotagsViteOptions\n):Plugin {\n const filter = options?.filter ?? /\\.(ts|js|mjs)$/\n const cascade = options?.cascade\n const keep = options?.keep as string[] | undefined\n\n return {\n name: 'microtags',\n transform (\n code:string,\n id:string,\n opts?:{ ssr?:boolean }\n ) {\n if (!filter.test(id)) return null\n // Server modules must keep their render links. Key on the\n // environment consumer, not build vs dev mode; older Vite\n // hook signatures only pass `options.ssr`.\n const consumer = this.environment?.config.consumer\n if (consumer ? consumer === 'server' : opts?.ssr) {\n return null\n }\n\n const result = transform(code, {\n cascade,\n keep,\n filename: id,\n })\n\n for (const w of result.warnings) {\n this.warn({\n message: w.message,\n id,\n pos: undefined,\n })\n }\n\n return {\n code: result.code,\n map: null,\n }\n },\n }\n}\n", "import type TypeScript from 'typescript'\n\ndeclare const require:(id:string) => unknown\n\nlet ts:typeof TypeScript\ntry {\n ts = require('typescript') as typeof TypeScript\n} catch (err) {\n // Only a failure to resolve the bare name means typescript is\n // missing. Anything else is a context that cannot `require` it:\n // an ESM bundle without `require`, or a Vite config bundle, which\n // hands `require` a file URL.\n const { code, message } = err as { code?:string, message?:string }\n if (\n code === 'MODULE_NOT_FOUND' &&\n message?.includes(\"'typescript'\")\n ) {\n throw new Error(\n 'microtags/build requires \"typescript\" as a peer dependency. ' +\n 'Install it with: npm install --save-dev typescript'\n )\n }\n throw new Error(\n 'microtags/build could not load \"typescript\" because `require` ' +\n 'is unavailable or unusable here. Load the entry from its ' +\n 'built form (microtags/build, or dist/ in this repo) instead ' +\n 'of from source.',\n { cause: err }\n )\n}\n\nexport interface TransformWarning {\n kind:'outside-chain'|'stripped-static'|'non-literal-tag'\n file?:string\n line:number\n message:string\n}\n\nexport interface TransformOptions {\n cascade?:boolean\n keep?:string[]\n filename?:string\n}\n\nexport interface TransformResult {\n code:string\n warnings:TransformWarning[]\n}\n\nexport function transform (\n code:string,\n options?:TransformOptions\n):TransformResult {\n const keep = options?.keep ?? []\n const filename = options?.filename\n\n const sf = ts.createSourceFile(\n filename ?? 'input.ts',\n code,\n ts.ScriptTarget.Latest,\n true\n )\n\n const defineAliases = findDefineAliases(sf)\n const spans:{ start:number, end:number }[] = []\n const strippedBindings:Set<string> = new Set()\n const warnings:TransformWarning[] = []\n let keptLink = false\n\n function visit (node:TypeScript.Node) {\n if (!ts.isCallExpression(node)) {\n ts.forEachChild(node, visit)\n return\n }\n\n if (\n ts.isPropertyAccessExpression(node.expression) &&\n node.expression.name.text === 'render'\n ) {\n const receiver = node.expression.expression\n const chainRoot = findChainRoot(receiver)\n\n if (\n chainRoot &&\n isDefineCall(chainRoot, defineAliases)\n ) {\n const tagName = getDefineLiteralTag(chainRoot)\n\n if (tagName === null && keep.length > 0) {\n const line = sf.getLineAndCharacterOfPosition(\n chainRoot.getStart()\n ).line + 1\n warnings.push({\n kind: 'non-literal-tag',\n file: filename,\n line,\n message:\n 'define() call with non-literal ' +\n 'tag name cannot be matched ' +\n 'by --keep',\n })\n }\n\n if (shouldKeep(node, tagName, keep)) {\n keptLink = true\n ts.forEachChild(node, visit)\n return\n }\n\n const binding = findBindingName(node)\n if (binding) strippedBindings.add(binding)\n\n spans.push({\n start: dotPosition(node),\n end: node.getEnd(),\n })\n return\n }\n\n const line = sf.getLineAndCharacterOfPosition(\n node.getStart()\n ).line + 1\n warnings.push({\n kind: 'outside-chain',\n file: filename,\n line,\n message:\n '.render() call outside a define chain',\n })\n }\n\n ts.forEachChild(node, visit)\n }\n\n ts.forEachChild(sf, visit)\n\n spans.sort((a, b) => b.start - a.start)\n\n let result = code\n for (const span of spans) {\n const removed = result.slice(span.start, span.end)\n const newlines = removed.split('\\n').length - 1\n result = result.slice(0, span.start) +\n '\\n'.repeat(newlines) +\n result.slice(span.end)\n }\n\n if (options?.cascade) {\n result = cascadeRemove(result, filename)\n }\n\n if (strippedBindings.size > 0) {\n const resultSf = ts.createSourceFile(\n filename ?? 'input.ts',\n result,\n ts.ScriptTarget.Latest,\n true\n )\n findStrippedStaticCalls(\n resultSf, strippedBindings, warnings, filename\n )\n }\n\n // A kept render link needs the server render support module at\n // runtime (ADR-009). Appended so no existing line moves; imports\n // are hoisted, so its position does not matter.\n if (keptLink && !importsSupport(sf)) {\n result += `\\nimport '${SUPPORT}'\\n`\n }\n\n return { code: result, warnings }\n}\n\nconst SUPPORT = 'microtags/render-support'\n\nfunction importsSupport (sf:TypeScript.SourceFile):boolean {\n return sf.statements.some(node =>\n ts.isImportDeclaration(node) &&\n ts.isStringLiteral(node.moduleSpecifier) &&\n node.moduleSpecifier.text === SUPPORT\n )\n}\n\nfunction findDefineAliases (\n sf:TypeScript.SourceFile\n):Set<string> {\n const aliases = new Set<string>()\n ts.forEachChild(sf, node => {\n if (\n ts.isImportDeclaration(node) &&\n ts.isStringLiteral(node.moduleSpecifier) &&\n node.moduleSpecifier.text === 'microtags' &&\n node.importClause?.namedBindings &&\n ts.isNamedImports(\n node.importClause.namedBindings\n )\n ) {\n for (const spec of\n node.importClause.namedBindings.elements\n ) {\n const origName =\n spec.propertyName?.text ??\n spec.name.text\n if (origName === 'define') {\n aliases.add(spec.name.text)\n }\n }\n }\n })\n return aliases\n}\n\nfunction findChainRoot (\n node:TypeScript.Node\n):TypeScript.CallExpression | null {\n if (ts.isCallExpression(node)) {\n if (ts.isIdentifier(node.expression)) {\n return node\n }\n if (\n ts.isPropertyAccessExpression(node.expression)\n ) {\n return findChainRoot(\n node.expression.expression\n )\n }\n }\n return null\n}\n\nfunction isDefineCall (\n node:TypeScript.CallExpression,\n aliases:Set<string>\n):boolean {\n return ts.isIdentifier(node.expression) &&\n aliases.has(node.expression.text)\n}\n\nfunction getDefineLiteralTag (\n node:TypeScript.CallExpression\n):string | null {\n if (\n node.arguments.length > 0 &&\n ts.isStringLiteral(node.arguments[0])\n ) {\n return node.arguments[0].text\n }\n return null\n}\n\nfunction shouldKeep (\n renderCall:TypeScript.CallExpression,\n tagName:string | null,\n keep:string[]\n):boolean {\n if (renderCall.arguments.length >= 2) {\n const opts = renderCall.arguments[1]\n if (ts.isObjectLiteralExpression(opts)) {\n for (const prop of opts.properties) {\n if (\n ts.isPropertyAssignment(prop) &&\n ts.isIdentifier(prop.name) &&\n prop.name.text === 'client' &&\n prop.initializer.kind ===\n ts.SyntaxKind.TrueKeyword\n ) {\n return true\n }\n }\n }\n }\n\n if (tagName !== null && keep.includes(tagName)) {\n return true\n }\n\n return false\n}\n\nfunction dotPosition (\n renderCall:TypeScript.CallExpression\n):number {\n const pa = renderCall\n .expression as TypeScript.PropertyAccessExpression\n return pa.expression.getEnd()\n}\n\nfunction findBindingName (\n node:TypeScript.Node\n):string | null {\n let current:TypeScript.Node = node\n while (current.parent) {\n current = current.parent\n if (\n ts.isVariableDeclaration(current) &&\n ts.isIdentifier(current.name)\n ) {\n return current.name.text\n }\n }\n return null\n}\n\nfunction cascadeRemove (\n code:string,\n filename?:string\n):string {\n let changed = true\n let result = code\n while (changed) {\n changed = false\n const sf = ts.createSourceFile(\n filename ?? 'input.ts',\n result,\n ts.ScriptTarget.Latest,\n true\n )\n\n const refs = collectReferences(sf)\n const removeSpans:{\n start:number, end:number\n }[] = []\n\n ts.forEachChild(sf, node => {\n if (\n ts.isImportDeclaration(node) &&\n node.importClause\n ) {\n if (isExportedNode(node)) return\n const nb = node.importClause.namedBindings\n if (!nb) return\n if (!ts.isNamedImports(nb)) {\n const name = node.importClause.name\n if (\n name &&\n !refs.has(name.text)\n ) {\n removeSpans.push({\n start: node.getStart(),\n end: node.getEnd(),\n })\n }\n return\n }\n const dead:TypeScript.ImportSpecifier[] = []\n const live:TypeScript.ImportSpecifier[] = []\n for (const el of nb.elements) {\n if (refs.has(el.name.text)) {\n live.push(el)\n } else {\n dead.push(el)\n }\n }\n if (dead.length === 0) return\n if (live.length === 0) {\n removeSpans.push({\n start: node.getStart(),\n end: node.getEnd(),\n })\n } else {\n for (const d of dead) {\n let start = d.getStart()\n let end = d.getEnd()\n const text = result\n const after = text.slice(end)\n const before = text.slice(0, start)\n if (/^\\s*,/.test(after)) {\n end += after.match(\n /^\\s*,/\n )![0].length\n } else if (/,\\s*$/.test(before)) {\n start = before.lastIndexOf(',')\n }\n removeSpans.push({ start, end })\n }\n }\n return\n }\n\n if (ts.isVariableStatement(node)) {\n if (isExportedNode(node)) return\n const allDead = node\n .declarationList\n .declarations\n .every(d =>\n ts.isIdentifier(d.name) &&\n !refs.has(d.name.text)\n )\n if (allDead) {\n removeSpans.push({\n start: node.getStart(),\n end: node.getEnd(),\n })\n }\n return\n }\n\n if (ts.isFunctionDeclaration(node)) {\n if (isExportedNode(node)) return\n if (\n node.name &&\n !refs.has(node.name.text)\n ) {\n removeSpans.push({\n start: node.getStart(),\n end: node.getEnd(),\n })\n }\n return\n }\n\n if (ts.isClassDeclaration(node)) {\n if (isExportedNode(node)) return\n if (\n node.name &&\n !refs.has(node.name.text)\n ) {\n removeSpans.push({\n start: node.getStart(),\n end: node.getEnd(),\n })\n }\n }\n })\n\n if (removeSpans.length === 0) break\n\n changed = true\n removeSpans.sort((a, b) => b.start - a.start)\n for (const span of removeSpans) {\n const removed = result.slice(\n span.start, span.end\n )\n const newlines =\n removed.split('\\n').length - 1\n result = result.slice(0, span.start) +\n '\\n'.repeat(newlines) +\n result.slice(span.end)\n }\n }\n\n return result\n}\n\nfunction collectReferences (\n sf:TypeScript.SourceFile\n):Set<string> {\n const refs = new Set<string>()\n const declared = new Set<string>()\n\n ts.forEachChild(sf, node => {\n if (ts.isImportDeclaration(node)) {\n if (\n node.importClause?.namedBindings &&\n ts.isNamedImports(\n node.importClause.namedBindings\n )\n ) {\n for (const el of\n node.importClause\n .namedBindings.elements\n ) {\n declared.add(el.name.text)\n }\n }\n return\n }\n if (ts.isVariableStatement(node)) {\n for (const d of\n node.declarationList.declarations\n ) {\n if (ts.isIdentifier(d.name)) {\n declared.add(d.name.text)\n }\n }\n }\n if (\n ts.isFunctionDeclaration(node) && node.name\n ) {\n declared.add(node.name.text)\n }\n if (\n ts.isClassDeclaration(node) && node.name\n ) {\n declared.add(node.name.text)\n }\n })\n\n function visitRefs (node:TypeScript.Node) {\n if (\n ts.isIdentifier(node) &&\n declared.has(node.text)\n ) {\n const parent = node.parent\n if (\n ts.isImportSpecifier(parent) ||\n (\n ts.isVariableDeclaration(parent) &&\n parent.name === node\n ) ||\n (\n ts.isFunctionDeclaration(parent) &&\n parent.name === node\n ) ||\n (\n ts.isClassDeclaration(parent) &&\n parent.name === node\n )\n ) {\n return\n }\n refs.add(node.text)\n }\n ts.forEachChild(node, visitRefs)\n }\n\n ts.forEachChild(sf, node => {\n if (ts.isImportDeclaration(node)) return\n visitRefs(node)\n })\n\n return refs\n}\n\nfunction isExportedNode (\n node:TypeScript.Node\n):boolean {\n if (!ts.canHaveModifiers(node)) return false\n const mods = ts.getModifiers(node)\n if (!mods) return false\n return mods.some(\n m => m.kind === ts.SyntaxKind.ExportKeyword\n )\n}\n\nfunction findStrippedStaticCalls (\n sf:TypeScript.SourceFile,\n bindings:Set<string>,\n warnings:TransformWarning[],\n filename?:string\n) {\n function visit (node:TypeScript.Node) {\n if (\n ts.isCallExpression(node) &&\n ts.isPropertyAccessExpression(\n node.expression\n ) &&\n node.expression.name.text === 'render' &&\n ts.isIdentifier(\n node.expression.expression\n ) &&\n bindings.has(\n node.expression.expression.text\n )\n ) {\n const line = sf.getLineAndCharacterOfPosition(\n node.getStart()\n ).line + 1\n warnings.push({\n kind: 'stripped-static',\n file: filename,\n line,\n message:\n `${node.expression.expression.text}` +\n '.render() called but render ' +\n 'was stripped',\n })\n }\n ts.forEachChild(node, visit)\n }\n ts.forEachChild(sf, visit)\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIA,IAAI;AACJ,IAAI;AACA,OAAK,QAAQ,YAAY;AAC7B,SAAS,KAAK;AAKV,QAAM,EAAE,MAAM,QAAQ,IAAI;AAC1B,MACI,SAAS,sBACT,SAAS,SAAS,cAAc,GAClC;AACE,UAAM,IAAI;AAAA,MACN;AAAA,IAEJ;AAAA,EACJ;AACA,QAAM,IAAI;AAAA,IACN;AAAA,IAIA,EAAE,OAAO,IAAI;AAAA,EACjB;AACJ;AAoBO,SAAS,UACZ,MACA,SACc;AACd,QAAM,OAAO,SAAS,QAAQ,CAAC;AAC/B,QAAM,WAAW,SAAS;AAE1B,QAAM,KAAK,GAAG;AAAA,IACV,YAAY;AAAA,IACZ;AAAA,IACA,GAAG,aAAa;AAAA,IAChB;AAAA,EACJ;AAEA,QAAM,gBAAgB,kBAAkB,EAAE;AAC1C,QAAM,QAAuC,CAAC;AAC9C,QAAM,mBAA+B,oBAAI,IAAI;AAC7C,QAAM,WAA8B,CAAC;AACrC,MAAI,WAAW;AAEf,WAAS,MAAO,MAAsB;AAClC,QAAI,CAAC,GAAG,iBAAiB,IAAI,GAAG;AAC5B,SAAG,aAAa,MAAM,KAAK;AAC3B;AAAA,IACJ;AAEA,QACI,GAAG,2BAA2B,KAAK,UAAU,KAC7C,KAAK,WAAW,KAAK,SAAS,UAChC;AACE,YAAM,WAAW,KAAK,WAAW;AACjC,YAAM,YAAY,cAAc,QAAQ;AAExC,UACI,aACA,aAAa,WAAW,aAAa,GACvC;AACE,cAAM,UAAU,oBAAoB,SAAS;AAE7C,YAAI,YAAY,QAAQ,KAAK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AAK;AAC9C,eAAO;AAAA,MACX;AAEA,YAAM,SAAS,UAAU,MAAM;AAAA,QAC3B;AAAA,QACA;AAAA,QACA,UAAU;AAAA,MACd,CAAC;AAED,iBAAW,KAAK,OAAO,UAAU;AAC7B,aAAK,KAAK;AAAA,UACN,SAAS,EAAE;AAAA,UACX;AAAA,UACA,KAAK;AAAA,QACT,CAAC;AAAA,MACL;AAEA,aAAO;AAAA,QACH,MAAM,OAAO;AAAA,QACb,KAAK;AAAA,MACT;AAAA,IACJ;AAAA,EACJ;AACJ;AA3CgB;",
|
|
6
|
+
"names": ["line"]
|
|
7
|
+
}
|
package/dist/vite.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
import type { TransformOptions } from './build.js';
|
|
3
|
+
export interface MicrotagsViteOptions extends TransformOptions {
|
|
4
|
+
filter?: RegExp;
|
|
5
|
+
}
|
|
6
|
+
export declare function microtags(options?: MicrotagsViteOptions): Plugin;
|
|
7
|
+
//# sourceMappingURL=vite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAElC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAElD,MAAM,WAAW,oBACb,SAAQ,gBAAgB;IACxB,MAAM,CAAC,EAAC,MAAM,CAAA;CACjB;AAED,wBAAgB,SAAS,CACrB,OAAO,CAAC,EAAC,oBAAoB,GAC/B,MAAM,CAyCP"}
|