pkgbld 1.9.2 → 1.10.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 +1 -1
- package/dist/helpers.d.ts +1 -1
- package/dist/index.js +35 -21
- package/dist/messages.d.ts +1 -0
- package/dist/types.d.ts +1 -1
- package/package.json +15 -14
package/README.md
CHANGED
|
@@ -63,7 +63,7 @@ Defines what formats to build, only supports `es` and `cjs` at the moment. Use `
|
|
|
63
63
|
pkgbld --preprocess=index
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
-
Defines what entry points/files should be preprocessed using `rollup-plugin-preprocess`. For the entry point will be defined variable
|
|
66
|
+
Defines what entry points/files should be preprocessed using `rollup-plugin-preprocess`. For the entry point will be defined variable es (for esm target), cjs (for commonjs) and umd (for umd) depending on the target type. Please request more variables / more granular logic if you want more.
|
|
67
67
|
|
|
68
68
|
### dir
|
|
69
69
|
|
package/dist/helpers.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare function getHelpers(name: string): {
|
|
|
8
8
|
export declare function umdFilter(config: ReturnType<typeof getCliOptions>, filename: string): boolean;
|
|
9
9
|
export declare function toArray<T>(object: T | T[] | undefined): T[];
|
|
10
10
|
export declare function isExternalInput(id: string, inputs: string | string[], currentInput: string, config: ReturnType<typeof getCliOptions>): boolean;
|
|
11
|
-
export declare function formatInput(input: string[] | string
|
|
11
|
+
export declare function formatInput(input: string[] | string): string;
|
|
12
12
|
export declare function formatOutput(output: OutputOptions | OutputOptions[] | undefined, field: 'dir' | 'format'): string;
|
|
13
13
|
export declare function getTimeDiff(starting: number): string;
|
|
14
14
|
export declare function getDefaultExport<T extends {
|
package/dist/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var rollupPluginTerser = require('rollup-plugin-terser');
|
|
|
15
15
|
var cleanFactory = require('@rollup-extras/plugin-clean');
|
|
16
16
|
var externals = require('@rollup-extras/plugin-externals');
|
|
17
17
|
var camelCase = require('lodash/camelCase');
|
|
18
|
+
var kleur = require('kleur');
|
|
18
19
|
|
|
19
20
|
async function createSubpackages(inputs, config) {
|
|
20
21
|
for (const input of inputs) {
|
|
@@ -107,15 +108,14 @@ function isExternalInput(id, inputs, currentInput, config) {
|
|
|
107
108
|
return normalizedPath !== currentInput && inputs.includes(normalizedPath);
|
|
108
109
|
}
|
|
109
110
|
function formatInput(input) {
|
|
110
|
-
return Array.isArray(input) ? input
|
|
111
|
+
return (Array.isArray(input) ? input : [input !== null && input !== void 0 ? input : '']).map(item => kleur.magenta(path.basename(item, '.ts'))).join(', ');
|
|
111
112
|
}
|
|
112
113
|
function formatOutput(output, field) {
|
|
113
|
-
var _a;
|
|
114
114
|
// can we avoid it?
|
|
115
115
|
if (output == null) {
|
|
116
116
|
return '';
|
|
117
117
|
}
|
|
118
|
-
return Array.isArray(output) ? output
|
|
118
|
+
return (Array.isArray(output) ? output : [output !== null && output !== void 0 ? output : '']).map(item => kleur.cyan(item[field])).join(', ');
|
|
119
119
|
}
|
|
120
120
|
function getTimeDiff(starting) {
|
|
121
121
|
const now = Date.now();
|
|
@@ -128,7 +128,6 @@ function getTimeDiff(starting) {
|
|
|
128
128
|
const clean = cleanFactory();
|
|
129
129
|
function getBuildPlugins(format, config, inputs, currentInput) {
|
|
130
130
|
const result = [
|
|
131
|
-
clean,
|
|
132
131
|
externals({
|
|
133
132
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
134
133
|
external: (id, external) => external || (format === 'umd' ? isExternalInput(id, inputs, currentInput, config) : false)
|
|
@@ -138,19 +137,25 @@ function getBuildPlugins(format, config, inputs, currentInput) {
|
|
|
138
137
|
typescript()
|
|
139
138
|
];
|
|
140
139
|
if (config.preprocess.length) {
|
|
141
|
-
const context = { [format
|
|
140
|
+
const context = { [format]: true };
|
|
142
141
|
result.unshift(preprocess({ include: config.preprocess.map(name => `${config.sourceDir}/${name}.ts`), context }));
|
|
143
142
|
}
|
|
144
143
|
return result;
|
|
145
144
|
}
|
|
146
145
|
function getOutputPlugins(format, config) {
|
|
147
|
-
|
|
146
|
+
const result = [
|
|
147
|
+
clean
|
|
148
|
+
];
|
|
149
|
+
if (config.compressTargets.includes(format)) {
|
|
150
|
+
result.push(rollupPluginTerser.terser({
|
|
148
151
|
mangle: {
|
|
149
152
|
properties: {
|
|
150
153
|
regex: /_$/
|
|
151
154
|
}
|
|
152
155
|
}
|
|
153
|
-
})
|
|
156
|
+
}));
|
|
157
|
+
}
|
|
158
|
+
return result;
|
|
154
159
|
}
|
|
155
160
|
|
|
156
161
|
function getRollupConfigs(inputs, config, helpers) {
|
|
@@ -203,6 +208,8 @@ function getRollupConfigs(inputs, config, helpers) {
|
|
|
203
208
|
return configs;
|
|
204
209
|
}
|
|
205
210
|
|
|
211
|
+
const mainLoggerText = (sourceDir, dir, configsCount, startingTime, finishedCount = 0) => (final = false) => `${sourceDir} → ${dir} ${final ? configsCount : finishedCount++} / ${configsCount}${final ? (' in ' + getTimeDiff(startingTime)) : ''}`;
|
|
212
|
+
|
|
206
213
|
function processPackage(pkg, config) {
|
|
207
214
|
var _a;
|
|
208
215
|
const input = [];
|
|
@@ -273,27 +280,34 @@ async function writePackage(pkgPath, pkg) {
|
|
|
273
280
|
}
|
|
274
281
|
|
|
275
282
|
async function execute() {
|
|
283
|
+
const time = Date.now();
|
|
284
|
+
const blank = logger.createLogger();
|
|
285
|
+
blank.update(' ');
|
|
286
|
+
const mainLogger = logger.createLogger();
|
|
287
|
+
mainLogger.update('preparing...');
|
|
276
288
|
try {
|
|
277
289
|
const [pkgPath, pkg] = await getPackage();
|
|
278
|
-
const
|
|
279
|
-
const inputs = processPackage(pkg,
|
|
290
|
+
const options = getCliOptions();
|
|
291
|
+
const inputs = processPackage(pkg, options);
|
|
280
292
|
const helpers = getHelpers(pkg.name);
|
|
281
|
-
const rollupConfigs = getRollupConfigs(inputs,
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
logger$1.start(`building ${formatInput(config.input)} → ${formatOutput(config.output, 'dir')}, ${formatOutput(config.output, 'format')}`, 1 /* LogLevel.info */);
|
|
286
|
-
const bundle = await rollup.rollup(config);
|
|
287
|
-
await Promise.all(toArray(config.output).map(config => bundle.write(config)));
|
|
288
|
-
await bundle.close();
|
|
289
|
-
logger$1.finish(`finished ${formatInput(config.input)} → ${formatOutput(config.output, 'dir')}, ${formatOutput(config.output, 'format')} in ${getTimeDiff(time)}`, 1 /* LogLevel.info */);
|
|
290
|
-
}
|
|
293
|
+
const rollupConfigs = getRollupConfigs(inputs, options, helpers);
|
|
294
|
+
const updater = mainLoggerText(options.sourceDir, options.dir, rollupConfigs.length, time);
|
|
295
|
+
mainLogger.start(updater());
|
|
296
|
+
await Promise.all(rollupConfigs.map(config => buildConfig(config, updater)));
|
|
291
297
|
await writePackage(pkgPath, pkg);
|
|
292
|
-
await createSubpackages(inputs,
|
|
298
|
+
await createSubpackages(inputs, options);
|
|
299
|
+
mainLogger.finish(updater(true));
|
|
293
300
|
}
|
|
294
301
|
catch (e) {
|
|
295
|
-
|
|
302
|
+
mainLogger.finish(`${e}}`, 3 /* LogLevel.error */);
|
|
296
303
|
process.exit(-1);
|
|
297
304
|
}
|
|
305
|
+
async function buildConfig(config, updater) {
|
|
306
|
+
const bundle = await rollup.rollup(config);
|
|
307
|
+
await Promise.all(toArray(config.output).map(config => bundle.write(config)));
|
|
308
|
+
await bundle.close();
|
|
309
|
+
mainLogger(`${kleur.green('✓')} ${formatInput(config.input)} [${formatOutput(config.output, 'format')}]`);
|
|
310
|
+
mainLogger.update(updater());
|
|
311
|
+
}
|
|
298
312
|
}
|
|
299
313
|
execute();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const mainLoggerText: (sourceDir: string, dir: string, configsCount: number, startingTime: number, finishedCount?: number) => (final?: boolean) => string;
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.10.1",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "pkgbld",
|
|
5
5
|
"author": {
|
|
@@ -39,32 +39,33 @@
|
|
|
39
39
|
"@semantic-release/git": "10.0.1",
|
|
40
40
|
"@semantic-release/npm": "9.0.1",
|
|
41
41
|
"@semantic-release/release-notes-generator": "10.0.3",
|
|
42
|
-
"@types/lodash": "4.14.
|
|
43
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
44
|
-
"@typescript-eslint/parser": "5.
|
|
42
|
+
"@types/lodash": "4.14.190",
|
|
43
|
+
"@typescript-eslint/eslint-plugin": "5.44.0",
|
|
44
|
+
"@typescript-eslint/parser": "5.44.0",
|
|
45
45
|
"conventional-changelog-angular": "5.0.13",
|
|
46
|
-
"eslint": "8.
|
|
46
|
+
"eslint": "8.28.0",
|
|
47
47
|
"semantic-release": "19.0.5",
|
|
48
|
-
"@rollup-extras/plugin-binify": "1.1.
|
|
48
|
+
"@rollup-extras/plugin-binify": "1.1.4"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@niceties/logger": "1.1.
|
|
52
|
-
"@niceties/draftlog-appender": "1.
|
|
51
|
+
"@niceties/logger": "1.1.10",
|
|
52
|
+
"@niceties/draftlog-appender": "1.3.0",
|
|
53
53
|
"lodash": "4.17.21",
|
|
54
|
-
"rollup": "3.
|
|
54
|
+
"rollup": "3.4.0",
|
|
55
55
|
"rollup-plugin-terser": "7.0.2",
|
|
56
56
|
"rollup-plugin-typescript2": "0.34.1",
|
|
57
57
|
"rollup-plugin-preprocess": "0.0.4",
|
|
58
58
|
"@rollup/plugin-commonjs": "23.0.2",
|
|
59
59
|
"@rollup/plugin-node-resolve": "15.0.1",
|
|
60
|
-
"@rollup-extras/plugin-clean": "1.3.
|
|
61
|
-
"@rollup-extras/plugin-externals": "1.1.
|
|
62
|
-
"typescript": "4.
|
|
63
|
-
"minimist": "1.2.7"
|
|
60
|
+
"@rollup-extras/plugin-clean": "1.3.3",
|
|
61
|
+
"@rollup-extras/plugin-externals": "1.1.4",
|
|
62
|
+
"typescript": "4.9.3",
|
|
63
|
+
"minimist": "1.2.7",
|
|
64
|
+
"kleur": "4.1.5"
|
|
64
65
|
},
|
|
65
66
|
"overrides": {
|
|
66
67
|
"rollup-plugin-terser@7.0.2": {
|
|
67
|
-
"rollup": "3.
|
|
68
|
+
"rollup": "3.4.0"
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
71
|
}
|