pkgbld 1.32.1 → 1.33.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/README.md CHANGED
@@ -227,7 +227,7 @@ If files cannot be copied because of name conflicts the command will fail.
227
227
  ### removeSourcemaps
228
228
 
229
229
  ```
230
- pkgbld prune --removeSourcemaps
230
+ pkgbld prune --remove-sourcemaps
231
231
  ```
232
232
 
233
233
  Removes all sourcemaps from the package. The logic is very simple and removes all files with `.map` extension and references in format `//# sourceMappingURL=<mapFile>`.
@@ -235,13 +235,21 @@ Removes all sourcemaps from the package. The logic is very simple and removes al
235
235
  ### optimizeFiles (default)
236
236
 
237
237
  ```
238
- pkgbld prune --optimizeFiles=false
238
+ pkgbld prune --optimize-files=false
239
239
  ```
240
240
 
241
241
  Optimizes files by removing all files that are not required for pack at the given moment.
242
242
 
243
243
  You might want to disable this option in some edge cases.
244
244
 
245
+ ### removeLegalComments
246
+
247
+ ```
248
+ pkgbld prune --remove-legal-comments --compress=es,cjs
249
+ ```
250
+
251
+ Removes all legal comments from the package. Only works with compress.
252
+
245
253
  ## Plugin API
246
254
 
247
255
  `pkgbld` reads all installed packages named `pkgbld-plugin-*` and assumes they are plugins
package/dist/index.d.ts CHANGED
@@ -26,6 +26,7 @@ declare function getCliOptions(plugins: Partial<PkgbldPlugin>[], pkg: PackageJso
26
26
  noExports: boolean;
27
27
  noClean: boolean;
28
28
  noBundle: boolean;
29
+ removeLegalComments: boolean;
29
30
  } | {
30
31
  readonly kind: "prune";
31
32
  readonly profile: string;
package/dist/index.mjs CHANGED
@@ -158,6 +158,11 @@ const cliFlags = {
158
158
  description: 'Do not bundle',
159
159
  default: false
160
160
  },
161
+ removeLegalComments: {
162
+ type: Boolean,
163
+ description: 'Remove legal comments',
164
+ default: false
165
+ }
161
166
  };
162
167
  const packageJsonFieldsOrder = new Set([
163
168
  'private',
@@ -301,7 +306,8 @@ function getCliOptions(plugins, pkg) {
301
306
  noPack: flags.noPack,
302
307
  noExports: flags.noExports,
303
308
  noClean: flags.noClean,
304
- noBundle: flags.noBundle
309
+ noBundle: flags.noBundle,
310
+ removeLegalComments: flags.removeLegalComments
305
311
  };
306
312
  for (const plugin of plugins) {
307
313
  plugin.options?.(flags, options);
@@ -434,6 +440,11 @@ async function terser (provider, config, inputs, inputsExt) {
434
440
  }
435
441
  }
436
442
  };
443
+ if (config.removeLegalComments) {
444
+ options.output = {
445
+ comments: false,
446
+ };
447
+ }
437
448
  if (filteredFormats.length > 0) {
438
449
  for (const format of filteredFormats) {
439
450
  if (format !== 'umd') {
@@ -653,6 +664,9 @@ async function getRollupConfigs([provider, plugins$1], inputs, inputsExt, config
653
664
  entryFileNames: fileNamePatterns[format],
654
665
  plugins: getPlugins([format], inputs, true),
655
666
  sourcemap: config.sourcemapFormats.includes(format),
667
+ // this requires more work
668
+ // preserveModules: true,
669
+ // preserveModulesRoot: config.sourceDir,
656
670
  ...getExtraOutputSettings(format, inputs)
657
671
  })),
658
672
  plugins: getPlugins(formats, inputs, false)
@@ -824,7 +838,7 @@ async function processPackage(pkg, config, plugins, tsConfig) {
824
838
  for (const id in pkg.exports) {
825
839
  if (id === './package.json')
826
840
  continue;
827
- const basename = id == '.' ? indexId : path.basename(id);
841
+ const basename = id == '.' ? indexId : path.join(path.dirname(id), path.basename(id));
828
842
  if (typeof pkg.exports[id] !== 'object') {
829
843
  pkg.exports[id] = {};
830
844
  }
@@ -935,7 +949,7 @@ async function writeJson(path, json) {
935
949
  await fs.writeFile(path, toFormattedJson(json));
936
950
  }
937
951
 
938
- var version = "1.32.1";
952
+ var version = "1.33.0";
939
953
  var name = "pkgbld";
940
954
  var license = "MIT";
941
955
  var author = "Konstantin Shutkin";
@@ -1216,7 +1230,7 @@ async function prunePkg(pkg, options, logger) {
1216
1230
  // load file
1217
1231
  const sourceFileContent = await readFile(sourceFile, 'utf8');
1218
1232
  // find sourceMappingURL
1219
- const sourceMappingUrl = `//# sourceMappingURL=${path.basename(sourceMap)}`;
1233
+ const sourceMappingUrl = `\n//# sourceMappingURL=${path.basename(sourceMap)}`;
1220
1234
  // remove sourceMappingURL
1221
1235
  const newContent = sourceFileContent.replace(sourceMappingUrl, '');
1222
1236
  // write file
@@ -1598,4 +1612,3 @@ function preimport() {
1598
1612
  ['@rollup-extras/plugin-externals', import('@rollup-extras/plugin-externals')]
1599
1613
  ]) : new Map);
1600
1614
  }
1601
-
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.32.1",
2
+ "version": "1.33.0",
3
3
  "name": "pkgbld",
4
4
  "license": "MIT",
5
5
  "author": "Konstantin Shutkin",