pkgbld 1.14.5 → 1.15.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 CHANGED
@@ -10,529 +10,681 @@ var minimist = require('minimist');
10
10
  var refiner = require('@slimlib/refine-partition');
11
11
  var camelCase = require('lodash/camelCase');
12
12
  var kleur = require('kleur');
13
+ var lodash = require('lodash');
14
+ var fs$1 = require('fs');
13
15
 
14
- async function createSubpackages(inputs, config) {
15
- for (const input of inputs) {
16
- const basename = path.basename(input, '.ts');
17
- if (basename !== 'index') {
18
- const pkg = {
19
- type: 'module',
20
- types: `../${config.dir}/${basename}.d.ts`,
21
- main: `../${config.dir}/${basename}.mjs`
22
- };
23
- await fs.mkdir(basename, { recursive: true });
24
- await fs.writeFile(`${basename}/package.json`, JSON.stringify(pkg, null, 2));
25
- }
26
- }
16
+ async function createSubpackages(inputs, config) {
17
+ for (const input of inputs) {
18
+ const basename = path.basename(input, '.ts');
19
+ if (basename !== 'index') {
20
+ const pkg = {
21
+ type: 'module',
22
+ types: `../${config.dir}/${basename}.d.ts`,
23
+ main: `../${config.dir}/${basename}.mjs`
24
+ };
25
+ await fs.mkdir(basename, { recursive: true });
26
+ await fs.writeFile(`${basename}/package.json`, JSON.stringify(pkg, null, 2));
27
+ }
28
+ }
27
29
  }
28
30
 
29
- const defaults = {
30
- formats: ['es', 'cjs'],
31
- umdInputs: [],
32
- compressFormats: ['umd'],
33
- sourcemapFormats: ['umd'],
34
- preprocess: [],
35
- dir: 'dist',
36
- sourceDir: 'src',
37
- includeExternals: false
38
- };
39
- function getCliOptions() {
40
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
41
- const parsedArgs = minimist(process.argv.slice(2));
42
- const umdInputs = (_b = (_a = parsedArgs.umd) === null || _a === void 0 ? void 0 : _a.split(',').map((arg) => arg.trim())) !== null && _b !== void 0 ? _b : defaults.umdInputs;
43
- const compressFormats = (_d = (_c = parsedArgs.compress) === null || _c === void 0 ? void 0 : _c.split(',').map((arg) => arg.trim())) !== null && _d !== void 0 ? _d : defaults.compressFormats;
44
- const sourcemapFormats = (_f = (_e = parsedArgs.sourcemaps) === null || _e === void 0 ? void 0 : _e.split(',').map((arg) => arg.trim())) !== null && _f !== void 0 ? _f : defaults.sourcemapFormats;
45
- 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;
46
- 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;
47
- const dir = (_l = parsedArgs.dir) !== null && _l !== void 0 ? _l : defaults.dir;
48
- const sourceDir = (_m = parsedArgs.sourceDir) !== null && _m !== void 0 ? _m : defaults.sourceDir;
49
- const bin = (_o = parsedArgs.bin) === null || _o === void 0 ? void 0 : _o.split(',').map((arg) => arg.trim());
50
- const includeExternals = (_p = parsedArgs['include-externals']) !== null && _p !== void 0 ? _p : defaults.includeExternals;
51
- return {
52
- umdInputs,
53
- compressFormats,
54
- sourcemapFormats,
55
- formats,
56
- formatsOverriden: 'formats' in parsedArgs,
57
- preprocess,
58
- dir,
59
- sourceDir,
60
- bin,
61
- includeExternals
62
- };
31
+ const defaults = {
32
+ formats: ['es', 'cjs'],
33
+ umdInputs: [],
34
+ compressFormats: ['umd'],
35
+ sourcemapFormats: ['umd'],
36
+ preprocess: [],
37
+ dir: 'dist',
38
+ sourceDir: 'src',
39
+ includeExternals: false,
40
+ eject: false,
41
+ noTsConfig: false,
42
+ noUpdatePackageJson: false
43
+ };
44
+ function getCliOptions() {
45
+ const parsedArgs = minimist(process.argv.slice(2));
46
+ const umdInputs = parsedArgs.umd?.split(',').map((arg) => arg.trim()) ?? defaults.umdInputs;
47
+ const compressFormats = parsedArgs.compress?.split(',').map((arg) => arg.trim()) ?? defaults.compressFormats;
48
+ const sourcemapFormats = parsedArgs.sourcemaps?.split(',').map((arg) => arg.trim()) ?? defaults.sourcemapFormats;
49
+ const formats = parsedArgs.formats?.split(',').map((arg) => arg.trim()) ?? defaults.formats;
50
+ const preprocess = parsedArgs.preprocess?.split(',').map((arg) => arg.trim()) ?? defaults.preprocess;
51
+ const dir = parsedArgs.dir ?? defaults.dir;
52
+ const sourceDir = parsedArgs.sourceDir ?? defaults.sourceDir;
53
+ const bin = parsedArgs.bin?.split(',').map((arg) => arg.trim());
54
+ const includeExternals = parsedArgs['include-externals'] ?? defaults.includeExternals;
55
+ const eject = !!parsedArgs.eject ?? defaults.eject;
56
+ const noTsConfig = !!parsedArgs.noTsConfig ?? defaults.noTsConfig;
57
+ const noUpdatePackageJson = !!parsedArgs.noUpdatePackageJson ?? defaults.noUpdatePackageJson;
58
+ return {
59
+ umdInputs,
60
+ compressFormats,
61
+ sourcemapFormats,
62
+ formats,
63
+ formatsOverriden: 'formats' in parsedArgs,
64
+ preprocess,
65
+ dir,
66
+ sourceDir,
67
+ bin,
68
+ includeExternals,
69
+ eject,
70
+ noTsConfig,
71
+ noUpdatePackageJson
72
+ };
63
73
  }
64
74
 
65
- async function getPackage() {
66
- const pkgPath = path.resolve('package.json');
67
- const buffer = await fs.readFile(pkgPath);
68
- return [pkgPath, JSON.parse(buffer.toString())];
75
+ async function getPackage() {
76
+ const pkgPath = path.resolve('package.json');
77
+ const buffer = await fs.readFile(pkgPath);
78
+ return [pkgPath, JSON.parse(buffer.toString())];
69
79
  }
70
80
 
71
- async function clean (provide) {
72
- const { default: pluginClean } = await import('@rollup-extras/plugin-clean');
73
- const pluginInstance = pluginClean();
74
- provide(pluginFactory, 1000 /* Priotiry.cleanup */, { outputPlugin: true });
75
- let firstPluginInstance = true;
76
- function pluginFactory() {
77
- const result = firstPluginInstance ? pluginInstance : pluginInstance.api.addInstance();
78
- firstPluginInstance = false;
79
- return result;
80
- }
81
+ async function clean (provider) {
82
+ const pluginClean = await provider.import('@rollup-extras/plugin-clean');
83
+ const pluginInstance = pluginClean();
84
+ provider.provide(pluginFactory, 1000 /* Priotiry.cleanup */, { outputPlugin: true });
85
+ let firstPluginInstance = true;
86
+ function pluginFactory() {
87
+ const result = firstPluginInstance ? pluginInstance : pluginInstance.api.addInstance();
88
+ firstPluginInstance = false;
89
+ return result;
90
+ }
81
91
  }
82
92
 
83
- async function commonjs (provide) {
84
- const { default: pluginCommonjs } = await import('@rollup/plugin-commonjs');
85
- provide(() => pluginCommonjs(), 4000 /* Priotiry.commonjs */);
93
+ async function commonjs (provider) {
94
+ const pluginCommonjs = await provider.import('@rollup/plugin-commonjs');
95
+ provider.provide(() => pluginCommonjs(), 4000 /* Priotiry.commonjs */);
86
96
  }
87
97
 
88
- async function externals (provide, config, inputs) {
89
- if (config.includeExternals) {
90
- return;
91
- }
92
- const { default: pluginExternals } = await import('@rollup-extras/plugin-externals');
93
- const allowGenericUmd = config.umdInputs.length === 1 && inputs.length === 1;
94
- if (config.formats.length > 0) {
95
- const format = (allowGenericUmd ? undefined : config.formats.filter(format => format !== 'umd'));
96
- provide(() => pluginExternals(), 2000 /* Priotiry.externals */, { format });
97
- }
98
- if (!allowGenericUmd && config.umdInputs.length > 0) {
99
- for (const currentInput of config.umdInputs) {
100
- provide(() => pluginExternals({
101
- external: (id, external) => external || isExternalInput(currentInput, inputs, id, config)
102
- }), 2000 /* Priotiry.externals */, { format: 'umd', inputs: [`./${config.sourceDir}/${currentInput}.ts`] });
103
- }
104
- }
105
- }
106
- function isExternalInput(currentInput, inputs, id, config) {
107
- let normalizedPath;
108
- if (path.isAbsolute(currentInput)) {
109
- normalizedPath = './' + path.relative(process.cwd(), currentInput);
110
- }
111
- else {
112
- normalizedPath = './' + path.join(config.sourceDir, currentInput + '.ts');
113
- }
114
- if (path.isAbsolute(id)) {
115
- id = './' + path.relative(process.cwd(), id);
116
- }
117
- return normalizedPath !== id && inputs.includes(normalizedPath);
98
+ async function externals (provider, config, inputs) {
99
+ if (config.includeExternals) {
100
+ return;
101
+ }
102
+ const pluginExternals = await provider.import('@rollup-extras/plugin-externals');
103
+ const allowGenericUmd = config.umdInputs.length === 1 && inputs.length === 1;
104
+ if (config.formats.length > 0) {
105
+ const format = (allowGenericUmd ? undefined : config.formats.filter(format => format !== 'umd'));
106
+ provider.provide(() => pluginExternals(), 2000 /* Priotiry.externals */, { format });
107
+ }
108
+ if (!allowGenericUmd && config.umdInputs.length > 0) {
109
+ for (const currentInput of config.umdInputs) {
110
+ provider.provide(() => pluginExternals({
111
+ external: (id, external) => external || isExternalInput(currentInput, inputs, id, config)
112
+ }), 2000 /* Priotiry.externals */, { format: 'umd', inputs: [`./${config.sourceDir}/${currentInput}.ts`] });
113
+ }
114
+ // for eject config
115
+ provider.globalImport('path', 'path');
116
+ provider.globalSetupt(isExternalInput);
117
+ }
118
+ }
119
+ function isExternalInput(currentInput, inputs, id, config) {
120
+ let normalizedPath;
121
+ if (path.isAbsolute(currentInput)) {
122
+ normalizedPath = './' + path.relative(process.cwd(), currentInput);
123
+ }
124
+ else {
125
+ normalizedPath = './' + path.join(config.sourceDir, currentInput + '.ts');
126
+ }
127
+ if (path.isAbsolute(id)) {
128
+ id = './' + path.relative(process.cwd(), id);
129
+ }
130
+ return normalizedPath !== id && inputs.includes(normalizedPath);
118
131
  }
119
132
 
120
- async function preprocess (provide, config) {
121
- if (config.preprocess.length > 0) {
122
- const { default: pluginPreprocess } = await import('rollup-plugin-preprocess');
123
- const include = config.preprocess.map(name => `${config.sourceDir}/${name}.ts`);
124
- for (const format of config.formats) {
125
- if (format !== 'umd') {
126
- provide(() => pluginPreprocess({ include, context: { [format]: true } }), 1000 /* Priotiry.preprocess */, { format });
127
- }
128
- else {
129
- for (const currentInput of config.umdInputs) {
130
- provide(() => pluginPreprocess({ include, context: { umd: true } }), 1000 /* Priotiry.preprocess */, { format, inputs: [`./${config.sourceDir}/${currentInput}.ts`] });
131
- }
132
- }
133
- }
134
- }
133
+ async function preprocess (provider, config) {
134
+ if (config.preprocess.length > 0) {
135
+ const pluginPreprocess = await provider.import('rollup-plugin-preprocess');
136
+ const include = config.preprocess.map(name => `${config.sourceDir}/${name}.ts`);
137
+ for (const format of config.formats) {
138
+ if (format !== 'umd') {
139
+ provider.provide(() => pluginPreprocess({ include, context: { [format]: true } }), 1000 /* Priotiry.preprocess */, { format });
140
+ }
141
+ else {
142
+ for (const currentInput of config.umdInputs) {
143
+ provider.provide(() => pluginPreprocess({ include, context: { umd: true } }), 1000 /* Priotiry.preprocess */, { format, inputs: [`./${config.sourceDir}/${currentInput}.ts`] });
144
+ }
145
+ }
146
+ }
147
+ }
135
148
  }
136
149
 
137
- async function resolve (provide) {
138
- const { default: pluginResolve } = await import('@rollup/plugin-node-resolve');
139
- provide(() => pluginResolve(), 3000 /* Priotiry.resolve */);
150
+ async function resolve (provider) {
151
+ const pluginResolve = await provider.import('@rollup/plugin-node-resolve');
152
+ provider.provide(() => pluginResolve(), 3000 /* Priotiry.resolve */);
140
153
  }
141
154
 
142
- async function terser (provide, config) {
143
- if (config.compressFormats.length > 0) {
144
- const { default: pluginTerser } = await import('@rollup/plugin-terser');
145
- const options = {
146
- mangle: {
147
- properties: {
148
- regex: /_$/
149
- }
150
- }
151
- };
152
- const filteredFormats = config.compressFormats.filter(format => config.formats.includes(format));
153
- if (filteredFormats.length > 0) {
154
- for (const format of filteredFormats) {
155
- if (format !== 'umd') {
156
- provide(() => pluginTerser(options), 10000 /* Priotiry.compress */, { format, outputPlugin: true });
157
- }
158
- else {
159
- for (const currentInput of config.umdInputs) {
160
- provide(() => pluginTerser(options), 10000 /* Priotiry.compress */, { format, outputPlugin: true, inputs: [`./${config.sourceDir}/${currentInput}.ts`] });
161
- }
162
- }
163
- }
164
- }
165
- }
155
+ async function terser (provider, config) {
156
+ const filteredFormats = config.compressFormats.filter(format => config.formats.includes(format));
157
+ if (filteredFormats.length > 0) {
158
+ const pluginTerser = await provider.import('@rollup/plugin-terser');
159
+ const options = {
160
+ mangle: {
161
+ properties: {
162
+ regex: /_$/
163
+ }
164
+ }
165
+ };
166
+ if (filteredFormats.length > 0) {
167
+ for (const format of filteredFormats) {
168
+ if (format !== 'umd') {
169
+ provider.provide(() => pluginTerser(options), 10000 /* Priotiry.compress */, { format, outputPlugin: true });
170
+ }
171
+ else {
172
+ for (const currentInput of config.umdInputs) {
173
+ provider.provide(() => pluginTerser(options), 10000 /* Priotiry.compress */, { format, outputPlugin: true, inputs: [`./${config.sourceDir}/${currentInput}.ts`] });
174
+ }
175
+ }
176
+ }
177
+ }
178
+ }
166
179
  }
167
180
 
168
- async function typescript (provide) {
169
- const { default: pluginTypescript } = await import('rollup-plugin-typescript2');
170
- provide(() => pluginTypescript(), 6000 /* Priotiry.transpile */);
181
+ async function typescript (provider) {
182
+ const pluginTypescript = await provider.import('rollup-plugin-typescript2');
183
+ provider.provide(() => pluginTypescript(), 6000 /* Priotiry.transpile */);
171
184
  }
172
185
 
173
- async function binify (provide, config) {
174
- var _a;
175
- if (config.bin != null) {
176
- const { default: pluginBinify } = await import('@rollup-extras/plugin-binify');
177
- const format = (_a = {
178
- 'cjs': 'cjs',
179
- 'mjs': 'es'
180
- }[path.extname(config.bin[0])]) !== null && _a !== void 0 ? _a : 'cjs';
181
- provide(() => pluginBinify({
182
- filter: (item) => item.type === 'chunk' && item.isEntry && config.bin.some(input => input === `./${config.dir}/${item.fileName}`)
183
- }), 20000 /* Priotiry.finalize */, { outputPlugin: true, format });
184
- }
186
+ async function binify (provider, config) {
187
+ if (config.bin != null) {
188
+ const pluginBinify = await provider.import('@rollup-extras/plugin-binify');
189
+ const format = {
190
+ 'cjs': 'cjs',
191
+ 'mjs': 'es'
192
+ }[path.extname(config.bin[0])] ?? 'cjs';
193
+ provider.provide(() => pluginBinify({
194
+ filter: (item) => item.type === 'chunk' && item.isEntry && config.bin.some(input => input === `./${config.dir}/${item.fileName}`)
195
+ }), 20000 /* Priotiry.finalize */, { outputPlugin: true, format });
196
+ }
185
197
  }
186
198
 
187
- const plugins = [
188
- clean,
189
- commonjs,
190
- externals,
191
- preprocess,
192
- resolve,
193
- terser,
194
- typescript,
195
- binify
196
- ];
197
- function createProvider() {
198
- const plugins = [];
199
- return [(plugin, priority, options) => {
200
- plugins.push({ priority, plugin, format: options === null || options === void 0 ? void 0 : options.format, inputs: options === null || options === void 0 ? void 0 : options.inputs, outputPlugin: options === null || options === void 0 ? void 0 : options.outputPlugin });
201
- }, plugins];
199
+ const plugins = [
200
+ clean,
201
+ commonjs,
202
+ externals,
203
+ preprocess,
204
+ resolve,
205
+ terser,
206
+ typescript,
207
+ binify
208
+ ];
209
+ const noop = () => undefined;
210
+ function createProvider() {
211
+ const plugins = [];
212
+ return [{
213
+ provide: (plugin, priority, options) => {
214
+ plugins.push({ priority, plugin, format: options?.format, inputs: options?.inputs, outputPlugin: options?.outputPlugin });
215
+ },
216
+ import: async (name, exportName) => {
217
+ const result = await import(name);
218
+ return result[exportName ?? 'default'];
219
+ },
220
+ globalImport: noop,
221
+ globalSetupt: noop
222
+ }, plugins];
202
223
  }
203
224
 
204
- function getHelpers(name) {
205
- function getGlobalName(anInput) {
206
- return camelCase(path.join(name, path.basename(anInput, '.ts') !== 'index' ? path.basename(anInput, '.ts') : ''));
207
- }
208
- function getExternalGlobalName(id) {
209
- if (path.isAbsolute(id)) {
210
- return getGlobalName(path.relative(__dirname, id));
211
- }
212
- return camelCase(id);
213
- }
214
- return {
215
- getGlobalName,
216
- getExternalGlobalName
217
- };
218
- }
219
- function toArray(object) {
220
- if (Array.isArray(object)) {
221
- return object;
222
- }
223
- if (object == null) {
224
- return [];
225
- }
226
- return [object];
227
- }
228
- function formatInput(input) {
229
- return (Array.isArray(input) ? input : [input !== null && input !== void 0 ? input : '']).map(item => kleur.magenta(path.basename(item, '.ts'))).join(', ');
230
- }
231
- function formatOutput(output, field) {
232
- //? can we avoid it
233
- if (output == null) {
234
- return '';
235
- }
236
- return (Array.isArray(output) ? output : [output !== null && output !== void 0 ? output : '']).map(item => kleur.cyan(item[field])).join(', ');
237
- }
238
- function getTimeDiff(starting) {
239
- const now = Date.now();
240
- if (now - starting > 1000) {
241
- return `${((now - starting) / 1000).toFixed(1)}s`;
242
- }
243
- return `${now - starting}ms`;
244
- }
225
+ function getHelpers(pkgName) {
226
+ function getGlobalName(anInput) {
227
+ return camelCase(path.join(pkgName, path.basename(anInput, '.ts') !== 'index' ? path.basename(anInput, '.ts') : ''));
228
+ }
229
+ function getExternalGlobalName(id) {
230
+ if (path.isAbsolute(id)) {
231
+ return getGlobalName(path.relative(__dirname, id));
232
+ }
233
+ return camelCase(id);
234
+ }
235
+ return {
236
+ getGlobalName,
237
+ getExternalGlobalName
238
+ };
239
+ }
240
+ function toArray(object) {
241
+ if (Array.isArray(object)) {
242
+ return object;
243
+ }
244
+ if (object == null) {
245
+ return [];
246
+ }
247
+ return [object];
248
+ }
249
+ function formatInput(input) {
250
+ return (Array.isArray(input) ? input : [input ?? '']).map(item => kleur.magenta(path.basename(item, '.ts'))).join(', ');
251
+ }
252
+ function formatOutput(output, field) {
253
+ //? can we avoid it
254
+ if (output == null) {
255
+ return '';
256
+ }
257
+ return (Array.isArray(output) ? output : [output ?? '']).map(item => kleur.cyan(item[field])).join(', ');
258
+ }
259
+ function getTimeDiff(starting) {
260
+ const now = Date.now();
261
+ if (now - starting > 1000) {
262
+ return `${((now - starting) / 1000).toFixed(1)}s`;
263
+ }
264
+ return `${now - starting}ms`;
265
+ }
245
266
  const areSetsEqual = (a, b) => a.size === b.size ? [...a].every(value => b.has(value)) : false;
246
267
 
247
- const fileNamePatterns = {
248
- 'es': '[name].mjs',
249
- 'cjs': '[name].cjs',
250
- 'umd': '[name].umd.js',
251
- };
252
- async function getRollupConfigs(inputs, config, helpers) {
253
- var _a;
254
- const [provide, plugins$1] = createProvider();
255
- for (const factory of plugins) {
256
- await factory(provide, config, inputs);
257
- }
258
- const expandInputs = new Set;
259
- for (const plugin of plugins$1) {
260
- if (plugin.format && ((_a = plugin.inputs) === null || _a === void 0 ? void 0 : _a.length) && !plugin.outputPlugin) {
261
- for (const format of toArray(plugin.format)) {
262
- expandInputs.add(format);
263
- }
264
- }
265
- }
266
- const refineNext = refiner();
267
- refineNext(doExpandInputs(toArray(config.formats)));
268
- for (const plugin of plugins$1) {
269
- if (plugin.format && !plugin.outputPlugin) {
270
- const formats = toArray(plugin.format);
271
- if (!plugin.inputs || plugin.inputs.length === 0) {
272
- refineNext(doExpandInputs(formats));
273
- }
274
- else {
275
- if (inputs.length === 1) {
276
- refineNext(formats);
277
- }
278
- else {
279
- const expanded = [];
280
- for (const format of formats) {
281
- for (const input of plugin.inputs) {
282
- expanded.push(`${format}.${input}`);
283
- }
284
- }
285
- refineNext(expanded);
286
- }
287
- }
288
- }
289
- }
290
- const refined = refineNext();
291
- const partitions = [];
292
- for (const partition of refined) {
293
- const result = [];
294
- for (const format of partition) {
295
- if (format.includes('.')) {
296
- const [, realFormat, input] = format.split(/(.*?)\.(.*)/gm);
297
- result.push({ format: realFormat, input });
298
- }
299
- else {
300
- result.push({ format });
301
- }
302
- }
303
- const mapFormatInputs = new Map;
304
- const formatsWithoutInputs = new Set;
305
- for (const { format, input } of result) {
306
- if (input) {
307
- if (mapFormatInputs.has(format)) {
308
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
309
- mapFormatInputs.get(format).add(input);
310
- }
311
- else {
312
- mapFormatInputs.set(format, new Set([input]));
313
- }
314
- }
315
- else {
316
- formatsWithoutInputs.add(format);
317
- }
318
- }
319
- for (const format of formatsWithoutInputs) {
320
- if (mapFormatInputs.has(format)) {
321
- throw new Error(`${format} is both used with inputs and without in plugins configuration and was not expanded / handled correctly. Please file an issue for pkgbld.`);
322
- }
323
- mapFormatInputs.set(format, new Set(inputs));
324
- }
325
- let prevInputs;
326
- for (const inputs of mapFormatInputs.values()) {
327
- if (prevInputs) {
328
- if (!areSetsEqual(inputs, prevInputs)) {
329
- throw new Error(`unbalanced inputs for partition: ${JSON.stringify(partition)}`);
330
- }
331
- }
332
- prevInputs = inputs;
333
- }
334
- partitions.push({ formats: [...mapFormatInputs.keys()], inputs: [...prevInputs] });
335
- }
336
- return partitions.map(({ formats, inputs }) => {
337
- return {
338
- input: inputs,
339
- output: formats.map(format => (Object.assign({ format, dir: config.dir, entryFileNames: fileNamePatterns[format], plugins: getPlugins([format], inputs, true), sourcemap: config.sourcemapFormats.includes(format) }, getExtraOutputSettings(format, inputs)))),
340
- plugins: getPlugins(formats, inputs, false)
341
- };
342
- });
343
- function getExtraOutputSettings(format, inputs) {
344
- switch (format) {
345
- case 'cjs':
346
- case 'es':
347
- return { chunkFileNames: fileNamePatterns[format] };
348
- case 'umd':
349
- if (inputs.length <= 0) {
350
- break;
351
- }
352
- if (inputs.length > 1) {
353
- throw new Error(`Cannot produce global name for mutliple umd inputs in one output: ${inputs}`);
354
- }
355
- return {
356
- name: helpers.getGlobalName(inputs[0]),
357
- globals: helpers.getExternalGlobalName,
358
- };
359
- }
360
- return {};
361
- }
362
- function getPlugins(formats, inputs, outputPlugin) {
363
- const filteredPlugins = [];
364
- for (const plugin of plugins$1) {
365
- if ((!!plugin.outputPlugin) === outputPlugin) {
366
- if ((!plugin.format || toArray(plugin.format).some(format => formats.includes(format)))
367
- && (!plugin.inputs || plugin.inputs.every(input => inputs.includes(input)))) {
368
- filteredPlugins.push({
369
- instance: plugin.plugin(),
370
- priority: plugin.priority
371
- });
372
- }
373
- }
374
- }
375
- filteredPlugins.sort((a, b) => a.priority - b.priority);
376
- return filteredPlugins.map(plugin => plugin.instance);
377
- }
378
- function doExpandInputs(formats) {
379
- if (inputs.length === 1) {
380
- return formats;
381
- }
382
- const expanded = [];
383
- for (const format of formats) {
384
- if (expandInputs.has(format)) {
385
- if (format !== 'umd') {
386
- for (const input of inputs) {
387
- expanded.push(`${format}.${input}`);
388
- }
389
- }
390
- else {
391
- for (const input of config.umdInputs) {
392
- expanded.push(`${format}../${config.sourceDir}/${input}.ts`);
393
- }
394
- }
395
- }
396
- else {
397
- expanded.push(format);
398
- }
399
- }
400
- return expanded;
401
- }
268
+ const fileNamePatterns = {
269
+ 'es': '[name].mjs',
270
+ 'cjs': '[name].cjs',
271
+ 'umd': '[name].umd.js',
272
+ };
273
+ async function getRollupConfigs([provider, plugins$1], inputs, config, helpers) {
274
+ for (const factory of plugins) {
275
+ await factory(provider, config, inputs);
276
+ }
277
+ const expandInputs = new Set;
278
+ for (const plugin of plugins$1) {
279
+ if (plugin.format && plugin.inputs?.length && !plugin.outputPlugin) {
280
+ for (const format of toArray(plugin.format)) {
281
+ expandInputs.add(format);
282
+ }
283
+ }
284
+ }
285
+ const refineNext = refiner();
286
+ refineNext(doExpandInputs(toArray(config.formats)));
287
+ for (const plugin of plugins$1) {
288
+ if (plugin.format && !plugin.outputPlugin) {
289
+ const formats = toArray(plugin.format);
290
+ if (!plugin.inputs || plugin.inputs.length === 0) {
291
+ refineNext(doExpandInputs(formats));
292
+ }
293
+ else {
294
+ if (inputs.length === 1) {
295
+ refineNext(formats);
296
+ }
297
+ else {
298
+ const expanded = [];
299
+ for (const format of formats) {
300
+ for (const input of plugin.inputs) {
301
+ expanded.push(`${format}.${input}`);
302
+ }
303
+ }
304
+ refineNext(expanded);
305
+ }
306
+ }
307
+ }
308
+ }
309
+ const refined = refineNext();
310
+ const partitions = [];
311
+ for (const partition of refined) {
312
+ const result = [];
313
+ for (const format of partition) {
314
+ if (format.includes('.')) {
315
+ const [, realFormat, input] = format.split(/(.*?)\.(.*)/gm);
316
+ result.push({ format: realFormat, input });
317
+ }
318
+ else {
319
+ result.push({ format });
320
+ }
321
+ }
322
+ const mapFormatInputs = new Map;
323
+ const formatsWithoutInputs = new Set;
324
+ for (const { format, input } of result) {
325
+ if (input) {
326
+ if (mapFormatInputs.has(format)) {
327
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
328
+ mapFormatInputs.get(format).add(input);
329
+ }
330
+ else {
331
+ mapFormatInputs.set(format, new Set([input]));
332
+ }
333
+ }
334
+ else {
335
+ formatsWithoutInputs.add(format);
336
+ }
337
+ }
338
+ for (const format of formatsWithoutInputs) {
339
+ if (mapFormatInputs.has(format)) {
340
+ throw new Error(`${format} is both used with inputs and without in plugins configuration and was not expanded / handled correctly. Please file an issue for pkgbld.`);
341
+ }
342
+ mapFormatInputs.set(format, new Set(inputs));
343
+ }
344
+ let prevInputs;
345
+ for (const inputs of mapFormatInputs.values()) {
346
+ if (prevInputs) {
347
+ if (!areSetsEqual(inputs, prevInputs)) {
348
+ throw new Error(`unbalanced inputs for partition: ${JSON.stringify(partition)}`);
349
+ }
350
+ }
351
+ prevInputs = inputs;
352
+ }
353
+ partitions.push({ formats: [...mapFormatInputs.keys()], inputs: [...prevInputs] });
354
+ }
355
+ return partitions.map(({ formats, inputs }) => {
356
+ return {
357
+ input: inputs,
358
+ output: formats.map(format => ({
359
+ format,
360
+ dir: config.dir,
361
+ entryFileNames: fileNamePatterns[format],
362
+ plugins: getPlugins([format], inputs, true),
363
+ sourcemap: config.sourcemapFormats.includes(format),
364
+ ...getExtraOutputSettings(format, inputs)
365
+ })),
366
+ plugins: getPlugins(formats, inputs, false)
367
+ };
368
+ });
369
+ function getExtraOutputSettings(format, inputs) {
370
+ switch (format) {
371
+ case 'cjs':
372
+ case 'es':
373
+ return { chunkFileNames: fileNamePatterns[format] };
374
+ case 'umd':
375
+ if (inputs.length <= 0) {
376
+ break;
377
+ }
378
+ if (inputs.length > 1) {
379
+ throw new Error(`Cannot produce global name for mutliple umd inputs in one output: ${inputs}`);
380
+ }
381
+ return {
382
+ name: helpers.getGlobalName(inputs[0]),
383
+ globals: helpers.getExternalGlobalName,
384
+ };
385
+ }
386
+ return {};
387
+ }
388
+ function getPlugins(formats, inputs, outputPlugin) {
389
+ const filteredPlugins = [];
390
+ for (const plugin of plugins$1) {
391
+ if ((!!plugin.outputPlugin) === outputPlugin) {
392
+ if ((!plugin.format || toArray(plugin.format).some(format => formats.includes(format)))
393
+ && (!plugin.inputs || plugin.inputs.every(input => inputs.includes(input)))) {
394
+ filteredPlugins.push({
395
+ instance: plugin.plugin(),
396
+ priority: plugin.priority
397
+ });
398
+ }
399
+ }
400
+ }
401
+ filteredPlugins.sort((a, b) => a.priority - b.priority);
402
+ return filteredPlugins.map(plugin => plugin.instance);
403
+ }
404
+ function doExpandInputs(formats) {
405
+ if (inputs.length === 1) {
406
+ return formats;
407
+ }
408
+ const expanded = [];
409
+ for (const format of formats) {
410
+ if (expandInputs.has(format)) {
411
+ if (format !== 'umd') {
412
+ for (const input of inputs) {
413
+ expanded.push(`${format}.${input}`);
414
+ }
415
+ }
416
+ else {
417
+ for (const input of config.umdInputs) {
418
+ expanded.push(`${format}../${config.sourceDir}/${input}.ts`);
419
+ }
420
+ }
421
+ }
422
+ else {
423
+ expanded.push(format);
424
+ }
425
+ }
426
+ return expanded;
427
+ }
402
428
  }
403
429
 
404
430
  const mainLoggerText = (sourceDir, dir, configsCount, startingTime, finishedCount = 0) => (final = false) => `${sourceDir} → ${dir} ${final ? configsCount : finishedCount++} / ${configsCount}${final ? (' in ' + getTimeDiff(startingTime)) : ''}`;
405
431
 
406
- function processPackage(pkg, config) {
407
- var _a;
408
- const input = [];
409
- const logger$1 = logger.createLogger();
410
- const allowEsm = (config.formatsOverriden && config.formats.includes('es') || !config.formatsOverriden);
411
- const allowCjs = (config.formatsOverriden && config.formats.includes('cjs') || !config.formatsOverriden);
412
- const allowUmd = (config.formatsOverriden && config.formats.includes('umd') || !config.formatsOverriden || config.umdInputs);
413
- if (typeof pkg !== 'object' || Array.isArray(pkg)) {
414
- logger$1.finish('expecting object on top level of package.json', 3 /* LogLevel.error */);
415
- process.exit(-1);
416
- }
417
- if (typeof (pkg === null || pkg === void 0 ? void 0 : pkg.name) !== 'string') {
418
- logger$1.finish('expecting name to be a string in package.json', 3 /* LogLevel.error */);
419
- process.exit(-1);
420
- }
421
- if (!Array.isArray(pkg === null || pkg === void 0 ? void 0 : pkg.files)) {
422
- pkg.files = [];
423
- }
424
- if (!pkg.files.includes(config.dir)) {
425
- pkg.files.push(config.dir);
426
- }
427
- if (typeof pkg.exports !== 'object' && pkg.exports !== null) {
428
- pkg.exports = {};
429
- }
430
- if (pkg.exports['.'] == null) {
431
- pkg.exports['.'] = {};
432
- }
433
- pkg.exports['./package.json'] = './package.json';
434
- if (allowUmd && typeof pkg.umd === 'string') {
435
- pkg.umd = `./${config.dir}/index.umd.js`;
436
- if (!config.umdInputs.includes('index')) {
437
- config.umdInputs.push('index');
438
- }
439
- }
440
- if (config.bin) {
441
- if (config.bin.length > 0) {
442
- if (config.bin[0] === '') {
443
- delete pkg.bin;
444
- }
445
- else {
446
- pkg.bin = config.bin[0];
447
- }
448
- config.bin = config.bin.filter(Boolean);
449
- if (config.bin.length === 0) {
450
- delete config.bin;
451
- }
452
- }
453
- }
454
- else {
455
- if (typeof pkg.bin === 'string') {
456
- config.bin = [pkg.bin];
457
- }
458
- else {
459
- delete pkg.bin;
460
- }
461
- }
462
- if (allowCjs && typeof pkg.main !== 'string') {
463
- pkg.main = `./${config.dir}/index.cjs`;
464
- }
465
- if (allowCjs && pkg.main !== pkg.exports['.'].require) {
466
- pkg.exports['.'].require = pkg.main;
467
- }
468
- if (allowEsm && typeof pkg.module !== 'string') {
469
- pkg.module = `./${config.dir}/index.mjs`;
470
- }
471
- if (allowEsm && pkg.module !== ((_a = pkg.exports['.']) === null || _a === void 0 ? void 0 : _a.default)) {
472
- pkg.exports['.'].default = pkg.module;
473
- }
474
- if (allowUmd && config.umdInputs.includes('index')) {
475
- pkg.unpkg = `./${config.dir}/index.umd.js`;
476
- }
477
- for (const id in pkg.exports) {
478
- if (id === './package.json')
479
- continue;
480
- const basename = id == '.' ? 'index' : path.basename(id);
481
- if (typeof pkg.exports[id] !== 'object') {
482
- pkg.exports[id] = {};
483
- }
484
- if (allowCjs) {
485
- pkg.exports[id].require = `./${config.dir}/${basename}.cjs`;
486
- }
487
- if (allowEsm) {
488
- pkg.exports[id].default = `./${config.dir}/${basename}.mjs`;
489
- }
490
- if (basename !== 'index') {
491
- if (!pkg.files.includes(basename)) {
492
- pkg.files.push(basename);
493
- }
494
- }
495
- input.push(`./${config.sourceDir}/${basename}.ts`);
496
- }
497
- if (allowUmd && config.umdInputs.length > 0 && !config.formats.includes('umd')) {
498
- config.formats.push('umd');
499
- }
500
- return input;
432
+ function processPackage(pkg, config) {
433
+ const input = [];
434
+ const logger$1 = logger.createLogger();
435
+ const allowEsm = (config.formatsOverriden && config.formats.includes('es') || !config.formatsOverriden);
436
+ const allowCjs = (config.formatsOverriden && config.formats.includes('cjs') || !config.formatsOverriden);
437
+ const allowUmd = (config.formatsOverriden && config.formats.includes('umd') || !config.formatsOverriden || config.umdInputs);
438
+ if (typeof pkg !== 'object' || Array.isArray(pkg)) {
439
+ logger$1.finish('expecting object on top level of package.json', 3 /* LogLevel.error */);
440
+ process.exit(-1);
441
+ }
442
+ if (typeof pkg?.name !== 'string') {
443
+ logger$1.finish('expecting name to be a string in package.json', 3 /* LogLevel.error */);
444
+ process.exit(-1);
445
+ }
446
+ if (!Array.isArray(pkg?.files)) {
447
+ pkg.files = [];
448
+ }
449
+ if (!pkg.files.includes(config.dir)) {
450
+ pkg.files.push(config.dir);
451
+ }
452
+ if (typeof pkg.exports !== 'object' && pkg.exports !== null) {
453
+ pkg.exports = {};
454
+ }
455
+ if (pkg.exports['.'] == null) {
456
+ pkg.exports['.'] = {};
457
+ }
458
+ pkg.exports['./package.json'] = './package.json';
459
+ if (allowUmd && typeof pkg.umd === 'string') {
460
+ pkg.umd = `./${config.dir}/index.umd.js`;
461
+ if (!config.umdInputs.includes('index')) {
462
+ config.umdInputs.push('index');
463
+ }
464
+ }
465
+ if (config.bin) {
466
+ if (config.bin.length > 0) {
467
+ if (config.bin[0] === '') {
468
+ delete pkg.bin;
469
+ }
470
+ else {
471
+ pkg.bin = config.bin[0];
472
+ }
473
+ config.bin = config.bin.filter(Boolean);
474
+ if (config.bin.length === 0) {
475
+ delete config.bin;
476
+ }
477
+ }
478
+ }
479
+ else {
480
+ if (typeof pkg.bin === 'string') {
481
+ config.bin = [pkg.bin];
482
+ }
483
+ else {
484
+ delete pkg.bin;
485
+ }
486
+ }
487
+ if (allowCjs && typeof pkg.main !== 'string') {
488
+ pkg.main = `./${config.dir}/index.cjs`;
489
+ }
490
+ if (allowCjs && pkg.main !== pkg.exports['.'].require) {
491
+ pkg.exports['.'].require = pkg.main;
492
+ }
493
+ if (allowEsm && typeof pkg.module !== 'string') {
494
+ pkg.module = `./${config.dir}/index.mjs`;
495
+ }
496
+ if (allowEsm && pkg.module !== pkg.exports['.']?.default) {
497
+ pkg.exports['.'].default = pkg.module;
498
+ }
499
+ if (allowUmd && config.umdInputs.includes('index')) {
500
+ pkg.unpkg = `./${config.dir}/index.umd.js`;
501
+ }
502
+ for (const id in pkg.exports) {
503
+ if (id === './package.json')
504
+ continue;
505
+ const basename = id == '.' ? 'index' : path.basename(id);
506
+ if (typeof pkg.exports[id] !== 'object') {
507
+ pkg.exports[id] = {};
508
+ }
509
+ if (allowCjs) {
510
+ pkg.exports[id].require = `./${config.dir}/${basename}.cjs`;
511
+ }
512
+ if (allowEsm) {
513
+ pkg.exports[id].default = `./${config.dir}/${basename}.mjs`;
514
+ }
515
+ if (basename !== 'index') {
516
+ if (!pkg.files.includes(basename)) {
517
+ pkg.files.push(basename);
518
+ }
519
+ }
520
+ input.push(`./${config.sourceDir}/${basename}.ts`);
521
+ }
522
+ if (allowUmd && config.umdInputs.length > 0 && !config.formats.includes('umd')) {
523
+ config.formats.push('umd');
524
+ }
525
+ return input;
501
526
  }
502
527
 
503
- async function writePackage(pkgPath, pkg) {
504
- await fs.writeFile(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
528
+ async function writeJson(path, json) {
529
+ await fs.writeFile(path, JSON.stringify(json, null, 2) + '\n');
505
530
  }
506
531
 
507
- async function execute() {
508
- const time = Date.now();
509
- const blank = logger.createLogger();
510
- blank.update(' ');
511
- const mainLogger = logger.createLogger();
512
- mainLogger.update('preparing...');
513
- try {
514
- const [pkgPath, pkg] = await getPackage();
515
- const options = getCliOptions();
516
- const inputs = processPackage(pkg, options);
517
- const helpers = getHelpers(pkg.name);
518
- const rollupConfigs = await getRollupConfigs(inputs, options, helpers);
519
- const updater = mainLoggerText(options.sourceDir, options.dir, rollupConfigs.length, time);
520
- mainLogger.start(updater());
521
- await Promise.all(rollupConfigs.map(config => buildConfig(config, updater)));
522
- await writePackage(pkgPath, pkg);
523
- await createSubpackages(inputs, options);
524
- mainLogger.finish(updater(true));
525
- }
526
- catch (e) {
527
- mainLogger.finish(`${e}}`, 3 /* LogLevel.error */);
528
- process.exit(-1);
529
- }
530
- async function buildConfig(config, updater) {
531
- const bundle = await rollup.rollup(config);
532
- await Promise.all(toArray(config.output).map(config => bundle.write(config)));
533
- await bundle.close();
534
- mainLogger(`${kleur.green('✓')} ${formatInput(config.input)} [${formatOutput(config.output, 'format')}]`);
535
- mainLogger.update(updater());
536
- }
537
- }
532
+ const imports = new Map;
533
+ const setup = new Set;
534
+ let generate, generateGlobals;
535
+ async function createEjectProvider() {
536
+ const createMockProvider = (await import('@slimlib/smart-mock')).default;
537
+ const provider = createMockProvider();
538
+ const createMock = provider.createMock;
539
+ generate = provider.generate;
540
+ generateGlobals = provider.generateGlobals;
541
+ const plugins = [];
542
+ return [{
543
+ provide: (plugin, priority, options) => {
544
+ plugins.push({ priority, plugin, format: options?.format, inputs: options?.inputs, outputPlugin: options?.outputPlugin });
545
+ },
546
+ import: async (name, exportName) => {
547
+ const result = await import(name);
548
+ const exports = result[exportName ?? 'default'];
549
+ const mangledName = lodash.camelCase(name);
550
+ imports.set(name, mangledName);
551
+ return createMock(exports, mangledName);
552
+ },
553
+ globalImport: (module, exportName) => {
554
+ imports.set(module, exportName ?? 'default');
555
+ },
556
+ // eslint-disable-next-line @typescript-eslint/ban-types
557
+ globalSetupt: (code) => {
558
+ if (typeof code === 'function') {
559
+ setup.add(code.toString());
560
+ }
561
+ setup.add(String(code));
562
+ }
563
+ }, plugins];
564
+ }
565
+ async function ejectConfig(config, pkgPath, options, inputs, helpers, pkg) {
566
+ const pkgName = pkg.name;
567
+ // generate from config
568
+ const text = generate(config);
569
+ setup.add(generateGlobals());
570
+ // generate globals for config functions
571
+ setup.add(`const config = ${generate(options)}`);
572
+ setup.add(`const inputs = ${generate(inputs)}`);
573
+ // generate helpers code
574
+ if (options.formats.includes('umd')) {
575
+ imports.set('path', 'path');
576
+ imports.set('lodash/camelCase', 'camelCase');
577
+ setup.add(`const pkgName = ${generate(pkgName)}`);
578
+ setup.add(helpers.getGlobalName.toString());
579
+ }
580
+ // imports
581
+ const importsString = Array.from(imports)
582
+ .map((value) => `import ${value[1]} from '${value[0]}';`)
583
+ .join('\n');
584
+ const setupString = Array.from(setup)
585
+ .join('\n');
586
+ const { minify } = await import('terser');
587
+ const result = await minify(`${importsString}\n${setupString}\nexport default ${text};`, {
588
+ module: true,
589
+ compress: {
590
+ booleans: false,
591
+ ecma: 2020,
592
+ module: true,
593
+ passes: 3,
594
+ unsafe: true
595
+ },
596
+ mangle: false,
597
+ output: {
598
+ beautify: true,
599
+ ecma: 2020,
600
+ quote_style: 1
601
+ }
602
+ });
603
+ await fs.writeFile(path.join(path.dirname(pkgPath), 'rollup.config.mjs'), result.code);
604
+ // this can be improved a lot
605
+ if (typeof pkg.devDependencies !== 'object') {
606
+ pkg.devDependencies = {};
607
+ }
608
+ const devDependencies = pkg.devDependencies;
609
+ if ('pkgbld' in devDependencies) {
610
+ delete devDependencies.pkgbld;
611
+ }
612
+ devDependencies['rollup'] = '*';
613
+ const isBuiltin = (await import('is-builtin-module')).default;
614
+ for (const key of imports.keys()) {
615
+ if (!isBuiltin(key)) {
616
+ devDependencies[key] = '*';
617
+ }
618
+ }
619
+ }
620
+
621
+ const defaultTsConfig = {
622
+ include: ['src', 'types'],
623
+ compilerOptions: {
624
+ lib: ['dom', 'esnext'],
625
+ target: 'esnext',
626
+ module: 'esnext',
627
+ esModuleInterop: true,
628
+ strict: true,
629
+ declaration: true,
630
+ moduleResolution: 'node'
631
+ }
632
+ };
633
+ async function checkTsConfig(options, mainLogger) {
634
+ if (options.noTsConfig) {
635
+ return;
636
+ }
637
+ const tsConfigPath = path.resolve('tsconfig.json');
638
+ if (fs$1.existsSync(tsConfigPath)) {
639
+ return;
640
+ }
641
+ mainLogger('no tsconfig.json and --no-ts-config not specified, writing tsconfig...');
642
+ await writeJson(tsConfigPath, defaultTsConfig);
643
+ mainLogger('done');
644
+ }
645
+
646
+ async function execute() {
647
+ const time = Date.now();
648
+ logger.createLogger().update(' '); // blank line
649
+ const mainLogger = logger.createLogger();
650
+ mainLogger.update('preparing...');
651
+ try {
652
+ const [pkgPath, pkg] = await getPackage();
653
+ const options = getCliOptions();
654
+ checkTsConfig(options, mainLogger);
655
+ const inputs = processPackage(pkg, options);
656
+ const helpers = getHelpers(pkg.name);
657
+ const provider = options.eject ? await createEjectProvider() : createProvider();
658
+ const rollupConfigs = await getRollupConfigs(provider, inputs, options, helpers);
659
+ if (options.eject) {
660
+ await ejectConfig(rollupConfigs, pkgPath, options, inputs, helpers, pkg);
661
+ mainLogger.finish(`ejected config in ${getTimeDiff(time)}`);
662
+ if (!options.noUpdatePackageJson) {
663
+ await writeJson(pkgPath, pkg);
664
+ }
665
+ }
666
+ else {
667
+ const updater = mainLoggerText(options.sourceDir, options.dir, rollupConfigs.length, time);
668
+ mainLogger.start(updater());
669
+ await Promise.all(rollupConfigs.map(config => buildConfig(config, updater)));
670
+ if (!options.noUpdatePackageJson) {
671
+ await writeJson(pkgPath, pkg);
672
+ }
673
+ await createSubpackages(inputs, options);
674
+ mainLogger.finish(updater(true));
675
+ }
676
+ }
677
+ catch (e) {
678
+ console.log(e);
679
+ mainLogger.finish(`${e}}`, 3 /* LogLevel.error */);
680
+ process.exit(-1);
681
+ }
682
+ async function buildConfig(config, updater) {
683
+ const bundle = await rollup.rollup(config);
684
+ await Promise.all(toArray(config.output).map(config => bundle.write(config)));
685
+ await bundle.close();
686
+ mainLogger(`${kleur.green('✓')} ${formatInput(config.input)} [${formatOutput(config.output, 'format')}]`);
687
+ mainLogger.update(updater());
688
+ }
689
+ }
538
690
  execute();