pkgbld 1.17.1 → 1.18.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 +24 -0
- package/dist/index.js +41 -17
- package/dist/src/get-cli-options.d.ts +3 -0
- package/dist/src/get-rollup-configs.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -140,6 +140,30 @@ pkgbld --no-update-package-json
|
|
|
140
140
|
|
|
141
141
|
Do not write package.json.
|
|
142
142
|
|
|
143
|
+
### commonjs-pattern
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
pkgbld --commonjs-pattern=[name].js
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Defines the pattern for commonjs output files. Default is `[name].cjs`.
|
|
150
|
+
|
|
151
|
+
### esm-pattern
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
pkgbld --esm-pattern=[name].js
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Defines the pattern for esm output files. Default is `[name].mjs`.
|
|
158
|
+
|
|
159
|
+
### umd-pattern
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
pkgbld --umd-pattern=[name].js
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Defines the pattern for umd output files. Default is `[name].umd.js`.
|
|
166
|
+
|
|
143
167
|
## Plugin API
|
|
144
168
|
|
|
145
169
|
`pkgbld` reads all installed packages named `pkgbld-plugin-*` and assumes they are plugins
|
package/dist/index.js
CHANGED
|
@@ -41,7 +41,10 @@ const defaults = {
|
|
|
41
41
|
includeExternals: false,
|
|
42
42
|
eject: false,
|
|
43
43
|
noTsConfig: false,
|
|
44
|
-
noUpdatePackageJson: false
|
|
44
|
+
noUpdatePackageJson: false,
|
|
45
|
+
commonjsPattern: '[name].cjs',
|
|
46
|
+
esPattern: '[name].mjs',
|
|
47
|
+
umdPattern: '[name].umd.js'
|
|
45
48
|
};
|
|
46
49
|
function CommaSeparatedString(value) {
|
|
47
50
|
return value.split(',').map((arg) => arg.trim());
|
|
@@ -109,6 +112,21 @@ function getCliOptions(plugins, pkg) {
|
|
|
109
112
|
type: Boolean,
|
|
110
113
|
description: 'Do not create / update package.json',
|
|
111
114
|
default: defaults.noUpdatePackageJson
|
|
115
|
+
},
|
|
116
|
+
commonjsPattern: {
|
|
117
|
+
type: String,
|
|
118
|
+
description: 'CommonJS output file name pattern',
|
|
119
|
+
default: defaults.commonjsPattern
|
|
120
|
+
},
|
|
121
|
+
esmPattern: {
|
|
122
|
+
type: String,
|
|
123
|
+
description: 'ES output file name pattern',
|
|
124
|
+
default: defaults.esPattern
|
|
125
|
+
},
|
|
126
|
+
umdPattern: {
|
|
127
|
+
type: String,
|
|
128
|
+
description: 'UMD output file name pattern',
|
|
129
|
+
default: defaults.umdPattern
|
|
112
130
|
}
|
|
113
131
|
}
|
|
114
132
|
});
|
|
@@ -126,7 +144,10 @@ function getCliOptions(plugins, pkg) {
|
|
|
126
144
|
includeExternals: flags.includeExternals,
|
|
127
145
|
eject: flags.eject,
|
|
128
146
|
noTsConfig: flags.noTsConfig,
|
|
129
|
-
noUpdatePackageJson: flags.noUpdatePackageJson
|
|
147
|
+
noUpdatePackageJson: flags.noUpdatePackageJson,
|
|
148
|
+
commonjsPattern: flags.commonjsPattern,
|
|
149
|
+
esPattern: flags.esmPattern,
|
|
150
|
+
umdPattern: flags.umdPattern
|
|
130
151
|
};
|
|
131
152
|
for (const plugin of plugins) {
|
|
132
153
|
plugin.options?.(flags, options);
|
|
@@ -329,13 +350,13 @@ function getTimeDiff(starting) {
|
|
|
329
350
|
}
|
|
330
351
|
const areSetsEqual = (a, b) => a.size === b.size ? [...a].every(value => b.has(value)) : false;
|
|
331
352
|
|
|
332
|
-
const fileNamePatterns = {
|
|
333
|
-
'es': '[name].mjs',
|
|
334
|
-
'cjs': '[name].cjs',
|
|
335
|
-
'umd': '[name].umd.js',
|
|
336
|
-
};
|
|
337
353
|
async function getRollupConfigs([provider, plugins$1], inputs, config, helpers, externalPlugins) {
|
|
338
354
|
const factoryInProgress = [];
|
|
355
|
+
const fileNamePatterns = {
|
|
356
|
+
'es': config.esPattern,
|
|
357
|
+
'cjs': config.commonjsPattern,
|
|
358
|
+
'umd': config.umdPattern
|
|
359
|
+
};
|
|
339
360
|
for (const factory of plugins) {
|
|
340
361
|
factoryInProgress.push(factory(provider, config, inputs));
|
|
341
362
|
}
|
|
@@ -537,7 +558,7 @@ function processPackage(pkg, config, plugins) {
|
|
|
537
558
|
}
|
|
538
559
|
pkg.types = `./${config.dir}/index.d.ts`;
|
|
539
560
|
if (allowUmd && typeof pkg.umd === 'string') {
|
|
540
|
-
pkg.umd = `./${config.dir}
|
|
561
|
+
pkg.umd = `./${config.dir}/${patternToName(config.umdPattern, 'index')}`;
|
|
541
562
|
if (!config.umdInputs.includes('index')) {
|
|
542
563
|
config.umdInputs.push('index');
|
|
543
564
|
}
|
|
@@ -562,23 +583,23 @@ function processPackage(pkg, config, plugins) {
|
|
|
562
583
|
else {
|
|
563
584
|
delete pkg.bin;
|
|
564
585
|
}
|
|
565
|
-
if (allowCjs
|
|
566
|
-
pkg.main = `./${config.dir}
|
|
586
|
+
if (allowCjs) {
|
|
587
|
+
pkg.main = `./${config.dir}/${patternToName(config.commonjsPattern, 'index')}`;
|
|
567
588
|
}
|
|
568
|
-
if (allowEsm && !allowCjs
|
|
569
|
-
pkg.main = `./${config.dir}
|
|
589
|
+
if (allowEsm && !allowCjs) {
|
|
590
|
+
pkg.main = `./${config.dir}/${patternToName(config.esPattern, 'index')}`;
|
|
570
591
|
}
|
|
571
592
|
if (allowCjs && pkg.main !== pkg.exports['.'].require) {
|
|
572
593
|
pkg.exports['.'].require = pkg.main;
|
|
573
594
|
}
|
|
574
595
|
if (allowCjs && allowEsm && typeof pkg.module !== 'string') {
|
|
575
|
-
pkg.module = `./${config.dir}
|
|
596
|
+
pkg.module = `./${config.dir}/${patternToName(config.esPattern, 'index')}`;
|
|
576
597
|
}
|
|
577
598
|
if (pkg.module !== pkg.exports['.']?.default) {
|
|
578
599
|
pkg.exports['.'].default = pkg.module;
|
|
579
600
|
}
|
|
580
601
|
if (allowUmd && config.umdInputs.includes('index')) {
|
|
581
|
-
pkg.unpkg = `./${config.dir}
|
|
602
|
+
pkg.unpkg = `./${config.dir}/${patternToName(config.umdPattern, 'index')}`;
|
|
582
603
|
}
|
|
583
604
|
for (const id in pkg.exports) {
|
|
584
605
|
if (id === './package.json')
|
|
@@ -588,10 +609,10 @@ function processPackage(pkg, config, plugins) {
|
|
|
588
609
|
pkg.exports[id] = {};
|
|
589
610
|
}
|
|
590
611
|
if (allowCjs) {
|
|
591
|
-
pkg.exports[id].require = `./${config.dir}/${basename}
|
|
612
|
+
pkg.exports[id].require = `./${config.dir}/${patternToName(config.commonjsPattern, basename)}`;
|
|
592
613
|
}
|
|
593
614
|
if (allowEsm) {
|
|
594
|
-
pkg.exports[id].default = `./${config.dir}/${basename}
|
|
615
|
+
pkg.exports[id].default = `./${config.dir}/${patternToName(config.esPattern, basename)}`;
|
|
595
616
|
}
|
|
596
617
|
if (basename !== 'index') {
|
|
597
618
|
if (!pkg.files.includes(basename)) {
|
|
@@ -608,12 +629,15 @@ function processPackage(pkg, config, plugins) {
|
|
|
608
629
|
}
|
|
609
630
|
return inputs;
|
|
610
631
|
}
|
|
632
|
+
function patternToName(pattern, input) {
|
|
633
|
+
return pattern.replace('[name]', input);
|
|
634
|
+
}
|
|
611
635
|
|
|
612
636
|
async function writeJson(path, json) {
|
|
613
637
|
await fs.writeFile(path, JSON.stringify(json, null, 2) + '\n');
|
|
614
638
|
}
|
|
615
639
|
|
|
616
|
-
var version = "1.
|
|
640
|
+
var version = "1.18.0";
|
|
617
641
|
var name = "pkgbld";
|
|
618
642
|
var license = "MIT";
|
|
619
643
|
var author = "Konstantin Shutkin";
|
|
@@ -21,7 +21,7 @@ export declare function getRollupConfigs([provider, plugins]: [Provider, PkgbldR
|
|
|
21
21
|
externalLiveBindings?: boolean | undefined;
|
|
22
22
|
file?: string | undefined;
|
|
23
23
|
footer?: string | import("rollup").AddonFunction | undefined;
|
|
24
|
-
format: "
|
|
24
|
+
format: "umd" | "es" | "cjs" | "amd" | "iife" | "system" | "commonjs" | "esm" | "module" | "systemjs";
|
|
25
25
|
freeze?: boolean | undefined;
|
|
26
26
|
generatedCode?: import("rollup").GeneratedCodePreset | import("rollup").GeneratedCodeOptions | undefined;
|
|
27
27
|
globals?: import("rollup").GlobalsOption | undefined;
|
package/package.json
CHANGED