rollup-plugin-iife-split 0.0.6 → 0.0.7
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 +94 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -276,7 +276,7 @@ function renameIdentifiers(code, renameMap, parse) {
|
|
|
276
276
|
const ast = parse(code);
|
|
277
277
|
const s = new MagicString2(code);
|
|
278
278
|
walk2(ast, {
|
|
279
|
-
enter(node) {
|
|
279
|
+
enter(node, parent) {
|
|
280
280
|
if (node.type === "ImportSpecifier") {
|
|
281
281
|
const spec = node;
|
|
282
282
|
const newName = renameMap.get(spec.local.name);
|
|
@@ -305,10 +305,43 @@ function renameIdentifiers(code, renameMap, parse) {
|
|
|
305
305
|
this.skip();
|
|
306
306
|
return;
|
|
307
307
|
}
|
|
308
|
+
if (node.type === "Property") {
|
|
309
|
+
const prop = node;
|
|
310
|
+
if (prop.shorthand && prop.key.type === "Identifier") {
|
|
311
|
+
const newName = renameMap.get(prop.key.name);
|
|
312
|
+
if (newName) {
|
|
313
|
+
s.overwrite(prop.start, prop.end, `${prop.key.name}: ${newName}`);
|
|
314
|
+
this.skip();
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if (!prop.computed && prop.key.type === "Identifier") {
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
308
323
|
if (node.type === "Identifier") {
|
|
309
324
|
const id = node;
|
|
310
325
|
const newName = renameMap.get(id.name);
|
|
311
326
|
if (newName) {
|
|
327
|
+
if (parent?.type === "Property") {
|
|
328
|
+
const prop = parent;
|
|
329
|
+
if (prop.key === node && !prop.computed && !prop.shorthand) {
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
if (parent?.type === "MemberExpression") {
|
|
334
|
+
const member = parent;
|
|
335
|
+
if (member.property === node && !member.computed) {
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
if (parent?.type === "MethodDefinition") {
|
|
340
|
+
const method = parent;
|
|
341
|
+
if (method.key === node && !method.computed) {
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
312
345
|
s.overwrite(id.start, id.end, newName);
|
|
313
346
|
}
|
|
314
347
|
}
|
|
@@ -526,7 +559,7 @@ function removeSharedImportsAndRewriteRefs(code, sharedChunkFileName, sharedExpo
|
|
|
526
559
|
}
|
|
527
560
|
});
|
|
528
561
|
walk2(ast, {
|
|
529
|
-
enter(node) {
|
|
562
|
+
enter(node, parent) {
|
|
530
563
|
if (node.type === "ImportDeclaration") {
|
|
531
564
|
const importNode = node;
|
|
532
565
|
const source = importNode.source.value;
|
|
@@ -565,10 +598,39 @@ function removeSharedImportsAndRewriteRefs(code, sharedChunkFileName, sharedExpo
|
|
|
565
598
|
this.skip();
|
|
566
599
|
}
|
|
567
600
|
}
|
|
601
|
+
if (node.type === "Property") {
|
|
602
|
+
const prop = node;
|
|
603
|
+
if (prop.shorthand && prop.key.type === "Identifier") {
|
|
604
|
+
const newName = namedImportRenames.get(prop.key.name);
|
|
605
|
+
if (newName) {
|
|
606
|
+
s.overwrite(prop.start, prop.end, `${prop.key.name}: ${newName}`);
|
|
607
|
+
this.skip();
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
}
|
|
568
612
|
if (node.type === "Identifier" && namedImportRenames.size > 0) {
|
|
569
613
|
const id = node;
|
|
570
614
|
const newName = namedImportRenames.get(id.name);
|
|
571
615
|
if (newName) {
|
|
616
|
+
if (parent?.type === "Property") {
|
|
617
|
+
const prop = parent;
|
|
618
|
+
if (prop.key === node && !prop.computed && !prop.shorthand) {
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
if (parent?.type === "MemberExpression") {
|
|
623
|
+
const member = parent;
|
|
624
|
+
if (member.property === node && !member.computed) {
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
if (parent?.type === "MethodDefinition") {
|
|
629
|
+
const method = parent;
|
|
630
|
+
if (method.key === node && !method.computed) {
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
572
634
|
s.overwrite(id.start, id.end, newName);
|
|
573
635
|
}
|
|
574
636
|
}
|
|
@@ -637,7 +699,7 @@ function removeChunkImportsAndRewriteRefs(code, chunkFileName, exportToLocal, pa
|
|
|
637
699
|
}
|
|
638
700
|
});
|
|
639
701
|
walk2(ast, {
|
|
640
|
-
enter(node) {
|
|
702
|
+
enter(node, parent) {
|
|
641
703
|
if (node.type === "ImportDeclaration") {
|
|
642
704
|
const importNode = node;
|
|
643
705
|
const source = importNode.source.value;
|
|
@@ -653,10 +715,39 @@ function removeChunkImportsAndRewriteRefs(code, chunkFileName, exportToLocal, pa
|
|
|
653
715
|
s.overwrite(memberNode.start, memberNode.end, localName);
|
|
654
716
|
}
|
|
655
717
|
}
|
|
718
|
+
if (node.type === "Property") {
|
|
719
|
+
const prop = node;
|
|
720
|
+
if (prop.shorthand && prop.key.type === "Identifier") {
|
|
721
|
+
const newName = namedImportRenames.get(prop.key.name);
|
|
722
|
+
if (newName) {
|
|
723
|
+
s.overwrite(prop.start, prop.end, `${prop.key.name}: ${newName}`);
|
|
724
|
+
this.skip();
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
}
|
|
656
729
|
if (node.type === "Identifier" && namedImportRenames.size > 0) {
|
|
657
730
|
const id = node;
|
|
658
731
|
const newName = namedImportRenames.get(id.name);
|
|
659
732
|
if (newName) {
|
|
733
|
+
if (parent?.type === "Property") {
|
|
734
|
+
const prop = parent;
|
|
735
|
+
if (prop.key === node && !prop.computed && !prop.shorthand) {
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
if (parent?.type === "MemberExpression") {
|
|
740
|
+
const member = parent;
|
|
741
|
+
if (member.property === node && !member.computed) {
|
|
742
|
+
return;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
if (parent?.type === "MethodDefinition") {
|
|
746
|
+
const method = parent;
|
|
747
|
+
if (method.key === node && !method.computed) {
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
660
751
|
s.overwrite(id.start, id.end, newName);
|
|
661
752
|
}
|
|
662
753
|
}
|