dismantle 0.3.0 → 0.4.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/dist/cjs/development/index.cjs +148 -104
- package/dist/cjs/development/index.cjs.map +2 -2
- package/dist/cjs/development/runtime.cjs +32 -1928
- package/dist/cjs/development/runtime.cjs.map +4 -4
- package/dist/cjs/production/index.cjs +1 -1
- package/dist/cjs/production/runtime.cjs +1 -1
- package/dist/esm/development/index.mjs +148 -104
- package/dist/esm/development/index.mjs.map +2 -2
- package/dist/esm/development/runtime.mjs +29 -1915
- package/dist/esm/development/runtime.mjs.map +4 -4
- package/dist/esm/production/index.mjs +1 -1
- package/dist/esm/production/runtime.mjs +1 -1
- package/dist/types/runtime/index.d.ts +10 -0
- package/dist/types/runtime/index.d.ts.map +1 -0
- package/dist/types/src/hidden-imports.d.ts.map +1 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/split-block-directive.d.ts.map +1 -0
- package/dist/types/src/split-call.d.ts.map +1 -0
- package/dist/types/src/split-function-directive.d.ts.map +1 -0
- package/dist/types/{split.d.ts → src/split.d.ts} +1 -1
- package/dist/types/src/split.d.ts.map +1 -0
- package/dist/types/src/transform-block-directive.d.ts.map +1 -0
- package/dist/types/src/transform-call.d.ts.map +1 -0
- package/dist/types/src/transform-function-directive.d.ts.map +1 -0
- package/dist/types/{types.d.ts → src/types.d.ts} +4 -0
- package/dist/types/src/types.d.ts.map +1 -0
- package/dist/types/src/utils/assert.d.ts.map +1 -0
- package/dist/types/src/utils/bubble-function-declaration.d.ts.map +1 -0
- package/dist/types/src/utils/directive-check.d.ts.map +1 -0
- package/dist/types/src/utils/generate-unique-name.d.ts.map +1 -0
- package/dist/types/src/utils/generator-shim.d.ts.map +1 -0
- package/dist/types/src/utils/get-descriptive-name.d.ts.map +1 -0
- package/dist/types/src/utils/get-foreign-bindings.d.ts.map +1 -0
- package/dist/types/src/utils/get-identifiers-from-lval.d.ts.map +1 -0
- package/dist/types/src/utils/get-import-identifier.d.ts.map +1 -0
- package/dist/types/src/utils/get-import-specifier-name.d.ts.map +1 -0
- package/dist/types/src/utils/get-module-definition.d.ts.map +1 -0
- package/dist/types/src/utils/get-root-statement-path.d.ts.map +1 -0
- package/dist/types/src/utils/is-statement-top-level.d.ts.map +1 -0
- package/dist/types/src/utils/register-import-specifiers.d.ts.map +1 -0
- package/dist/types/src/utils/unwrap.d.ts.map +1 -0
- package/dist/types/src/utils/xxhash32.d.ts.map +1 -0
- package/package.json +11 -11
- package/src/split-block-directive.ts +52 -37
- package/src/split-call.ts +45 -30
- package/src/split-function-directive.ts +44 -30
- package/src/split.ts +2 -1
- package/src/types.ts +4 -0
- package/dist/types/hidden-imports.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/plugin.d.ts.map +0 -1
- package/dist/types/split-block-directive.d.ts.map +0 -1
- package/dist/types/split-call.d.ts.map +0 -1
- package/dist/types/split-function-directive.d.ts.map +0 -1
- package/dist/types/split.d.ts.map +0 -1
- package/dist/types/transform-block-directive.d.ts.map +0 -1
- package/dist/types/transform-call.d.ts.map +0 -1
- package/dist/types/transform-function-directive.d.ts.map +0 -1
- package/dist/types/types.d.ts.map +0 -1
- package/dist/types/utils/assert.d.ts.map +0 -1
- package/dist/types/utils/bubble-function-declaration.d.ts.map +0 -1
- package/dist/types/utils/directive-check.d.ts.map +0 -1
- package/dist/types/utils/generate-unique-name.d.ts.map +0 -1
- package/dist/types/utils/generator-shim.d.ts.map +0 -1
- package/dist/types/utils/get-descriptive-name.d.ts.map +0 -1
- package/dist/types/utils/get-foreign-bindings.d.ts.map +0 -1
- package/dist/types/utils/get-identifiers-from-lval.d.ts.map +0 -1
- package/dist/types/utils/get-import-identifier.d.ts.map +0 -1
- package/dist/types/utils/get-import-specifier-name.d.ts.map +0 -1
- package/dist/types/utils/get-module-definition.d.ts.map +0 -1
- package/dist/types/utils/get-root-statement-path.d.ts.map +0 -1
- package/dist/types/utils/is-statement-top-level.d.ts.map +0 -1
- package/dist/types/utils/register-import-specifiers.d.ts.map +0 -1
- package/dist/types/utils/unwrap.d.ts.map +0 -1
- package/dist/types/utils/xxhash32.d.ts.map +0 -1
- /package/dist/types/{hidden-imports.d.ts → src/hidden-imports.d.ts} +0 -0
- /package/dist/types/{index.d.ts → src/index.d.ts} +0 -0
- /package/dist/types/{plugin.d.ts → src/plugin.d.ts} +0 -0
- /package/dist/types/{split-block-directive.d.ts → src/split-block-directive.d.ts} +0 -0
- /package/dist/types/{split-call.d.ts → src/split-call.d.ts} +0 -0
- /package/dist/types/{split-function-directive.d.ts → src/split-function-directive.d.ts} +0 -0
- /package/dist/types/{transform-block-directive.d.ts → src/transform-block-directive.d.ts} +0 -0
- /package/dist/types/{transform-call.d.ts → src/transform-call.d.ts} +0 -0
- /package/dist/types/{transform-function-directive.d.ts → src/transform-function-directive.d.ts} +0 -0
- /package/dist/types/{utils → src/utils}/assert.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/bubble-function-declaration.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/directive-check.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/generate-unique-name.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/generator-shim.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/get-descriptive-name.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/get-foreign-bindings.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/get-identifiers-from-lval.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/get-import-identifier.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/get-import-specifier-name.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/get-module-definition.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/get-root-statement-path.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/is-statement-top-level.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/register-import-specifiers.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/unwrap.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/xxhash32.d.ts +0 -0
|
@@ -427,8 +427,8 @@ function createRootFile(ctx, bindings, replacement) {
|
|
|
427
427
|
);
|
|
428
428
|
return rootFile;
|
|
429
429
|
}
|
|
430
|
-
function createEntryFile(ctx, path2, rootFile, imported) {
|
|
431
|
-
let id = `${ctx.blocks.hash}-${ctx.blocks.count++}`;
|
|
430
|
+
function createEntryFile(ctx, path2, rootFile, imported, idPrefix) {
|
|
431
|
+
let id = `${idPrefix || ""}${ctx.blocks.hash}-${ctx.blocks.count++}`;
|
|
432
432
|
if (ctx.options.env !== "production") {
|
|
433
433
|
id += `-${getDescriptiveName(path2, "anonymous")}`;
|
|
434
434
|
}
|
|
@@ -809,24 +809,32 @@ function getBlockDirectiveReplacement(ctx, path2, entryFile, bindings, halting)
|
|
|
809
809
|
t9.variableDeclaration("const", [
|
|
810
810
|
t9.variableDeclarator(
|
|
811
811
|
blockID,
|
|
812
|
-
t9.callExpression(
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
),
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
t9.objectPattern(
|
|
822
|
-
bindings.mutations.map(
|
|
823
|
-
(item) => t9.objectProperty(item, item, false, true)
|
|
824
|
-
)
|
|
812
|
+
t9.callExpression(
|
|
813
|
+
getImportIdentifier(ctx, path2, {
|
|
814
|
+
...HIDDEN_GENERATOR,
|
|
815
|
+
source: ctx.options.runtime
|
|
816
|
+
}),
|
|
817
|
+
[
|
|
818
|
+
t9.memberExpression(
|
|
819
|
+
t9.awaitExpression(
|
|
820
|
+
t9.importExpression(t9.stringLiteral(entryFile))
|
|
825
821
|
),
|
|
826
|
-
|
|
827
|
-
)
|
|
828
|
-
|
|
829
|
-
|
|
822
|
+
t9.identifier("default")
|
|
823
|
+
),
|
|
824
|
+
bindings.mutations.length ? t9.arrowFunctionExpression(
|
|
825
|
+
[returnMutations],
|
|
826
|
+
t9.assignmentExpression(
|
|
827
|
+
"=",
|
|
828
|
+
t9.objectPattern(
|
|
829
|
+
bindings.mutations.map(
|
|
830
|
+
(item) => t9.objectProperty(item, item, false, true)
|
|
831
|
+
)
|
|
832
|
+
),
|
|
833
|
+
returnMutations
|
|
834
|
+
)
|
|
835
|
+
) : t9.nullLiteral()
|
|
836
|
+
]
|
|
837
|
+
)
|
|
830
838
|
)
|
|
831
839
|
])
|
|
832
840
|
);
|
|
@@ -853,26 +861,32 @@ function getBlockDirectiveReplacement(ctx, path2, entryFile, bindings, halting)
|
|
|
853
861
|
t9.arrayPattern([returnType, returnResult]),
|
|
854
862
|
t9.awaitExpression(
|
|
855
863
|
t9.callExpression(
|
|
856
|
-
t9.callExpression(
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
t9.assignmentExpression(
|
|
866
|
-
"=",
|
|
867
|
-
t9.objectPattern(
|
|
868
|
-
bindings.mutations.map(
|
|
869
|
-
(item) => t9.objectProperty(item, item, false, true)
|
|
870
|
-
)
|
|
864
|
+
t9.callExpression(
|
|
865
|
+
getImportIdentifier(ctx, path2, {
|
|
866
|
+
...HIDDEN_FUNC,
|
|
867
|
+
source: ctx.options.runtime
|
|
868
|
+
}),
|
|
869
|
+
[
|
|
870
|
+
t9.memberExpression(
|
|
871
|
+
t9.awaitExpression(
|
|
872
|
+
t9.importExpression(t9.stringLiteral(entryFile))
|
|
871
873
|
),
|
|
872
|
-
|
|
873
|
-
)
|
|
874
|
-
|
|
875
|
-
|
|
874
|
+
t9.identifier("default")
|
|
875
|
+
),
|
|
876
|
+
bindings.mutations.length ? t9.arrowFunctionExpression(
|
|
877
|
+
[returnMutations],
|
|
878
|
+
t9.assignmentExpression(
|
|
879
|
+
"=",
|
|
880
|
+
t9.objectPattern(
|
|
881
|
+
bindings.mutations.map(
|
|
882
|
+
(item) => t9.objectProperty(item, item, false, true)
|
|
883
|
+
)
|
|
884
|
+
),
|
|
885
|
+
returnMutations
|
|
886
|
+
)
|
|
887
|
+
) : t9.nullLiteral()
|
|
888
|
+
]
|
|
889
|
+
),
|
|
876
890
|
bindings.locals
|
|
877
891
|
)
|
|
878
892
|
)
|
|
@@ -901,7 +915,8 @@ function replaceBlockDirective(ctx, path2, directive, bindings) {
|
|
|
901
915
|
true
|
|
902
916
|
)
|
|
903
917
|
) : void 0,
|
|
904
|
-
directive.target
|
|
918
|
+
directive.target,
|
|
919
|
+
directive.idPrefix
|
|
905
920
|
);
|
|
906
921
|
path2.replaceWith(
|
|
907
922
|
getBlockDirectiveReplacement(ctx, path2, entryFile, bindings, halting)
|
|
@@ -1089,21 +1104,27 @@ function getFunctionReplacement(ctx, path2, entryFile, bindings) {
|
|
|
1089
1104
|
t11.variableDeclaration("const", [
|
|
1090
1105
|
t11.variableDeclarator(
|
|
1091
1106
|
funcID,
|
|
1092
|
-
t11.callExpression(
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
+
t11.callExpression(
|
|
1108
|
+
getImportIdentifier(ctx, path2, {
|
|
1109
|
+
...HIDDEN_GENERATOR,
|
|
1110
|
+
source: ctx.options.runtime
|
|
1111
|
+
}),
|
|
1112
|
+
[
|
|
1113
|
+
source,
|
|
1114
|
+
bindings.mutations.length ? t11.arrowFunctionExpression(
|
|
1115
|
+
[returnMutations],
|
|
1116
|
+
t11.assignmentExpression(
|
|
1117
|
+
"=",
|
|
1118
|
+
t11.objectPattern(
|
|
1119
|
+
bindings.mutations.map(
|
|
1120
|
+
(item) => t11.objectProperty(item, item, false, true)
|
|
1121
|
+
)
|
|
1122
|
+
),
|
|
1123
|
+
returnMutations
|
|
1124
|
+
)
|
|
1125
|
+
) : t11.nullLiteral()
|
|
1126
|
+
]
|
|
1127
|
+
)
|
|
1107
1128
|
)
|
|
1108
1129
|
])
|
|
1109
1130
|
);
|
|
@@ -1129,21 +1150,27 @@ function getFunctionReplacement(ctx, path2, entryFile, bindings) {
|
|
|
1129
1150
|
t11.arrayPattern([returnType, returnResult]),
|
|
1130
1151
|
t11.awaitExpression(
|
|
1131
1152
|
t11.callExpression(
|
|
1132
|
-
t11.callExpression(
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1153
|
+
t11.callExpression(
|
|
1154
|
+
getImportIdentifier(ctx, path2, {
|
|
1155
|
+
...HIDDEN_FUNC,
|
|
1156
|
+
source: ctx.options.runtime
|
|
1157
|
+
}),
|
|
1158
|
+
[
|
|
1159
|
+
source,
|
|
1160
|
+
bindings.mutations.length ? t11.arrowFunctionExpression(
|
|
1161
|
+
[returnMutations],
|
|
1162
|
+
t11.assignmentExpression(
|
|
1163
|
+
"=",
|
|
1164
|
+
t11.objectPattern(
|
|
1165
|
+
bindings.mutations.map(
|
|
1166
|
+
(item) => t11.objectProperty(item, item, false, true)
|
|
1167
|
+
)
|
|
1168
|
+
),
|
|
1169
|
+
returnMutations
|
|
1170
|
+
)
|
|
1171
|
+
) : t11.nullLiteral()
|
|
1172
|
+
]
|
|
1173
|
+
),
|
|
1147
1174
|
[t11.arrayExpression(bindings.locals), t11.spreadElement(rest)]
|
|
1148
1175
|
)
|
|
1149
1176
|
)
|
|
@@ -1205,7 +1232,8 @@ function replaceIsomorphicFunction(ctx, path2, func, bindings) {
|
|
|
1205
1232
|
path2.node.async
|
|
1206
1233
|
)
|
|
1207
1234
|
),
|
|
1208
|
-
func.target
|
|
1235
|
+
func.target,
|
|
1236
|
+
func.idPrefix
|
|
1209
1237
|
);
|
|
1210
1238
|
const source = generateUniqueName(path2, "source");
|
|
1211
1239
|
const rest = generateUniqueName(path2, "rest");
|
|
@@ -1260,7 +1288,8 @@ function replaceFunctionFromCall(ctx, path2, func, bindings) {
|
|
|
1260
1288
|
path2.node.async
|
|
1261
1289
|
)
|
|
1262
1290
|
) : void 0,
|
|
1263
|
-
func.target
|
|
1291
|
+
func.target,
|
|
1292
|
+
func.idPrefix
|
|
1264
1293
|
);
|
|
1265
1294
|
return getFunctionReplacement(ctx, path2, entryFile, bindings);
|
|
1266
1295
|
}
|
|
@@ -1281,7 +1310,8 @@ function replaceExpressionFromCall(ctx, path2, func, bindings) {
|
|
|
1281
1310
|
ctx,
|
|
1282
1311
|
path2,
|
|
1283
1312
|
ctx.options.mode === "server" || func.isomorphic ? createRootFile(ctx, bindings, path2.node) : void 0,
|
|
1284
|
-
func.target
|
|
1313
|
+
func.target,
|
|
1314
|
+
func.idPrefix
|
|
1285
1315
|
);
|
|
1286
1316
|
const rest = generateUniqueName(path2, "rest");
|
|
1287
1317
|
const source = generateUniqueName(path2, "source");
|
|
@@ -1467,21 +1497,27 @@ function getFunctionReplacement2(ctx, path2, entryFile, bindings) {
|
|
|
1467
1497
|
t13.variableDeclaration("const", [
|
|
1468
1498
|
t13.variableDeclarator(
|
|
1469
1499
|
funcID,
|
|
1470
|
-
t13.callExpression(
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1500
|
+
t13.callExpression(
|
|
1501
|
+
getImportIdentifier(ctx, path2, {
|
|
1502
|
+
...HIDDEN_GENERATOR,
|
|
1503
|
+
source: ctx.options.runtime
|
|
1504
|
+
}),
|
|
1505
|
+
[
|
|
1506
|
+
source,
|
|
1507
|
+
bindings.mutations.length ? t13.arrowFunctionExpression(
|
|
1508
|
+
[returnMutations],
|
|
1509
|
+
t13.assignmentExpression(
|
|
1510
|
+
"=",
|
|
1511
|
+
t13.objectPattern(
|
|
1512
|
+
bindings.mutations.map(
|
|
1513
|
+
(item) => t13.objectProperty(item, item, false, true)
|
|
1514
|
+
)
|
|
1515
|
+
),
|
|
1516
|
+
returnMutations
|
|
1517
|
+
)
|
|
1518
|
+
) : t13.nullLiteral()
|
|
1519
|
+
]
|
|
1520
|
+
)
|
|
1485
1521
|
)
|
|
1486
1522
|
])
|
|
1487
1523
|
);
|
|
@@ -1507,21 +1543,27 @@ function getFunctionReplacement2(ctx, path2, entryFile, bindings) {
|
|
|
1507
1543
|
t13.arrayPattern([returnType, returnResult]),
|
|
1508
1544
|
t13.awaitExpression(
|
|
1509
1545
|
t13.callExpression(
|
|
1510
|
-
t13.callExpression(
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1546
|
+
t13.callExpression(
|
|
1547
|
+
getImportIdentifier(ctx, path2, {
|
|
1548
|
+
...HIDDEN_FUNC,
|
|
1549
|
+
source: ctx.options.runtime
|
|
1550
|
+
}),
|
|
1551
|
+
[
|
|
1552
|
+
source,
|
|
1553
|
+
bindings.mutations.length ? t13.arrowFunctionExpression(
|
|
1554
|
+
[returnMutations],
|
|
1555
|
+
t13.assignmentExpression(
|
|
1556
|
+
"=",
|
|
1557
|
+
t13.objectPattern(
|
|
1558
|
+
bindings.mutations.map(
|
|
1559
|
+
(item) => t13.objectProperty(item, item, false, true)
|
|
1560
|
+
)
|
|
1561
|
+
),
|
|
1562
|
+
returnMutations
|
|
1563
|
+
)
|
|
1564
|
+
) : t13.nullLiteral()
|
|
1565
|
+
]
|
|
1566
|
+
),
|
|
1525
1567
|
[t13.arrayExpression(bindings.locals), t13.spreadElement(rest)]
|
|
1526
1568
|
)
|
|
1527
1569
|
)
|
|
@@ -1583,7 +1625,8 @@ function replaceIsomorphicFunction2(ctx, path2, directive, bindings) {
|
|
|
1583
1625
|
path2.node.async
|
|
1584
1626
|
)
|
|
1585
1627
|
),
|
|
1586
|
-
directive.target
|
|
1628
|
+
directive.target,
|
|
1629
|
+
directive.idPrefix
|
|
1587
1630
|
);
|
|
1588
1631
|
const source = generateUniqueName(path2, "source");
|
|
1589
1632
|
const rest = generateUniqueName(path2, "rest");
|
|
@@ -1638,7 +1681,8 @@ function replaceFunctionDirective(ctx, path2, directive, bindings) {
|
|
|
1638
1681
|
path2.node.async
|
|
1639
1682
|
)
|
|
1640
1683
|
) : void 0,
|
|
1641
|
-
directive.target
|
|
1684
|
+
directive.target,
|
|
1685
|
+
directive.idPrefix
|
|
1642
1686
|
);
|
|
1643
1687
|
return getFunctionReplacement2(ctx, path2, entryFile, bindings);
|
|
1644
1688
|
}
|