pkgbld 1.32.2 → 1.33.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/README.md +10 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +20 -6
- package/package.json +1 -1
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 --
|
|
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 --
|
|
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
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.
|
|
952
|
+
var version = "1.33.1";
|
|
939
953
|
var name = "pkgbld";
|
|
940
954
|
var license = "MIT";
|
|
941
955
|
var author = "Konstantin Shutkin";
|
|
@@ -1209,7 +1223,7 @@ async function prunePkg(pkg, options, logger) {
|
|
|
1209
1223
|
await flatten(pkg, options.flatten, logger);
|
|
1210
1224
|
}
|
|
1211
1225
|
if (options.removeSourcemaps) {
|
|
1212
|
-
const sourceMaps = await walkDir('.').then(files => files.filter(file => file.endsWith('.map')));
|
|
1226
|
+
const sourceMaps = await walkDir('.', ['node_modules']).then(files => files.filter(file => file.endsWith('.map')));
|
|
1213
1227
|
for (const sourceMap of sourceMaps) {
|
|
1214
1228
|
// find corresponding file
|
|
1215
1229
|
const sourceFile = sourceMap.slice(0, -4);
|
|
@@ -1475,12 +1489,12 @@ async function isDirectory(file) {
|
|
|
1475
1489
|
const fileStat = await stat(file);
|
|
1476
1490
|
return fileStat.isDirectory();
|
|
1477
1491
|
}
|
|
1478
|
-
async function walkDir(dir) {
|
|
1492
|
+
async function walkDir(dir, ignoreDirs = []) {
|
|
1479
1493
|
const entries = await readdir(dir, { withFileTypes: true });
|
|
1480
1494
|
const files = [];
|
|
1481
1495
|
await Promise.all(entries.map(entry => {
|
|
1482
1496
|
const childPath = path.join(dir, entry.name);
|
|
1483
|
-
if (entry.isDirectory()) {
|
|
1497
|
+
if (entry.isDirectory() && !ignoreDirs.includes(entry.name)) {
|
|
1484
1498
|
return walkDir(childPath)
|
|
1485
1499
|
.then(childFiles => {
|
|
1486
1500
|
files.push(...childFiles);
|
package/package.json
CHANGED