pkgbld 1.6.0 → 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/dist/index.js +22 -35
- package/package.json +15 -10
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
|
}
|
|
@@ -52,7 +39,7 @@ const defaults = {
|
|
|
52
39
|
};
|
|
53
40
|
function getCliOptions() {
|
|
54
41
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
55
|
-
const parsedArgs =
|
|
42
|
+
const parsedArgs = minimist(process.argv.slice(2));
|
|
56
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;
|
|
57
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;
|
|
58
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;
|
|
@@ -72,21 +59,21 @@ function getCliOptions() {
|
|
|
72
59
|
}
|
|
73
60
|
|
|
74
61
|
async function getPackage() {
|
|
75
|
-
const pkgPath =
|
|
76
|
-
const buffer = await
|
|
62
|
+
const pkgPath = path.resolve('package.json');
|
|
63
|
+
const buffer = await fs.readFile(pkgPath);
|
|
77
64
|
return [pkgPath, JSON.parse(buffer.toString())];
|
|
78
65
|
}
|
|
79
66
|
|
|
80
67
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
68
|
function getHelpers(pkg) {
|
|
82
69
|
function getGlobalName(anInput) {
|
|
83
|
-
return
|
|
70
|
+
return camelCase(path.join(pkg.name, path.basename(anInput, '.ts') !== 'index' ? path.basename(anInput, '.ts') : ''));
|
|
84
71
|
}
|
|
85
72
|
function getExternalGlobalName(id) {
|
|
86
|
-
if (
|
|
87
|
-
return getGlobalName(
|
|
73
|
+
if (path.isAbsolute(id)) {
|
|
74
|
+
return getGlobalName(path.relative(__dirname, id));
|
|
88
75
|
}
|
|
89
|
-
return
|
|
76
|
+
return camelCase(id);
|
|
90
77
|
}
|
|
91
78
|
return {
|
|
92
79
|
getGlobalName,
|
|
@@ -95,7 +82,7 @@ function getHelpers(pkg) {
|
|
|
95
82
|
};
|
|
96
83
|
}
|
|
97
84
|
function umdFilter(config, filename) {
|
|
98
|
-
const id =
|
|
85
|
+
const id = path.basename(filename, '.ts');
|
|
99
86
|
return config.umdTargets.includes(id);
|
|
100
87
|
}
|
|
101
88
|
function toArray(object) {
|
|
@@ -106,11 +93,11 @@ function toArray(object) {
|
|
|
106
93
|
}
|
|
107
94
|
function isExternalInput(id, inputs, currentInput, config) {
|
|
108
95
|
let normalizedPath;
|
|
109
|
-
if (
|
|
110
|
-
normalizedPath = './' +
|
|
96
|
+
if (path.isAbsolute(id)) {
|
|
97
|
+
normalizedPath = './' + path.relative(process.cwd(), id);
|
|
111
98
|
}
|
|
112
99
|
else {
|
|
113
|
-
normalizedPath = './' +
|
|
100
|
+
normalizedPath = './' + path.join(config.sourceDir, id + '.ts');
|
|
114
101
|
}
|
|
115
102
|
return normalizedPath !== currentInput && inputs.includes(normalizedPath);
|
|
116
103
|
}
|
|
@@ -129,20 +116,20 @@ function getTimeDiff(starting) {
|
|
|
129
116
|
return `${now - starting}ms`;
|
|
130
117
|
}
|
|
131
118
|
|
|
132
|
-
const clean =
|
|
119
|
+
const clean = cleanFactory();
|
|
133
120
|
function getBuildPlugins(format, config, inputs, currentInput) {
|
|
134
121
|
const result = [
|
|
135
122
|
clean,
|
|
136
|
-
|
|
123
|
+
externals({
|
|
137
124
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
138
125
|
external: (id, external) => external || (format === 'umd' ? isExternalInput(id, inputs, currentInput, config) : false)
|
|
139
126
|
}),
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
127
|
+
resolve(),
|
|
128
|
+
commonjs(),
|
|
129
|
+
typescript()
|
|
143
130
|
];
|
|
144
131
|
if (config.preprocess.length) {
|
|
145
|
-
result.unshift(
|
|
132
|
+
result.unshift(preprocess({ include: config.preprocess.map(name => `${config.sourceDir}/${name}.ts`), context: getPreprocessContext(format) }));
|
|
146
133
|
}
|
|
147
134
|
return result;
|
|
148
135
|
}
|
|
@@ -260,7 +247,7 @@ function processPackage(pkg, config) {
|
|
|
260
247
|
for (const id in pkg.exports) {
|
|
261
248
|
if (id === './package.json')
|
|
262
249
|
continue;
|
|
263
|
-
const basename = id == '.' ? 'index' :
|
|
250
|
+
const basename = id == '.' ? 'index' : path.basename(id);
|
|
264
251
|
if (typeof pkg.exports[id] !== 'object') {
|
|
265
252
|
pkg.exports[id] = {};
|
|
266
253
|
}
|
|
@@ -278,7 +265,7 @@ function processPackage(pkg, config) {
|
|
|
278
265
|
|
|
279
266
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
280
267
|
async function writePackage(pkgPath, pkg) {
|
|
281
|
-
await
|
|
268
|
+
await fs.writeFile(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
|
|
282
269
|
}
|
|
283
270
|
|
|
284
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
|
}
|