pkgprn-internal 0.5.3 → 0.5.5

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.
Files changed (2) hide show
  1. package/dist/index.mjs +14 -7
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -694,8 +694,12 @@ async function prunePkg(pkg, options, logger) {
694
694
  logger('cleanup is disabled, junk files may cause flatten to fail', 2);
695
695
  }
696
696
 
697
+ if (pkg.files && Array.isArray(pkg.files) && pkg.files.length > 0 && options.cleanupFiles) {
698
+ await cleanupDir(pkg, logger);
699
+ }
700
+
697
701
  if (options.flatten) {
698
- await flatten(pkg, options.flatten, logger);
702
+ await flatten(pkg, options.flatten, logger, options.removeSourcemaps);
699
703
  }
700
704
 
701
705
  if (options.removeSourcemaps) {
@@ -714,6 +718,11 @@ async function prunePkg(pkg, options, logger) {
714
718
 
715
719
  await rm(sourceMap);
716
720
  }
721
+
722
+ if (pkg.files && sourceMaps.length > 0) {
723
+ const removedMaps = new Set(sourceMaps.map(f => normalizePath(path.relative('.', f))));
724
+ pkg.files = pkg.files.filter(f => !removedMaps.has(normalizePath(f)));
725
+ }
717
726
  }
718
727
 
719
728
  if (options.stripComments) {
@@ -846,12 +855,12 @@ async function prunePkg(pkg, options, logger) {
846
855
  }
847
856
  }
848
857
 
849
- if (pkg.files && Array.isArray(pkg.files) && options.cleanupFiles) {
850
- await cleanupDir(pkg, logger);
858
+ if (options.cleanupFiles) {
859
+ pkg.files = undefined;
851
860
  }
852
861
  }
853
862
 
854
- async function flatten(pkg, flatten, logger) {
863
+ async function flatten(pkg, flatten, logger, skipSourcemapAdjust) {
855
864
 
856
865
  const allReferences = extractReferences(pkg);
857
866
 
@@ -977,7 +986,7 @@ async function flatten(pkg, flatten, logger) {
977
986
 
978
987
  await Promise.all(renamePromises);
979
988
 
980
- if (typeof flatten === 'string') {
989
+ if (typeof flatten === 'string' && !skipSourcemapAdjust) {
981
990
 
982
991
  const oldToNew = new Map();
983
992
  for (const [newPath, oldPath] of movedFiles) {
@@ -1258,8 +1267,6 @@ async function cleanupDir(pkg, logger) {
1258
1267
 
1259
1268
  await rm(entry, { recursive: true, force: true });
1260
1269
  }
1261
-
1262
- pkg.files = undefined;
1263
1270
  }
1264
1271
 
1265
1272
  async function cleanupSubDir(dir, filesEntries, alwaysIncludedFiles) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.5.3",
2
+ "version": "0.5.5",
3
3
  "name": "pkgprn-internal",
4
4
  "description": "Special version of pkgprn to install it in MY workspace-enabled repositories to build in-house packages",
5
5
  "license": "MIT",