pkgbld 1.5.5 → 1.7.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 +8 -0
- package/dist/get-cli-options.d.ts +1 -0
- package/dist/helpers.d.ts +1 -1
- package/dist/index.js +31 -41
- package/package.json +15 -10
- package/dist/types.d.ts +0 -0
package/README.md
CHANGED
package/dist/helpers.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare function getHelpers(pkg: any): {
|
|
|
6
6
|
};
|
|
7
7
|
export declare function umdFilter(config: ReturnType<typeof getCliOptions>, filename: string): boolean;
|
|
8
8
|
export declare function toArray<T>(object: T): (T & any[]) | T[];
|
|
9
|
-
export declare function isExternalInput(id: string, inputs: string | string[], currentInput: string): boolean;
|
|
9
|
+
export declare function isExternalInput(id: string, inputs: string | string[], currentInput: string, config: ReturnType<typeof getCliOptions>): boolean;
|
|
10
10
|
export declare function formatInput(input: string[] | string | undefined): string | undefined;
|
|
11
11
|
export declare function formatOutput(output: any, field: string): string | undefined;
|
|
12
12
|
export declare function getTimeDiff(starting: number): string;
|
package/dist/index.js
CHANGED
|
@@ -15,28 +15,15 @@ var cleanFactory = require('@rollup-extras/plugin-clean');
|
|
|
15
15
|
var externals = require('@rollup-extras/plugin-externals');
|
|
16
16
|
var camelCase = require('lodash/camelCase');
|
|
17
17
|
|
|
18
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
19
|
-
|
|
20
|
-
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
21
|
-
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
22
|
-
var minimist__default = /*#__PURE__*/_interopDefaultLegacy(minimist);
|
|
23
|
-
var typescript__default = /*#__PURE__*/_interopDefaultLegacy(typescript);
|
|
24
|
-
var commonjs__default = /*#__PURE__*/_interopDefaultLegacy(commonjs);
|
|
25
|
-
var resolve__default = /*#__PURE__*/_interopDefaultLegacy(resolve);
|
|
26
|
-
var preprocess__default = /*#__PURE__*/_interopDefaultLegacy(preprocess);
|
|
27
|
-
var cleanFactory__default = /*#__PURE__*/_interopDefaultLegacy(cleanFactory);
|
|
28
|
-
var externals__default = /*#__PURE__*/_interopDefaultLegacy(externals);
|
|
29
|
-
var camelCase__default = /*#__PURE__*/_interopDefaultLegacy(camelCase);
|
|
30
|
-
|
|
31
18
|
async function createSubpackages(inputs, config) {
|
|
32
19
|
for (const input of inputs) {
|
|
33
|
-
const basename =
|
|
20
|
+
const basename = path.basename(input, '.ts');
|
|
34
21
|
if (basename !== 'index') {
|
|
35
22
|
const pkg = {
|
|
36
23
|
types: `../${config.dir}/${basename}.d.ts`
|
|
37
24
|
};
|
|
38
|
-
await
|
|
39
|
-
await
|
|
25
|
+
await fs.mkdir(basename, { recursive: true });
|
|
26
|
+
await fs.writeFile(`${basename}/package.json`, JSON.stringify(pkg, null, 2));
|
|
40
27
|
}
|
|
41
28
|
}
|
|
42
29
|
}
|
|
@@ -47,43 +34,46 @@ const defaults = {
|
|
|
47
34
|
compressTargets: ['umd'],
|
|
48
35
|
sourcemapTargets: ['umd'],
|
|
49
36
|
preprocess: [],
|
|
50
|
-
dir: 'dist'
|
|
37
|
+
dir: 'dist',
|
|
38
|
+
sourceDir: 'src'
|
|
51
39
|
};
|
|
52
40
|
function getCliOptions() {
|
|
53
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
54
|
-
const parsedArgs =
|
|
41
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
42
|
+
const parsedArgs = minimist(process.argv.slice(2));
|
|
55
43
|
const umdTargets = (_b = (_a = parsedArgs.umd) === null || _a === void 0 ? void 0 : _a.split(',').map((arg) => arg.trim())) !== null && _b !== void 0 ? _b : defaults.umdTargets;
|
|
56
44
|
const compressTargets = (_d = (_c = parsedArgs.compress) === null || _c === void 0 ? void 0 : _c.split(',').map((arg) => arg.trim())) !== null && _d !== void 0 ? _d : defaults.compressTargets;
|
|
57
45
|
const sourcemapTargets = (_f = (_e = parsedArgs.sourcemaps) === null || _e === void 0 ? void 0 : _e.split(',').map((arg) => arg.trim())) !== null && _f !== void 0 ? _f : defaults.sourcemapTargets;
|
|
58
46
|
const formats = (_h = (_g = parsedArgs.formats) === null || _g === void 0 ? void 0 : _g.split(',').map((arg) => arg.trim())) !== null && _h !== void 0 ? _h : defaults.formats;
|
|
59
47
|
const preprocess = (_k = (_j = parsedArgs.preprocess) === null || _j === void 0 ? void 0 : _j.split(',').map((arg) => arg.trim())) !== null && _k !== void 0 ? _k : defaults.preprocess;
|
|
60
48
|
const dir = (_l = parsedArgs.dir) !== null && _l !== void 0 ? _l : defaults.dir;
|
|
49
|
+
const sourceDir = (_m = parsedArgs.sourceDir) !== null && _m !== void 0 ? _m : defaults.sourceDir;
|
|
61
50
|
return {
|
|
62
51
|
umdTargets,
|
|
63
52
|
compressTargets,
|
|
64
53
|
sourcemapTargets,
|
|
65
54
|
formats,
|
|
66
55
|
preprocess,
|
|
67
|
-
dir
|
|
56
|
+
dir,
|
|
57
|
+
sourceDir
|
|
68
58
|
};
|
|
69
59
|
}
|
|
70
60
|
|
|
71
61
|
async function getPackage() {
|
|
72
|
-
const pkgPath =
|
|
73
|
-
const buffer = await
|
|
62
|
+
const pkgPath = path.resolve('package.json');
|
|
63
|
+
const buffer = await fs.readFile(pkgPath);
|
|
74
64
|
return [pkgPath, JSON.parse(buffer.toString())];
|
|
75
65
|
}
|
|
76
66
|
|
|
77
67
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
78
68
|
function getHelpers(pkg) {
|
|
79
69
|
function getGlobalName(anInput) {
|
|
80
|
-
return
|
|
70
|
+
return camelCase(path.join(pkg.name, path.basename(anInput, '.ts') !== 'index' ? path.basename(anInput, '.ts') : ''));
|
|
81
71
|
}
|
|
82
72
|
function getExternalGlobalName(id) {
|
|
83
|
-
if (
|
|
84
|
-
return getGlobalName(
|
|
73
|
+
if (path.isAbsolute(id)) {
|
|
74
|
+
return getGlobalName(path.relative(__dirname, id));
|
|
85
75
|
}
|
|
86
|
-
return
|
|
76
|
+
return camelCase(id);
|
|
87
77
|
}
|
|
88
78
|
return {
|
|
89
79
|
getGlobalName,
|
|
@@ -92,7 +82,7 @@ function getHelpers(pkg) {
|
|
|
92
82
|
};
|
|
93
83
|
}
|
|
94
84
|
function umdFilter(config, filename) {
|
|
95
|
-
const id =
|
|
85
|
+
const id = path.basename(filename, '.ts');
|
|
96
86
|
return config.umdTargets.includes(id);
|
|
97
87
|
}
|
|
98
88
|
function toArray(object) {
|
|
@@ -101,13 +91,13 @@ function toArray(object) {
|
|
|
101
91
|
}
|
|
102
92
|
return [object];
|
|
103
93
|
}
|
|
104
|
-
function isExternalInput(id, inputs, currentInput) {
|
|
94
|
+
function isExternalInput(id, inputs, currentInput, config) {
|
|
105
95
|
let normalizedPath;
|
|
106
|
-
if (
|
|
107
|
-
normalizedPath = './' +
|
|
96
|
+
if (path.isAbsolute(id)) {
|
|
97
|
+
normalizedPath = './' + path.relative(process.cwd(), id);
|
|
108
98
|
}
|
|
109
99
|
else {
|
|
110
|
-
normalizedPath = './' +
|
|
100
|
+
normalizedPath = './' + path.join(config.sourceDir, id + '.ts');
|
|
111
101
|
}
|
|
112
102
|
return normalizedPath !== currentInput && inputs.includes(normalizedPath);
|
|
113
103
|
}
|
|
@@ -126,20 +116,20 @@ function getTimeDiff(starting) {
|
|
|
126
116
|
return `${now - starting}ms`;
|
|
127
117
|
}
|
|
128
118
|
|
|
129
|
-
const clean =
|
|
119
|
+
const clean = cleanFactory();
|
|
130
120
|
function getBuildPlugins(format, config, inputs, currentInput) {
|
|
131
121
|
const result = [
|
|
132
122
|
clean,
|
|
133
|
-
|
|
123
|
+
externals({
|
|
134
124
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
135
|
-
external: (id, external) => external || (format === 'umd' ? isExternalInput(id, inputs, currentInput) : false)
|
|
125
|
+
external: (id, external) => external || (format === 'umd' ? isExternalInput(id, inputs, currentInput, config) : false)
|
|
136
126
|
}),
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
127
|
+
resolve(),
|
|
128
|
+
commonjs(),
|
|
129
|
+
typescript()
|
|
140
130
|
];
|
|
141
131
|
if (config.preprocess.length) {
|
|
142
|
-
result.unshift(
|
|
132
|
+
result.unshift(preprocess({ include: config.preprocess.map(name => `${config.sourceDir}/${name}.ts`), context: getPreprocessContext(format) }));
|
|
143
133
|
}
|
|
144
134
|
return result;
|
|
145
135
|
}
|
|
@@ -257,7 +247,7 @@ function processPackage(pkg, config) {
|
|
|
257
247
|
for (const id in pkg.exports) {
|
|
258
248
|
if (id === './package.json')
|
|
259
249
|
continue;
|
|
260
|
-
const basename = id == '.' ? 'index' :
|
|
250
|
+
const basename = id == '.' ? 'index' : path.basename(id);
|
|
261
251
|
if (typeof pkg.exports[id] !== 'object') {
|
|
262
252
|
pkg.exports[id] = {};
|
|
263
253
|
}
|
|
@@ -268,14 +258,14 @@ function processPackage(pkg, config) {
|
|
|
268
258
|
pkg.files.push(basename);
|
|
269
259
|
}
|
|
270
260
|
}
|
|
271
|
-
input.push(
|
|
261
|
+
input.push(`./${config.sourceDir}/${basename}.ts`);
|
|
272
262
|
}
|
|
273
263
|
return input;
|
|
274
264
|
}
|
|
275
265
|
|
|
276
266
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
277
267
|
async function writePackage(pkgPath, pkg) {
|
|
278
|
-
await
|
|
268
|
+
await fs.writeFile(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
|
|
279
269
|
}
|
|
280
270
|
|
|
281
271
|
async function execute() {
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.7.0",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "pkgbld",
|
|
5
5
|
"author": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"dist"
|
|
11
11
|
],
|
|
12
12
|
"engines": {
|
|
13
|
-
"node": ">=
|
|
13
|
+
"node": ">=16"
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
@@ -43,20 +43,25 @@
|
|
|
43
43
|
"conventional-changelog-angular": "5.0.13",
|
|
44
44
|
"eslint": "8.5.0",
|
|
45
45
|
"semantic-release": "19.0.3",
|
|
46
|
-
"@rollup-extras/plugin-binify": "1.
|
|
46
|
+
"@rollup-extras/plugin-binify": "1.1.0"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@niceties/logger": "1.1.4",
|
|
50
50
|
"lodash": "4.17.21",
|
|
51
|
-
"rollup": "
|
|
51
|
+
"rollup": "3.1.0",
|
|
52
52
|
"rollup-plugin-terser": "7.0.2",
|
|
53
53
|
"rollup-plugin-typescript2": "0.34.1",
|
|
54
54
|
"rollup-plugin-preprocess": "0.0.4",
|
|
55
|
-
"@rollup/plugin-commonjs": "
|
|
56
|
-
"@rollup/plugin-node-resolve": "
|
|
57
|
-
"@rollup-extras/plugin-clean": "1.
|
|
58
|
-
"@rollup-extras/plugin-externals": "1.0
|
|
59
|
-
"typescript": "4.8.
|
|
60
|
-
"minimist": "1.2.
|
|
55
|
+
"@rollup/plugin-commonjs": "23.0.0",
|
|
56
|
+
"@rollup/plugin-node-resolve": "15.0.0",
|
|
57
|
+
"@rollup-extras/plugin-clean": "1.3.0",
|
|
58
|
+
"@rollup-extras/plugin-externals": "1.1.0",
|
|
59
|
+
"typescript": "4.8.4",
|
|
60
|
+
"minimist": "1.2.7"
|
|
61
|
+
},
|
|
62
|
+
"overrides": {
|
|
63
|
+
"rollup-plugin-terser@7.0.2": {
|
|
64
|
+
"rollup": "3.1.0"
|
|
65
|
+
}
|
|
61
66
|
}
|
|
62
67
|
}
|
package/dist/types.d.ts
DELETED
|
File without changes
|