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