@defold-typescript/transpiler 0.23.0 → 0.24.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/dist/index.js +8 -1
- package/package.json +2 -2
- package/src/lifecycle-erasure.ts +12 -3
package/dist/index.js
CHANGED
|
@@ -307,11 +307,18 @@ function isFactoryOnlyImport(node) {
|
|
|
307
307
|
if (clause === undefined || clause.name !== undefined) {
|
|
308
308
|
return false;
|
|
309
309
|
}
|
|
310
|
+
if (clause.isTypeOnly) {
|
|
311
|
+
return false;
|
|
312
|
+
}
|
|
310
313
|
const bindings = clause.namedBindings;
|
|
311
314
|
if (bindings === undefined || !ts2.isNamedImports(bindings)) {
|
|
312
315
|
return false;
|
|
313
316
|
}
|
|
314
|
-
|
|
317
|
+
const runtime = bindings.elements.filter((element) => !element.isTypeOnly);
|
|
318
|
+
if (runtime.length === 0) {
|
|
319
|
+
return false;
|
|
320
|
+
}
|
|
321
|
+
return runtime.every((element) => FACTORY_NAMES.has((element.propertyName ?? element.name).text));
|
|
315
322
|
}
|
|
316
323
|
var lifecycleErasurePlugin = {
|
|
317
324
|
visitors: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defold-typescript/transpiler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "TypeScript-to-Lua build pipeline tuned for Defold's runtime.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"test": "bun test"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@defold-typescript/types": "0.
|
|
38
|
+
"@defold-typescript/types": "0.24.0",
|
|
39
39
|
"@typescript-to-lua/language-extensions": "1.19.0",
|
|
40
40
|
"typescript-to-lua": "^1.36.0"
|
|
41
41
|
}
|
package/src/lifecycle-erasure.ts
CHANGED
|
@@ -312,13 +312,22 @@ export function isFactoryOnlyImport(node: ts.ImportDeclaration): boolean {
|
|
|
312
312
|
if (clause === undefined || clause.name !== undefined) {
|
|
313
313
|
return false;
|
|
314
314
|
}
|
|
315
|
+
// A whole-clause `import type { ... }` binds nothing at runtime; leave it for
|
|
316
|
+
// the normal transform, which elides it.
|
|
317
|
+
if (clause.isTypeOnly) {
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
315
320
|
const bindings = clause.namedBindings;
|
|
316
321
|
if (bindings === undefined || !ts.isNamedImports(bindings)) {
|
|
317
322
|
return false;
|
|
318
323
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
);
|
|
324
|
+
// Type-only specifiers ride along and drop with the erased statement; erase
|
|
325
|
+
// only when every runtime specifier is a lifecycle factory.
|
|
326
|
+
const runtime = bindings.elements.filter((element) => !element.isTypeOnly);
|
|
327
|
+
if (runtime.length === 0) {
|
|
328
|
+
return false;
|
|
329
|
+
}
|
|
330
|
+
return runtime.every((element) => FACTORY_NAMES.has((element.propertyName ?? element.name).text));
|
|
322
331
|
}
|
|
323
332
|
|
|
324
333
|
export const lifecycleErasurePlugin: Plugin = {
|