pkgbld 1.29.1 → 1.29.3
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/LICENSE +1 -1
- package/dist/index.d.ts +94 -0
- package/dist/index.d.ts.map +26 -0
- package/dist/index.mjs +43 -22
- package/package.json +2 -1
package/LICENSE
CHANGED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/// <reference types="@niceties/draftlog-appender" />
|
|
2
|
+
|
|
3
|
+
declare module 'pkgbld' {
|
|
4
|
+
import type { Plugin, InternalModuleFormat, OutputOptions } from 'rollup';
|
|
5
|
+
import type { Logger } from '@niceties/logger';
|
|
6
|
+
export type Json = null | string | number | boolean | Json[] | {
|
|
7
|
+
[name: string]: Json;
|
|
8
|
+
};
|
|
9
|
+
export type ProvideFunction = (factory: () => Plugin, priority: number, options?: {
|
|
10
|
+
format?: InternalModuleFormat | InternalModuleFormat[];
|
|
11
|
+
inputs?: string[];
|
|
12
|
+
outputPlugin?: true;
|
|
13
|
+
}) => void;
|
|
14
|
+
export type Provider = {
|
|
15
|
+
provide: ProvideFunction;
|
|
16
|
+
import: (module: string, exportName?: string) => Promise<((...args: unknown[]) => Plugin)>;
|
|
17
|
+
globalImport: (module: string, exportName?: string | string[]) => void;
|
|
18
|
+
globalSetup: (code: Function | string) => void;
|
|
19
|
+
};
|
|
20
|
+
export type PkgbldRollupPlugin = {
|
|
21
|
+
plugin: () => Plugin;
|
|
22
|
+
priority: number;
|
|
23
|
+
format?: InternalModuleFormat | InternalModuleFormat[];
|
|
24
|
+
inputs?: string[];
|
|
25
|
+
outputPlugin?: true;
|
|
26
|
+
};
|
|
27
|
+
export type CliOptions = NonNullable<Extract<ReturnType<typeof getCliOptions>, {
|
|
28
|
+
kind: 'build';
|
|
29
|
+
}>>;
|
|
30
|
+
export type ParsedOptions = Record<string, string | number | string[] | number[] | boolean | undefined>;
|
|
31
|
+
export interface PkgbldPlugin {
|
|
32
|
+
options(parsedArgs: ParsedOptions, options: CliOptions): void;
|
|
33
|
+
processPackageJson(packageJson: PackageJson, inputs: string[], logger: Logger): void;
|
|
34
|
+
processTsConfig(config: Json): void;
|
|
35
|
+
providePlugins(provider: Provider, config: ParsedOptions, inputs: string[], inputsExt: Map<string, string>): Promise<void>;
|
|
36
|
+
getExtraOutputSettings(format: InternalModuleFormat, inputs: string[]): Partial<OutputOptions>;
|
|
37
|
+
buildEnd(): Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
export type PackageJson = {
|
|
40
|
+
private?: boolean;
|
|
41
|
+
version?: string;
|
|
42
|
+
name?: string;
|
|
43
|
+
license?: string;
|
|
44
|
+
readme?: string;
|
|
45
|
+
author?: string | {
|
|
46
|
+
name?: string;
|
|
47
|
+
email?: string;
|
|
48
|
+
url?: string;
|
|
49
|
+
};
|
|
50
|
+
description?: string;
|
|
51
|
+
scripts?: {
|
|
52
|
+
[key: string]: string;
|
|
53
|
+
};
|
|
54
|
+
repository?: {
|
|
55
|
+
type?: string;
|
|
56
|
+
url?: string;
|
|
57
|
+
};
|
|
58
|
+
files?: string[];
|
|
59
|
+
bugs?: string;
|
|
60
|
+
homepage?: string;
|
|
61
|
+
dependencies?: Record<string, string>;
|
|
62
|
+
devDependencies?: Record<string, string>;
|
|
63
|
+
peerDependencies?: Record<string, string>;
|
|
64
|
+
exports?: Record<string, string | Record<string, string>>;
|
|
65
|
+
};
|
|
66
|
+
function getCliOptions(plugins: Partial<PkgbldPlugin>[], pkg: PackageJson): {
|
|
67
|
+
kind: 'build';
|
|
68
|
+
umdInputs: string[];
|
|
69
|
+
compressFormats: string[];
|
|
70
|
+
sourcemapFormats: string[];
|
|
71
|
+
formats: string[];
|
|
72
|
+
formatsOverridden: boolean;
|
|
73
|
+
preprocess: string[];
|
|
74
|
+
dir: string;
|
|
75
|
+
sourceDir: string;
|
|
76
|
+
bin?: string[] | undefined;
|
|
77
|
+
includeExternals: boolean | string[];
|
|
78
|
+
eject: boolean;
|
|
79
|
+
noTsConfig: boolean;
|
|
80
|
+
noUpdatePackageJson: boolean;
|
|
81
|
+
commonjsPattern: string;
|
|
82
|
+
esPattern: string;
|
|
83
|
+
umdPattern: string;
|
|
84
|
+
formatPackageJson: boolean;
|
|
85
|
+
noPack: boolean;
|
|
86
|
+
noExports: boolean;
|
|
87
|
+
} | {
|
|
88
|
+
readonly kind: "prune";
|
|
89
|
+
readonly profile: string;
|
|
90
|
+
readonly flatten: string | boolean;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"file": "index.d.ts",
|
|
4
|
+
"names": [
|
|
5
|
+
"Json",
|
|
6
|
+
"ProvideFunction",
|
|
7
|
+
"Provider",
|
|
8
|
+
"PkgbldRollupPlugin",
|
|
9
|
+
"CliOptions",
|
|
10
|
+
"ParsedOptions",
|
|
11
|
+
"PkgbldPlugin",
|
|
12
|
+
"PackageJson",
|
|
13
|
+
"getCliOptions"
|
|
14
|
+
],
|
|
15
|
+
"sources": [
|
|
16
|
+
"src/types.d.ts",
|
|
17
|
+
"src/options-types.d.ts",
|
|
18
|
+
"src/get-cli-options.d.ts"
|
|
19
|
+
],
|
|
20
|
+
"sourcesContent": [
|
|
21
|
+
null,
|
|
22
|
+
null,
|
|
23
|
+
null
|
|
24
|
+
],
|
|
25
|
+
"mappings": ";;;;;aAIYA,IAAIA;;;aAGJC,eAAeA;;;;;aAKfC,QAAQA;;;;;;aAMRC,kBAAkBA;;;;;;;aAOlBC,UAAUA;;;aAGVC,aAAaA;kBACRC,YAAYA;;;;;;;;aC7BjBC,WAAWA;;;;;;;;;;;;;;;;;;;;;;;;;;;UCECC,aAAaA"
|
|
26
|
+
}
|
package/dist/index.mjs
CHANGED
|
@@ -292,10 +292,21 @@ async function getJson(fileName) {
|
|
|
292
292
|
return [pkgPath, JSON.parse(buffer.toString())];
|
|
293
293
|
}
|
|
294
294
|
|
|
295
|
+
const Priority = {
|
|
296
|
+
preprocess: 1000,
|
|
297
|
+
cleanup: 1000,
|
|
298
|
+
externals: 2000,
|
|
299
|
+
resolve: 3000,
|
|
300
|
+
commonjs: 4000,
|
|
301
|
+
transpile: 6000,
|
|
302
|
+
compress: 10000,
|
|
303
|
+
finalize: 20000
|
|
304
|
+
};
|
|
305
|
+
|
|
295
306
|
async function clean (provider) {
|
|
296
307
|
const pluginClean = await provider.import('@rollup-extras/plugin-clean');
|
|
297
308
|
const pluginInstance = pluginClean();
|
|
298
|
-
provider.provide(pluginFactory,
|
|
309
|
+
provider.provide(pluginFactory, Priority.cleanup, { outputPlugin: true });
|
|
299
310
|
let firstPluginInstance = true;
|
|
300
311
|
function pluginFactory() {
|
|
301
312
|
const result = firstPluginInstance ? pluginInstance : pluginInstance.api.addInstance();
|
|
@@ -306,7 +317,7 @@ async function clean (provider) {
|
|
|
306
317
|
|
|
307
318
|
async function commonjs (provider) {
|
|
308
319
|
const pluginCommonjs = await provider.import('@rollup/plugin-commonjs');
|
|
309
|
-
provider.provide(() => pluginCommonjs(),
|
|
320
|
+
provider.provide(() => pluginCommonjs(), Priority.commonjs);
|
|
310
321
|
}
|
|
311
322
|
|
|
312
323
|
async function externals (provider, config, inputs, inputsExt) {
|
|
@@ -319,7 +330,7 @@ async function externals (provider, config, inputs, inputsExt) {
|
|
|
319
330
|
const format = (allowGenericUmd ? undefined : config.formats.filter(format => format !== 'umd'));
|
|
320
331
|
provider.provide(() => pluginExternals(config.includeExternals === false
|
|
321
332
|
? {}
|
|
322
|
-
: (id, external, importer) => includeExternals(importer, external, id, config)),
|
|
333
|
+
: (id, external, importer) => includeExternals(importer, external, id, config)), Priority.externals, { format });
|
|
323
334
|
// for eject config
|
|
324
335
|
provider.globalImport('path', 'path');
|
|
325
336
|
provider.globalSetup(includeExternals);
|
|
@@ -328,7 +339,7 @@ async function externals (provider, config, inputs, inputsExt) {
|
|
|
328
339
|
const curry = (await provider.import('lodash/curry.js'));
|
|
329
340
|
for (const currentInput of config.umdInputs) {
|
|
330
341
|
const isExternal = curry((currentInput, id, external, importer) => includeExternals(importer, external, id, config) || isExternalInput(currentInput, inputs, inputsExt, id, config))(currentInput);
|
|
331
|
-
provider.provide(() => pluginExternals(isExternal),
|
|
342
|
+
provider.provide(() => pluginExternals(isExternal), Priority.externals, { format: 'umd', inputs: [`./${config.sourceDir}/${currentInput}.${inputsExt.get(currentInput)}`] });
|
|
332
343
|
}
|
|
333
344
|
// for eject config
|
|
334
345
|
if (config.formats.length === 0) {
|
|
@@ -372,15 +383,15 @@ function isExternalInput(currentInput, inputs, inputsExt, id, config) {
|
|
|
372
383
|
|
|
373
384
|
async function preprocess (provider, config, inputs, inputsExt) {
|
|
374
385
|
if (config.preprocess.length > 0) {
|
|
375
|
-
const pluginPreprocess = await provider.import('rollup-plugin-preprocess'
|
|
386
|
+
const pluginPreprocess = await provider.import('rollup-plugin-preprocess');
|
|
376
387
|
const include = config.preprocess.map(name => `${config.sourceDir}/${name}.${inputsExt.get(name)}`);
|
|
377
388
|
for (const format of config.formats) {
|
|
378
389
|
if (format !== 'umd') {
|
|
379
|
-
provider.provide(() => pluginPreprocess({ include, context: { [format]: true } }),
|
|
390
|
+
provider.provide(() => pluginPreprocess.default({ include, context: { [format]: true } }), Priority.preprocess, { format });
|
|
380
391
|
}
|
|
381
392
|
else {
|
|
382
393
|
for (const currentInput of config.umdInputs) {
|
|
383
|
-
provider.provide(() => pluginPreprocess({ include, context: { umd: true } }),
|
|
394
|
+
provider.provide(() => pluginPreprocess.default({ include, context: { umd: true } }), Priority.preprocess, { format, inputs: [`./${config.sourceDir}/${currentInput}.${inputsExt.get(currentInput)}`] });
|
|
384
395
|
}
|
|
385
396
|
}
|
|
386
397
|
}
|
|
@@ -389,7 +400,7 @@ async function preprocess (provider, config, inputs, inputsExt) {
|
|
|
389
400
|
|
|
390
401
|
async function resolve (provider) {
|
|
391
402
|
const pluginResolve = await provider.import('@rollup/plugin-node-resolve');
|
|
392
|
-
provider.provide(() => pluginResolve(),
|
|
403
|
+
provider.provide(() => pluginResolve(), Priority.resolve);
|
|
393
404
|
}
|
|
394
405
|
|
|
395
406
|
async function terser (provider, config, inputs, inputsExt) {
|
|
@@ -406,11 +417,11 @@ async function terser (provider, config, inputs, inputsExt) {
|
|
|
406
417
|
if (filteredFormats.length > 0) {
|
|
407
418
|
for (const format of filteredFormats) {
|
|
408
419
|
if (format !== 'umd') {
|
|
409
|
-
provider.provide(() => pluginTerser(options),
|
|
420
|
+
provider.provide(() => pluginTerser(options), Priority.compress, { format, outputPlugin: true });
|
|
410
421
|
}
|
|
411
422
|
else {
|
|
412
423
|
for (const currentInput of config.umdInputs) {
|
|
413
|
-
provider.provide(() => pluginTerser(options),
|
|
424
|
+
provider.provide(() => pluginTerser(options), Priority.compress, { format, outputPlugin: true, inputs: [`./${config.sourceDir}/${currentInput}.${inputsExt.get(currentInput)}`] });
|
|
414
425
|
}
|
|
415
426
|
}
|
|
416
427
|
}
|
|
@@ -422,7 +433,7 @@ async function typescript (provider, config, inputs) {
|
|
|
422
433
|
const typescriptInputs = inputs.filter(input => input.endsWith('.ts') || input.endsWith('.tsx'));
|
|
423
434
|
if (typescriptInputs.length > 0) {
|
|
424
435
|
const pluginTypescript = await provider.import('rollup-plugin-typescript2');
|
|
425
|
-
provider.provide(() => pluginTypescript(),
|
|
436
|
+
provider.provide(() => pluginTypescript(), Priority.transpile, typescriptInputs.length === inputs.length ? undefined : { inputs: typescriptInputs });
|
|
426
437
|
}
|
|
427
438
|
}
|
|
428
439
|
|
|
@@ -431,7 +442,7 @@ async function binify (provider, config) {
|
|
|
431
442
|
const pluginBinify = await provider.import('@rollup-extras/plugin-binify');
|
|
432
443
|
provider.provide(() => pluginBinify({
|
|
433
444
|
filter: (item) => item.type === 'chunk' && item.isEntry && config.bin.some(input => input === `./${config.dir}/${item.fileName}`)
|
|
434
|
-
}),
|
|
445
|
+
}), Priority.finalize, { outputPlugin: true, format: 'cjs' });
|
|
435
446
|
}
|
|
436
447
|
}
|
|
437
448
|
|
|
@@ -694,7 +705,7 @@ async function getRollupConfigs([provider, plugins$1], inputs, inputsExt, config
|
|
|
694
705
|
const mainLoggerText = (sourceDir, dir, configsCount, startingTime, finishedCount = 0) => (final = false) => `${sourceDir} → ${dir} ${final ? configsCount : finishedCount++} / ${configsCount}${final ? (' in ' + getTimeDiff(startingTime)) : ''}`;
|
|
695
706
|
|
|
696
707
|
const emptySet = new Set;
|
|
697
|
-
const sourceFileSuffixes = ['ts', 'tsx', 'js', 'jsx']; // svelte, vue, etc. are not supported yet
|
|
708
|
+
const sourceFileSuffixes = ['ts', 'tsx', 'js', 'jsx', 'cjs', 'mjs']; // svelte, vue, etc. are not supported yet
|
|
698
709
|
async function processPackage(pkg, config, plugins, tsConfig) {
|
|
699
710
|
const typingsFilePattern = '[name].d.ts';
|
|
700
711
|
const indexId = 'index';
|
|
@@ -901,12 +912,13 @@ async function writeJson(path, json) {
|
|
|
901
912
|
await fs.writeFile(path, toFormattedJson(json));
|
|
902
913
|
}
|
|
903
914
|
|
|
904
|
-
var version = "1.29.
|
|
915
|
+
var version = "1.29.3";
|
|
905
916
|
var name = "pkgbld";
|
|
906
917
|
var license = "MIT";
|
|
907
918
|
var author = "Konstantin Shutkin";
|
|
908
919
|
var bin = "./index.js";
|
|
909
920
|
var main = "./dist/index.mjs";
|
|
921
|
+
var types = "./dist/index.d.ts";
|
|
910
922
|
var files = [
|
|
911
923
|
"dist"
|
|
912
924
|
];
|
|
@@ -928,7 +940,7 @@ var keywords = [
|
|
|
928
940
|
"rollup"
|
|
929
941
|
];
|
|
930
942
|
var scripts = {
|
|
931
|
-
build: "rollup -c",
|
|
943
|
+
build: "xc6 rm src/options-types.ts && xc6 ln ../options/src/types.ts src/options-types.ts && rollup -c && dts-buddy dist/index.d.ts -m pkgbld:dist/src/index.d.ts && xc6 rm dist/src",
|
|
932
944
|
lint: "eslint ./src",
|
|
933
945
|
prepack: "node ./index.js prune"
|
|
934
946
|
};
|
|
@@ -956,8 +968,11 @@ var dependencies = {
|
|
|
956
968
|
};
|
|
957
969
|
var devDependencies = {
|
|
958
970
|
"@types/lodash": "^4.14.202",
|
|
971
|
+
"rollup-plugin-dts": "^6.1.0",
|
|
959
972
|
"@total-typescript/ts-reset": "^0.5.1",
|
|
960
|
-
|
|
973
|
+
"dts-buddy": "^0.4.4",
|
|
974
|
+
options: "workspace:*",
|
|
975
|
+
xc6: "workspace:*"
|
|
961
976
|
};
|
|
962
977
|
var peerDependencies = {
|
|
963
978
|
typescript: "^5.3.3"
|
|
@@ -969,6 +984,7 @@ var pkgbldPkg = {
|
|
|
969
984
|
author: author,
|
|
970
985
|
bin: bin,
|
|
971
986
|
main: main,
|
|
987
|
+
types: types,
|
|
972
988
|
files: files,
|
|
973
989
|
engines: engines,
|
|
974
990
|
repository: repository,
|
|
@@ -1131,10 +1147,16 @@ async function checkTsConfig(options, mainLogger, plugins) {
|
|
|
1131
1147
|
return config;
|
|
1132
1148
|
}
|
|
1133
1149
|
|
|
1134
|
-
function loadPlugins(pkg) {
|
|
1135
|
-
|
|
1136
|
-
.
|
|
1137
|
-
|
|
1150
|
+
async function loadPlugins(pkg) {
|
|
1151
|
+
try {
|
|
1152
|
+
return await Promise.all([...new Set([...Object.keys(pkg.devDependencies || {}), ...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.peerDependencies || {})])]
|
|
1153
|
+
.filter(packageName => packageName.startsWith('pkgbld-plugin-'))
|
|
1154
|
+
.map(packageName => import(packageName)));
|
|
1155
|
+
}
|
|
1156
|
+
catch (e) {
|
|
1157
|
+
console.error(e);
|
|
1158
|
+
return [];
|
|
1159
|
+
}
|
|
1138
1160
|
}
|
|
1139
1161
|
|
|
1140
1162
|
async function prunePkg(pkg, options, logger) {
|
|
@@ -1384,8 +1406,7 @@ async function execute() {
|
|
|
1384
1406
|
}
|
|
1385
1407
|
}
|
|
1386
1408
|
catch (e) {
|
|
1387
|
-
|
|
1388
|
-
mainLogger.finish(`${e}}`, 3 /* LogLevel.error */);
|
|
1409
|
+
mainLogger.finish(JSON.stringify(e), 3 /* LogLevel.error */);
|
|
1389
1410
|
process.exit(-1);
|
|
1390
1411
|
}
|
|
1391
1412
|
async function buildConfig(config, updater) {
|
package/package.json
CHANGED