@absolutejs/absolute 0.20.0-beta.173 → 0.20.0-beta.174
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/CHANGELOG.md +7 -0
- package/changelog.json +11 -0
- package/dist/angular/components/core/streamingSlotRegistrar.js +1 -1
- package/dist/angular/components/core/streamingSlotRegistry.js +2 -2
- package/dist/angular/index.js +47 -27
- package/dist/angular/index.js.map +6 -5
- package/dist/angular/server.js +47 -27
- package/dist/angular/server.js.map +6 -5
- package/dist/build.js +635 -613
- package/dist/build.js.map +25 -24
- package/dist/cli/{add-ae6mg79m.js → add-ntg96znk.js} +32 -31
- package/dist/cli/{compile-ndc36zna.js → compile-n6fs2vmx.js} +16 -14
- package/dist/cli/config/server.js +85 -65
- package/dist/cli/{dev-x49583aj.js → dev-6h1f0mzq.js} +1 -1
- package/dist/cli/{expoProject-h404n2r8.js → expoProject-1qtw97js.js} +2 -1
- package/dist/cli/{generate-brvjesd6.js → generate-5vyz1s44.js} +7 -6
- package/dist/cli/{htmx-5twhjz7p.js → htmx-26hs6jdm.js} +2 -1
- package/dist/cli/{index-gyjxrnnz.js → index-23hvdyxf.js} +18 -16
- package/dist/cli/index-4j1twret.js +22 -0
- package/dist/cli/{index-25e7k849.js → index-bhyd3ejc.js} +4 -4
- package/dist/cli/{index-s0r5q839.js → index-cksezef8.js} +10 -8
- package/dist/cli/{index-q3snnhyd.js → index-enbw9484.js} +34 -33
- package/dist/cli/{index-b1wht4q5.js → index-kes8he5s.js} +6 -4
- package/dist/cli/{index-z794p5qg.js → index-mqevg32w.js} +22 -19
- package/dist/cli/{index-vh68jb0e.js → index-pkw3jktb.js} +17 -16
- package/dist/cli/{index-rervww4p.js → index-zyd80s3h.js} +119 -119
- package/dist/cli/index.js +11 -11
- package/dist/cli/{islands-p4vgx7a2.js → islands-vk05sj6v.js} +5 -4
- package/dist/cli/{mobile-nqdkk3gd.js → mobile-62b6j3j7.js} +5 -4
- package/dist/cli/{remove-abaf0w6k.js → remove-4jh862qa.js} +6 -5
- package/dist/cli/{start-t3cq57wn.js → start-jh6kyp92.js} +5 -4
- package/dist/cli/{typecheck-fag7djt5.js → typecheck-7fvww3b7.js} +28 -26
- package/dist/dev/importCostReport.js +45 -26
- package/dist/index.js +633 -611
- package/dist/index.js.map +25 -24
- package/dist/mobile/index.js +115 -95
- package/dist/mobile/index.js.map +6 -5
- package/dist/mobile/remoteMacAgentEntry.js +205 -651
- package/dist/src/cli/config/absolute/resolveAbsoluteConfig.d.ts +3 -3
- package/dist/src/cli/config/auth/resolveAuthSettings.d.ts +3 -3
- package/dist/src/dev/angular/fastHmrCompiler.d.ts +2 -2
- package/dist/src/dev/angular/hmrImportGenerator.d.ts +2 -2
- package/dist/src/dev/angular/vendor/translator/ts_util.d.ts +2 -2
- package/dist/src/dev/angular/vendor/translator/typescript_ast_factory.d.ts +40 -40
- package/dist/src/dev/angular/vendor/translator/typescript_translator.d.ts +3 -3
- package/dist/src/utils/lazyTypescript.d.ts +3 -0
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -54,7 +54,7 @@ if (command === "dev") {
|
|
|
54
54
|
}
|
|
55
55
|
const positionalArgs = stripNamedArgs("--config", "--android-device", "--ios-device").filter((arg) => arg !== "--no-mobile" && arg !== "--eager");
|
|
56
56
|
const serverEntry = positionalArgs[0] ?? DEFAULT_SERVER_ENTRY;
|
|
57
|
-
const { dev } = await import("./dev-
|
|
57
|
+
const { dev } = await import("./dev-6h1f0mzq.js");
|
|
58
58
|
await dev(serverEntry, configPath, {
|
|
59
59
|
androidDevice,
|
|
60
60
|
eager: args.includes("--eager"),
|
|
@@ -70,7 +70,7 @@ if (command === "dev") {
|
|
|
70
70
|
const configPath = parseNamedArg("--config");
|
|
71
71
|
const positionalArgs = stripNamedArgs("--outdir", "--config").filter((arg) => arg !== "--prebuilt");
|
|
72
72
|
const serverEntry = positionalArgs[0] ?? DEFAULT_SERVER_ENTRY;
|
|
73
|
-
const { start } = await import("./start-
|
|
73
|
+
const { start } = await import("./start-jh6kyp92.js");
|
|
74
74
|
await start(serverEntry, outdir, configPath, {
|
|
75
75
|
prebuilt: args.includes("--prebuilt")
|
|
76
76
|
});
|
|
@@ -80,7 +80,7 @@ if (command === "dev") {
|
|
|
80
80
|
const configPath = parseNamedArg("--config");
|
|
81
81
|
const positionalArgs = stripNamedArgs("--outdir", "--config");
|
|
82
82
|
const serverEntry = positionalArgs[0] ?? DEFAULT_SERVER_ENTRY;
|
|
83
|
-
const { start } = await import("./start-
|
|
83
|
+
const { start } = await import("./start-jh6kyp92.js");
|
|
84
84
|
await start(serverEntry, outdir, configPath, { prepareOnly: true });
|
|
85
85
|
} else if (command === "build") {
|
|
86
86
|
sendTelemetryEvent("cli:command", { command });
|
|
@@ -133,11 +133,11 @@ if (command === "dev") {
|
|
|
133
133
|
await runMem(args);
|
|
134
134
|
} else if (command === "generate" || command === "g") {
|
|
135
135
|
sendTelemetryEvent("cli:command", { command: "generate" });
|
|
136
|
-
const { runGenerate } = await import("./generate-
|
|
136
|
+
const { runGenerate } = await import("./generate-5vyz1s44.js");
|
|
137
137
|
await runGenerate(args);
|
|
138
138
|
} else if (command === "add") {
|
|
139
139
|
sendTelemetryEvent("cli:command", { command: "add" });
|
|
140
|
-
const { runAdd } = await import("./add-
|
|
140
|
+
const { runAdd } = await import("./add-ntg96znk.js");
|
|
141
141
|
await runAdd(args);
|
|
142
142
|
} else if (command === "analyze") {
|
|
143
143
|
sendTelemetryEvent("cli:command", { command: "analyze" });
|
|
@@ -149,11 +149,11 @@ if (command === "dev") {
|
|
|
149
149
|
await runApi(args);
|
|
150
150
|
} else if (command === "remove") {
|
|
151
151
|
sendTelemetryEvent("cli:command", { command: "remove" });
|
|
152
|
-
const { runRemove } = await import("./remove-
|
|
152
|
+
const { runRemove } = await import("./remove-4jh862qa.js");
|
|
153
153
|
await runRemove(args);
|
|
154
154
|
} else if (command === "htmx") {
|
|
155
155
|
sendTelemetryEvent("cli:command", { command: "htmx" });
|
|
156
|
-
const { runHtmx } = await import("./htmx-
|
|
156
|
+
const { runHtmx } = await import("./htmx-26hs6jdm.js");
|
|
157
157
|
await runHtmx(args);
|
|
158
158
|
} else if (command === "env") {
|
|
159
159
|
sendTelemetryEvent("cli:command", { command: "env" });
|
|
@@ -188,7 +188,7 @@ if (command === "dev") {
|
|
|
188
188
|
await runInspect(args);
|
|
189
189
|
} else if (command === "islands") {
|
|
190
190
|
sendTelemetryEvent("cli:command", { command: "islands" });
|
|
191
|
-
const { runIslands } = await import("./islands-
|
|
191
|
+
const { runIslands } = await import("./islands-vk05sj6v.js");
|
|
192
192
|
await runIslands(args);
|
|
193
193
|
} else if (command === "info") {
|
|
194
194
|
sendTelemetryEvent("cli:command", { command });
|
|
@@ -205,13 +205,13 @@ if (command === "dev") {
|
|
|
205
205
|
const configPath = parseNamedArg("--config");
|
|
206
206
|
const positionalArgs = stripNamedArgs("--outdir", "--outfile", "--config");
|
|
207
207
|
const serverEntry = positionalArgs[0] ?? DEFAULT_SERVER_ENTRY;
|
|
208
|
-
const { compile } = await import("./compile-
|
|
208
|
+
const { compile } = await import("./compile-n6fs2vmx.js");
|
|
209
209
|
await compile(serverEntry, outdir, outfile, configPath);
|
|
210
210
|
} else if (command === "mobile") {
|
|
211
211
|
sendTelemetryEvent("cli:command", {
|
|
212
212
|
command: `mobile:${workspaceCommand ?? "unknown"}`
|
|
213
213
|
});
|
|
214
|
-
const { runMobile } = await import("./mobile-
|
|
214
|
+
const { runMobile } = await import("./mobile-62b6j3j7.js");
|
|
215
215
|
try {
|
|
216
216
|
await runMobile(args);
|
|
217
217
|
} catch (error) {
|
|
@@ -221,7 +221,7 @@ if (command === "dev") {
|
|
|
221
221
|
} else if (command === "typecheck") {
|
|
222
222
|
sendTelemetryEvent("cli:command", { command });
|
|
223
223
|
const configPath = parseNamedArg("--config");
|
|
224
|
-
const { typecheck } = await import("./typecheck-
|
|
224
|
+
const { typecheck } = await import("./typecheck-7fvww3b7.js");
|
|
225
225
|
await typecheck(configPath);
|
|
226
226
|
} else if (command === "migrate") {
|
|
227
227
|
sendTelemetryEvent("cli:command", { command });
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import
|
|
3
|
-
getIslandManifestKey,
|
|
4
|
-
loadIslandRegistryBuildInfo
|
|
5
|
-
} from "./index-z794p5qg.js";
|
|
2
|
+
import"./index-4j1twret.js";
|
|
6
3
|
import {
|
|
7
4
|
loadConfig
|
|
8
5
|
} from "./index-wk0pyxrg.js";
|
|
@@ -14,6 +11,10 @@ import {
|
|
|
14
11
|
import {
|
|
15
12
|
formatBytes
|
|
16
13
|
} from "./index-7854xf0m.js";
|
|
14
|
+
import {
|
|
15
|
+
getIslandManifestKey,
|
|
16
|
+
loadIslandRegistryBuildInfo
|
|
17
|
+
} from "./index-mqevg32w.js";
|
|
17
18
|
|
|
18
19
|
// src/cli/scripts/islands.ts
|
|
19
20
|
import { existsSync as existsSync2, readFileSync as readFileSync2, statSync } from "fs";
|
|
@@ -26,11 +26,12 @@ import {
|
|
|
26
26
|
renderAbsoluteMobileBrandingPreview,
|
|
27
27
|
writeAbsoluteExpoProject2,
|
|
28
28
|
syncAbsoluteExpoWebAssets2
|
|
29
|
-
} from "./index-
|
|
29
|
+
} from "./index-cksezef8.js";
|
|
30
30
|
import {
|
|
31
31
|
projectUsesAbsoluteAuth2,
|
|
32
32
|
projectUsesAbsoluteSync2
|
|
33
33
|
} from "./index-pch0v1z6.js";
|
|
34
|
+
import"./index-4j1twret.js";
|
|
34
35
|
import {
|
|
35
36
|
normalizeAbsoluteMobileConfig2
|
|
36
37
|
} from "./index-t7yf3vxs.js";
|
|
@@ -62,7 +63,7 @@ import {
|
|
|
62
63
|
resolveAbsoluteMobileRoute,
|
|
63
64
|
ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION,
|
|
64
65
|
ABSOLUTE_MOBILE_CLIENT_MANIFEST_FORMAT
|
|
65
|
-
} from "./index-
|
|
66
|
+
} from "./index-zyd80s3h.js";
|
|
66
67
|
import {
|
|
67
68
|
buildAbsoluteExpoAndroidWslBundle2
|
|
68
69
|
} from "./index-3sfcmb49.js";
|
|
@@ -76,10 +77,9 @@ import {
|
|
|
76
77
|
parseIosSimulators2,
|
|
77
78
|
repairAbsoluteIosDevSession2
|
|
78
79
|
} from "./index-prza6tkp.js";
|
|
79
|
-
import"./index-z794p5qg.js";
|
|
80
80
|
import {
|
|
81
81
|
start2
|
|
82
|
-
} from "./index-
|
|
82
|
+
} from "./index-bhyd3ejc.js";
|
|
83
83
|
import {
|
|
84
84
|
captureAbsoluteRemoteMacCommand2,
|
|
85
85
|
getAbsoluteRemoteMacProfile2,
|
|
@@ -99,6 +99,7 @@ import {
|
|
|
99
99
|
import {
|
|
100
100
|
formatBytes
|
|
101
101
|
} from "./index-7854xf0m.js";
|
|
102
|
+
import"./index-mqevg32w.js";
|
|
102
103
|
import {
|
|
103
104
|
sendTelemetryEvent
|
|
104
105
|
} from "./index-qyxd5n9a.js";
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
import"./index-4j1twret.js";
|
|
2
3
|
import {
|
|
3
4
|
isFrameworkKey,
|
|
4
5
|
frameworks,
|
|
5
6
|
resolveProject
|
|
6
|
-
} from "./index-
|
|
7
|
-
import {
|
|
8
|
-
applyAbsoluteConfigEdit
|
|
9
|
-
} from "./index-b1wht4q5.js";
|
|
7
|
+
} from "./index-enbw9484.js";
|
|
10
8
|
import"./index-wk0pyxrg.js";
|
|
11
9
|
import"./index-t8jmj8w1.js";
|
|
12
10
|
import {
|
|
13
11
|
findRoutingFile
|
|
14
|
-
} from "./index-
|
|
12
|
+
} from "./index-23hvdyxf.js";
|
|
15
13
|
import {
|
|
16
14
|
colors
|
|
17
15
|
} from "./index-9djrap79.js";
|
|
16
|
+
import {
|
|
17
|
+
applyAbsoluteConfigEdit
|
|
18
|
+
} from "./index-kes8he5s.js";
|
|
18
19
|
import {
|
|
19
20
|
frameworkDependencyNames
|
|
20
21
|
} from "./index-jjfbjv1z.js";
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
start2
|
|
4
|
-
} from "./index-
|
|
5
|
-
import"./index-
|
|
6
|
-
import"./index-
|
|
4
|
+
} from "./index-bhyd3ejc.js";
|
|
5
|
+
import"./index-zyd80s3h.js";
|
|
6
|
+
import"./index-mqevg32w.js";
|
|
7
7
|
import"./index-71gchbzt.js";
|
|
8
8
|
import"./index-wk0pyxrg.js";
|
|
9
9
|
import"./index-qyxd5n9a.js";
|
|
10
10
|
import"./index-43a1vvb7.js";
|
|
11
11
|
import"./index-t7yf3vxs.js";
|
|
12
|
-
import"./index-
|
|
12
|
+
import"./index-cksezef8.js";
|
|
13
|
+
import"./index-4j1twret.js";
|
|
13
14
|
import"./index-pch0v1z6.js";
|
|
14
15
|
import"./index-125cfzvn.js";
|
|
15
16
|
import"./index-3ewt17wm.js";
|
|
@@ -5,6 +5,9 @@ import {
|
|
|
5
5
|
loadConfig,
|
|
6
6
|
loadRawConfig
|
|
7
7
|
} from "./index-wk0pyxrg.js";
|
|
8
|
+
import {
|
|
9
|
+
lazyTypescript
|
|
10
|
+
} from "./index-4j1twret.js";
|
|
8
11
|
import {
|
|
9
12
|
ANSI_ESCAPE_CODE
|
|
10
13
|
} from "./index-t8jmj8w1.js";
|
|
@@ -831,24 +834,23 @@ var ParseErrorCode;
|
|
|
831
834
|
})(ParseErrorCode || (ParseErrorCode = {}));
|
|
832
835
|
|
|
833
836
|
// src/dev/importCost/deferability.ts
|
|
834
|
-
import ts from "typescript";
|
|
835
837
|
var DEFERRED = "deferred";
|
|
836
838
|
var scriptKindFor = (fileName) => {
|
|
837
839
|
if (fileName.endsWith(".tsx"))
|
|
838
|
-
return
|
|
840
|
+
return lazyTypescript.ScriptKind.TSX;
|
|
839
841
|
if (fileName.endsWith(".jsx"))
|
|
840
|
-
return
|
|
842
|
+
return lazyTypescript.ScriptKind.JSX;
|
|
841
843
|
if (fileName.endsWith(".js") || fileName.endsWith(".mjs")) {
|
|
842
|
-
return
|
|
844
|
+
return lazyTypescript.ScriptKind.JS;
|
|
843
845
|
}
|
|
844
|
-
return
|
|
846
|
+
return lazyTypescript.ScriptKind.TS;
|
|
845
847
|
};
|
|
846
848
|
var namedBindings = (clause) => {
|
|
847
849
|
const names = clause.name === undefined ? [] : [clause.name.text];
|
|
848
850
|
const { namedBindings: bindings } = clause;
|
|
849
851
|
if (bindings === undefined)
|
|
850
852
|
return names;
|
|
851
|
-
if (
|
|
853
|
+
if (lazyTypescript.isNamespaceImport(bindings))
|
|
852
854
|
return [...names, bindings.name.text];
|
|
853
855
|
return [
|
|
854
856
|
...names,
|
|
@@ -857,20 +859,20 @@ var namedBindings = (clause) => {
|
|
|
857
859
|
};
|
|
858
860
|
var declarationFrom = (statement, source) => {
|
|
859
861
|
const specifier = statement.moduleSpecifier;
|
|
860
|
-
if (!
|
|
862
|
+
if (!lazyTypescript.isStringLiteral(specifier))
|
|
861
863
|
return null;
|
|
862
864
|
const clause = statement.importClause;
|
|
863
865
|
const bindings = clause === undefined ? [] : namedBindings(clause);
|
|
864
866
|
const declaration = {
|
|
865
867
|
bindings,
|
|
866
|
-
line:
|
|
868
|
+
line: lazyTypescript.getLineAndCharacterOfPosition(source, statement.getStart(source)).line + 1,
|
|
867
869
|
sideEffect: clause === undefined,
|
|
868
870
|
specifier: specifier.text,
|
|
869
871
|
typeOnly: clause !== undefined && (clause.isTypeOnly || bindings.length === 0)
|
|
870
872
|
};
|
|
871
873
|
return declaration;
|
|
872
874
|
};
|
|
873
|
-
var isTypePosition = (node) =>
|
|
875
|
+
var isTypePosition = (node) => lazyTypescript.isTypeNode(node) && !lazyTypescript.isExpressionWithTypeArguments(node);
|
|
874
876
|
var isDeferredPosition = (current, child) => {
|
|
875
877
|
if (Reflect.get(current, "body") === child)
|
|
876
878
|
return true;
|
|
@@ -878,19 +880,19 @@ var isDeferredPosition = (current, child) => {
|
|
|
878
880
|
return Array.isArray(parameters) && parameters.some((parameter) => parameter === child);
|
|
879
881
|
};
|
|
880
882
|
var classifyAncestor = (current, child) => {
|
|
881
|
-
if (
|
|
883
|
+
if (lazyTypescript.isExportSpecifier(current))
|
|
882
884
|
return "re-exported by the entry";
|
|
883
|
-
if (
|
|
885
|
+
if (lazyTypescript.isDecorator(current))
|
|
884
886
|
return "decorator";
|
|
885
|
-
if (
|
|
887
|
+
if (lazyTypescript.isPropertyDeclaration(current) && current.initializer === child) {
|
|
886
888
|
return "class field initializer";
|
|
887
889
|
}
|
|
888
890
|
if (isTypePosition(current))
|
|
889
891
|
return DEFERRED;
|
|
890
|
-
if (
|
|
892
|
+
if (lazyTypescript.isFunctionLike(current) && isDeferredPosition(current, child)) {
|
|
891
893
|
return DEFERRED;
|
|
892
894
|
}
|
|
893
|
-
if (
|
|
895
|
+
if (lazyTypescript.isSourceFile(current))
|
|
894
896
|
return "module scope";
|
|
895
897
|
return null;
|
|
896
898
|
};
|
|
@@ -910,9 +912,9 @@ var classifyUsage = (node) => {
|
|
|
910
912
|
return pending ?? "module scope";
|
|
911
913
|
};
|
|
912
914
|
var isDeclarationName = (parent, node) => {
|
|
913
|
-
if (
|
|
915
|
+
if (lazyTypescript.isExportSpecifier(parent))
|
|
914
916
|
return false;
|
|
915
|
-
if (
|
|
917
|
+
if (lazyTypescript.isShorthandPropertyAssignment(parent))
|
|
916
918
|
return false;
|
|
917
919
|
return Reflect.get(parent, "name") === node;
|
|
918
920
|
};
|
|
@@ -920,7 +922,7 @@ var isReferencePosition = (node) => {
|
|
|
920
922
|
const { parent } = node;
|
|
921
923
|
if (parent === undefined)
|
|
922
924
|
return false;
|
|
923
|
-
if (
|
|
925
|
+
if (lazyTypescript.isQualifiedName(parent) && parent.right === node)
|
|
924
926
|
return false;
|
|
925
927
|
return !isDeclarationName(parent, node);
|
|
926
928
|
};
|
|
@@ -937,13 +939,13 @@ var recordUsage = (node, owners, reasons) => {
|
|
|
937
939
|
var collectUnsafeReasons = (source, owners) => {
|
|
938
940
|
const reasons = new Map;
|
|
939
941
|
const visit = (node) => {
|
|
940
|
-
if (
|
|
942
|
+
if (lazyTypescript.isImportDeclaration(node))
|
|
941
943
|
return;
|
|
942
|
-
if (
|
|
944
|
+
if (lazyTypescript.isIdentifier(node))
|
|
943
945
|
recordUsage(node, owners, reasons);
|
|
944
|
-
|
|
946
|
+
lazyTypescript.forEachChild(node, visit);
|
|
945
947
|
};
|
|
946
|
-
|
|
948
|
+
lazyTypescript.forEachChild(source, visit);
|
|
947
949
|
return reasons;
|
|
948
950
|
};
|
|
949
951
|
var verdictFor = (declaration, reason) => {
|
|
@@ -957,12 +959,12 @@ var verdictFor = (declaration, reason) => {
|
|
|
957
959
|
};
|
|
958
960
|
var reExportOf = (statement, source) => {
|
|
959
961
|
const specifier = statement.moduleSpecifier;
|
|
960
|
-
if (specifier === undefined || !
|
|
962
|
+
if (specifier === undefined || !lazyTypescript.isStringLiteral(specifier))
|
|
961
963
|
return null;
|
|
962
964
|
if (statement.isTypeOnly)
|
|
963
965
|
return null;
|
|
964
966
|
const entry = {
|
|
965
|
-
line:
|
|
967
|
+
line: lazyTypescript.getLineAndCharacterOfPosition(source, statement.getStart(source)).line + 1,
|
|
966
968
|
reason: "re-exported by the entry",
|
|
967
969
|
specifier: specifier.text,
|
|
968
970
|
verdict: "used at module scope"
|
|
@@ -970,9 +972,9 @@ var reExportOf = (statement, source) => {
|
|
|
970
972
|
return entry;
|
|
971
973
|
};
|
|
972
974
|
var analyzeEntryImports = (sourceText, fileName) => {
|
|
973
|
-
const source =
|
|
974
|
-
const declarations = source.statements.filter(
|
|
975
|
-
const reExports = source.statements.filter(
|
|
975
|
+
const source = lazyTypescript.createSourceFile(fileName, sourceText, lazyTypescript.ScriptTarget.ESNext, true, scriptKindFor(fileName));
|
|
976
|
+
const declarations = source.statements.filter(lazyTypescript.isImportDeclaration).map((statement) => declarationFrom(statement, source)).filter((declaration) => declaration !== null);
|
|
977
|
+
const reExports = source.statements.filter(lazyTypescript.isExportDeclaration).map((statement) => reExportOf(statement, source)).filter((entry) => entry !== null);
|
|
976
978
|
const owners = new Map;
|
|
977
979
|
declarations.forEach((declaration, index) => {
|
|
978
980
|
for (const binding of declaration.bindings)
|
|
@@ -3,25 +3,44 @@
|
|
|
3
3
|
import { readFileSync as readFileSync2, writeFileSync } from "fs";
|
|
4
4
|
import { dirname as dirname2, relative } from "path";
|
|
5
5
|
|
|
6
|
+
// src/utils/lazyTypescript.ts
|
|
7
|
+
import { createRequire } from "module";
|
|
8
|
+
var loaded;
|
|
9
|
+
var loadTypescript = () => {
|
|
10
|
+
if (loaded)
|
|
11
|
+
return loaded;
|
|
12
|
+
const requireFromHere = createRequire(import.meta.url);
|
|
13
|
+
const typescript = requireFromHere("typescript");
|
|
14
|
+
loaded = typescript;
|
|
15
|
+
return typescript;
|
|
16
|
+
};
|
|
17
|
+
var createLazyTypescript = () => {
|
|
18
|
+
const target = Object.create(null);
|
|
19
|
+
return new Proxy(target, {
|
|
20
|
+
get: (_target, key) => Reflect.get(loadTypescript(), key),
|
|
21
|
+
has: (_target, key) => Reflect.has(loadTypescript(), key)
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
var lazyTypescript = createLazyTypescript();
|
|
25
|
+
|
|
6
26
|
// src/dev/importCost/deferability.ts
|
|
7
|
-
import ts from "typescript";
|
|
8
27
|
var DEFERRED = "deferred";
|
|
9
28
|
var scriptKindFor = (fileName) => {
|
|
10
29
|
if (fileName.endsWith(".tsx"))
|
|
11
|
-
return
|
|
30
|
+
return lazyTypescript.ScriptKind.TSX;
|
|
12
31
|
if (fileName.endsWith(".jsx"))
|
|
13
|
-
return
|
|
32
|
+
return lazyTypescript.ScriptKind.JSX;
|
|
14
33
|
if (fileName.endsWith(".js") || fileName.endsWith(".mjs")) {
|
|
15
|
-
return
|
|
34
|
+
return lazyTypescript.ScriptKind.JS;
|
|
16
35
|
}
|
|
17
|
-
return
|
|
36
|
+
return lazyTypescript.ScriptKind.TS;
|
|
18
37
|
};
|
|
19
38
|
var namedBindings = (clause) => {
|
|
20
39
|
const names = clause.name === undefined ? [] : [clause.name.text];
|
|
21
40
|
const { namedBindings: bindings } = clause;
|
|
22
41
|
if (bindings === undefined)
|
|
23
42
|
return names;
|
|
24
|
-
if (
|
|
43
|
+
if (lazyTypescript.isNamespaceImport(bindings))
|
|
25
44
|
return [...names, bindings.name.text];
|
|
26
45
|
return [
|
|
27
46
|
...names,
|
|
@@ -30,20 +49,20 @@ var namedBindings = (clause) => {
|
|
|
30
49
|
};
|
|
31
50
|
var declarationFrom = (statement, source) => {
|
|
32
51
|
const specifier = statement.moduleSpecifier;
|
|
33
|
-
if (!
|
|
52
|
+
if (!lazyTypescript.isStringLiteral(specifier))
|
|
34
53
|
return null;
|
|
35
54
|
const clause = statement.importClause;
|
|
36
55
|
const bindings = clause === undefined ? [] : namedBindings(clause);
|
|
37
56
|
const declaration = {
|
|
38
57
|
bindings,
|
|
39
|
-
line:
|
|
58
|
+
line: lazyTypescript.getLineAndCharacterOfPosition(source, statement.getStart(source)).line + 1,
|
|
40
59
|
sideEffect: clause === undefined,
|
|
41
60
|
specifier: specifier.text,
|
|
42
61
|
typeOnly: clause !== undefined && (clause.isTypeOnly || bindings.length === 0)
|
|
43
62
|
};
|
|
44
63
|
return declaration;
|
|
45
64
|
};
|
|
46
|
-
var isTypePosition = (node) =>
|
|
65
|
+
var isTypePosition = (node) => lazyTypescript.isTypeNode(node) && !lazyTypescript.isExpressionWithTypeArguments(node);
|
|
47
66
|
var isDeferredPosition = (current, child) => {
|
|
48
67
|
if (Reflect.get(current, "body") === child)
|
|
49
68
|
return true;
|
|
@@ -51,19 +70,19 @@ var isDeferredPosition = (current, child) => {
|
|
|
51
70
|
return Array.isArray(parameters) && parameters.some((parameter) => parameter === child);
|
|
52
71
|
};
|
|
53
72
|
var classifyAncestor = (current, child) => {
|
|
54
|
-
if (
|
|
73
|
+
if (lazyTypescript.isExportSpecifier(current))
|
|
55
74
|
return "re-exported by the entry";
|
|
56
|
-
if (
|
|
75
|
+
if (lazyTypescript.isDecorator(current))
|
|
57
76
|
return "decorator";
|
|
58
|
-
if (
|
|
77
|
+
if (lazyTypescript.isPropertyDeclaration(current) && current.initializer === child) {
|
|
59
78
|
return "class field initializer";
|
|
60
79
|
}
|
|
61
80
|
if (isTypePosition(current))
|
|
62
81
|
return DEFERRED;
|
|
63
|
-
if (
|
|
82
|
+
if (lazyTypescript.isFunctionLike(current) && isDeferredPosition(current, child)) {
|
|
64
83
|
return DEFERRED;
|
|
65
84
|
}
|
|
66
|
-
if (
|
|
85
|
+
if (lazyTypescript.isSourceFile(current))
|
|
67
86
|
return "module scope";
|
|
68
87
|
return null;
|
|
69
88
|
};
|
|
@@ -83,9 +102,9 @@ var classifyUsage = (node) => {
|
|
|
83
102
|
return pending ?? "module scope";
|
|
84
103
|
};
|
|
85
104
|
var isDeclarationName = (parent, node) => {
|
|
86
|
-
if (
|
|
105
|
+
if (lazyTypescript.isExportSpecifier(parent))
|
|
87
106
|
return false;
|
|
88
|
-
if (
|
|
107
|
+
if (lazyTypescript.isShorthandPropertyAssignment(parent))
|
|
89
108
|
return false;
|
|
90
109
|
return Reflect.get(parent, "name") === node;
|
|
91
110
|
};
|
|
@@ -93,7 +112,7 @@ var isReferencePosition = (node) => {
|
|
|
93
112
|
const { parent } = node;
|
|
94
113
|
if (parent === undefined)
|
|
95
114
|
return false;
|
|
96
|
-
if (
|
|
115
|
+
if (lazyTypescript.isQualifiedName(parent) && parent.right === node)
|
|
97
116
|
return false;
|
|
98
117
|
return !isDeclarationName(parent, node);
|
|
99
118
|
};
|
|
@@ -110,13 +129,13 @@ var recordUsage = (node, owners, reasons) => {
|
|
|
110
129
|
var collectUnsafeReasons = (source, owners) => {
|
|
111
130
|
const reasons = new Map;
|
|
112
131
|
const visit = (node) => {
|
|
113
|
-
if (
|
|
132
|
+
if (lazyTypescript.isImportDeclaration(node))
|
|
114
133
|
return;
|
|
115
|
-
if (
|
|
134
|
+
if (lazyTypescript.isIdentifier(node))
|
|
116
135
|
recordUsage(node, owners, reasons);
|
|
117
|
-
|
|
136
|
+
lazyTypescript.forEachChild(node, visit);
|
|
118
137
|
};
|
|
119
|
-
|
|
138
|
+
lazyTypescript.forEachChild(source, visit);
|
|
120
139
|
return reasons;
|
|
121
140
|
};
|
|
122
141
|
var verdictFor = (declaration, reason) => {
|
|
@@ -130,12 +149,12 @@ var verdictFor = (declaration, reason) => {
|
|
|
130
149
|
};
|
|
131
150
|
var reExportOf = (statement, source) => {
|
|
132
151
|
const specifier = statement.moduleSpecifier;
|
|
133
|
-
if (specifier === undefined || !
|
|
152
|
+
if (specifier === undefined || !lazyTypescript.isStringLiteral(specifier))
|
|
134
153
|
return null;
|
|
135
154
|
if (statement.isTypeOnly)
|
|
136
155
|
return null;
|
|
137
156
|
const entry = {
|
|
138
|
-
line:
|
|
157
|
+
line: lazyTypescript.getLineAndCharacterOfPosition(source, statement.getStart(source)).line + 1,
|
|
139
158
|
reason: "re-exported by the entry",
|
|
140
159
|
specifier: specifier.text,
|
|
141
160
|
verdict: "used at module scope"
|
|
@@ -143,9 +162,9 @@ var reExportOf = (statement, source) => {
|
|
|
143
162
|
return entry;
|
|
144
163
|
};
|
|
145
164
|
var analyzeEntryImports = (sourceText, fileName) => {
|
|
146
|
-
const source =
|
|
147
|
-
const declarations = source.statements.filter(
|
|
148
|
-
const reExports = source.statements.filter(
|
|
165
|
+
const source = lazyTypescript.createSourceFile(fileName, sourceText, lazyTypescript.ScriptTarget.ESNext, true, scriptKindFor(fileName));
|
|
166
|
+
const declarations = source.statements.filter(lazyTypescript.isImportDeclaration).map((statement) => declarationFrom(statement, source)).filter((declaration) => declaration !== null);
|
|
167
|
+
const reExports = source.statements.filter(lazyTypescript.isExportDeclaration).map((statement) => reExportOf(statement, source)).filter((entry) => entry !== null);
|
|
149
168
|
const owners = new Map;
|
|
150
169
|
declarations.forEach((declaration, index) => {
|
|
151
170
|
for (const binding of declaration.bindings)
|