1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const tslib_1 = require("tslib");
|
4 | const fs = tslib_1.__importStar(require("fs-extra"));
|
5 | const jpjs_1 = require("jpjs");
|
6 | const constants_1 = require("./constants");
|
7 | const createRollupConfig_1 = require("./createRollupConfig");
|
8 |
|
9 | let tsdxConfig = {
|
10 | rollup(config, _options) {
|
11 | return config;
|
12 | },
|
13 | };
|
14 | if (fs.existsSync(constants_1.paths.appConfig)) {
|
15 | tsdxConfig = require(constants_1.paths.appConfig);
|
16 | }
|
17 | async function createBuildConfigs(opts) {
|
18 | const allInputs = jpjs_1.concatAllArray(opts.input.map((input) => createAllFormats(opts, input).map((options, index) => (Object.assign(Object.assign({}, options), {
|
19 |
|
20 |
|
21 | writeMeta: index === 0 })))));
|
22 | return await Promise.all(allInputs.map(async (options, index) => {
|
23 |
|
24 | const config = await createRollupConfig_1.createRollupConfig(options, index);
|
25 | return tsdxConfig.rollup(config, options);
|
26 | }));
|
27 | }
|
28 | exports.createBuildConfigs = createBuildConfigs;
|
29 | function createAllFormats(opts, input) {
|
30 | return [
|
31 | opts.format.includes('cjs') && Object.assign(Object.assign({}, opts), { format: 'cjs', env: 'development', input }),
|
32 | opts.format.includes('cjs') && Object.assign(Object.assign({}, opts), { format: 'cjs', env: 'production', input }),
|
33 | opts.format.includes('esm') && Object.assign(Object.assign({}, opts), { format: 'esm', input }),
|
34 | opts.format.includes('umd') && Object.assign(Object.assign({}, opts), { format: 'umd', env: 'development', input }),
|
35 | opts.format.includes('umd') && Object.assign(Object.assign({}, opts), { format: 'umd', env: 'production', input }),
|
36 | opts.format.includes('system') && Object.assign(Object.assign({}, opts), { format: 'system', env: 'development', input }),
|
37 | opts.format.includes('system') && Object.assign(Object.assign({}, opts), { format: 'system', env: 'production', input }),
|
38 | ].filter(Boolean);
|
39 | }
|