@storm-software/unbuild 0.22.0 → 0.23.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 +1 -1
- package/bin/unbuild.js +184 -1599
- package/bin/unbuild.mjs +184 -1595
- package/dist/build.d.mts +1 -0
- package/dist/build.d.ts +1 -0
- package/dist/build.js +10 -10
- package/dist/build.mjs +1 -1
- package/dist/chunk-3GQAWCBQ.js +13 -0
- package/dist/{chunk-E73BVQF5.js → chunk-3OJD7CO4.js} +5 -5
- package/dist/chunk-AW52DUNE.mjs +1043 -0
- package/dist/chunk-AYRYNROK.js +27 -0
- package/dist/{chunk-B2WY6JG2.js → chunk-DFIGNXGY.js} +1035 -1035
- package/dist/{chunk-UUI4UWA4.js → chunk-OQPSH7GE.js} +37 -37
- package/dist/{chunk-RUNO4F6F.js → chunk-RCEWRXM5.js} +2 -2
- package/dist/chunk-T2OTJN2D.js +1043 -0
- package/dist/{chunk-BMAXMHJB.js → chunk-WPOEGALQ.js} +5 -5
- package/dist/{chunk-6KE6SIPQ.js → chunk-XEAFTDQ7.js} +5 -5
- package/dist/clean.js +4 -4
- package/dist/config.d.mts +1 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.js +8 -8
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +10 -10
- package/dist/index.mjs +1 -1
- package/dist/types.d.mts +2 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.js +0 -1
- package/package.json +190 -1
- package/dist/chunk-2Q67L63A.js +0 -2456
- package/dist/chunk-4WKFVYTI.js +0 -18
- package/dist/chunk-J5YBLOB7.js +0 -27
- package/dist/chunk-SGIQJ2OU.mjs +0 -2455
package/dist/chunk-2Q67L63A.js
DELETED
|
@@ -1,2456 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
-
|
|
3
|
-
var _chunkE73BVQF5js = require('./chunk-E73BVQF5.js');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _chunkJ5YBLOB7js = require('./chunk-J5YBLOB7.js');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _chunkB2WY6JG2js = require('./chunk-B2WY6JG2.js');
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
var _chunkUUI4UWA4js = require('./chunk-UUI4UWA4.js');
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var _chunk4WKFVYTIjs = require('./chunk-4WKFVYTI.js');
|
|
37
|
-
|
|
38
|
-
// src/build.ts
|
|
39
|
-
var _devkit = require('@nx/devkit');
|
|
40
|
-
var _js = require('@nx/js');
|
|
41
|
-
var _buildablelibsutils = require('@nx/js/src/utils/buildable-libs-utils');
|
|
42
|
-
|
|
43
|
-
// ../build-tools/src/plugins/swc.ts
|
|
44
|
-
var _core = require('@swc/core');
|
|
45
|
-
|
|
46
|
-
// ../build-tools/src/plugins/ts-resolve.ts
|
|
47
|
-
var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
|
|
48
|
-
var _module = require('module'); var _module2 = _interopRequireDefault(_module);
|
|
49
|
-
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
50
|
-
var _resolve2 = require('resolve'); var _resolve3 = _interopRequireDefault(_resolve2);
|
|
51
|
-
|
|
52
|
-
// ../build-tools/src/plugins/type-definitions.ts
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
// ../build-tools/src/utilities/copy-assets.ts
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
var _glob = require('glob');
|
|
60
|
-
var _promises = require('fs/promises'); var _promises2 = _interopRequireDefault(_promises);
|
|
61
|
-
|
|
62
|
-
// ../config-tools/src/config-file/get-config-file.ts
|
|
63
|
-
var _c12 = require('c12');
|
|
64
|
-
var _defu = require('defu'); var _defu2 = _interopRequireDefault(_defu);
|
|
65
|
-
var getConfigFileByName = /* @__PURE__ */ _chunk4WKFVYTIjs.__name.call(void 0, async (fileName, filePath, options = {}) => {
|
|
66
|
-
const workspacePath = filePath || _chunkUUI4UWA4js.findWorkspaceRoot.call(void 0, filePath);
|
|
67
|
-
let config = await _c12.loadConfig.call(void 0, {
|
|
68
|
-
cwd: workspacePath,
|
|
69
|
-
packageJson: true,
|
|
70
|
-
name: fileName,
|
|
71
|
-
envName: _optionalChain([fileName, 'optionalAccess', _2 => _2.toUpperCase, 'call', _3 => _3()]),
|
|
72
|
-
jitiOptions: {
|
|
73
|
-
debug: false,
|
|
74
|
-
fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : _chunkUUI4UWA4js.joinPaths.call(void 0, process.env.STORM_CACHE_DIR || "node_modules/.cache/storm", "config")
|
|
75
|
-
},
|
|
76
|
-
...options
|
|
77
|
-
});
|
|
78
|
-
if (!config || Object.keys(config).length === 0) {
|
|
79
|
-
config = await _c12.loadConfig.call(void 0, {
|
|
80
|
-
cwd: workspacePath,
|
|
81
|
-
packageJson: true,
|
|
82
|
-
name: fileName,
|
|
83
|
-
envName: _optionalChain([fileName, 'optionalAccess', _4 => _4.toUpperCase, 'call', _5 => _5()]),
|
|
84
|
-
jitiOptions: {
|
|
85
|
-
debug: false,
|
|
86
|
-
fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : _chunkUUI4UWA4js.joinPaths.call(void 0, process.env.STORM_CACHE_DIR || "node_modules/.cache/storm", "config")
|
|
87
|
-
},
|
|
88
|
-
configFile: fileName,
|
|
89
|
-
...options
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
return config;
|
|
93
|
-
}, "getConfigFileByName");
|
|
94
|
-
var getConfigFile = /* @__PURE__ */ _chunk4WKFVYTIjs.__name.call(void 0, async (filePath, additionalFileNames = []) => {
|
|
95
|
-
const workspacePath = filePath ? filePath : _chunkUUI4UWA4js.findWorkspaceRoot.call(void 0, filePath);
|
|
96
|
-
const result = await getConfigFileByName("storm", workspacePath);
|
|
97
|
-
let config = result.config;
|
|
98
|
-
const configFile = result.configFile;
|
|
99
|
-
if (config && configFile && Object.keys(config).length > 0) {
|
|
100
|
-
_chunkUUI4UWA4js.writeSystem.call(void 0, `Found Storm configuration file "${configFile.includes(`${workspacePath}/`) ? configFile.replace(`${workspacePath}/`, "") : configFile}" at "${workspacePath}"`, {
|
|
101
|
-
logLevel: "all"
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
if (additionalFileNames && additionalFileNames.length > 0) {
|
|
105
|
-
const results = await Promise.all(additionalFileNames.map((fileName) => getConfigFileByName(fileName, workspacePath)));
|
|
106
|
-
for (const result2 of results) {
|
|
107
|
-
if (_optionalChain([result2, 'optionalAccess', _6 => _6.config]) && _optionalChain([result2, 'optionalAccess', _7 => _7.configFile]) && Object.keys(result2.config).length > 0) {
|
|
108
|
-
_chunkUUI4UWA4js.writeSystem.call(void 0, `Found alternative configuration file "${result2.configFile.includes(`${workspacePath}/`) ? result2.configFile.replace(`${workspacePath}/`, "") : result2.configFile}" at "${workspacePath}"`, {
|
|
109
|
-
logLevel: "all"
|
|
110
|
-
});
|
|
111
|
-
config = _defu2.default.call(void 0, _nullishCoalesce(result2.config, () => ( {})), _nullishCoalesce(config, () => ( {})));
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
if (!config) {
|
|
116
|
-
return void 0;
|
|
117
|
-
}
|
|
118
|
-
config.configFile = configFile;
|
|
119
|
-
return config;
|
|
120
|
-
}, "getConfigFile");
|
|
121
|
-
|
|
122
|
-
// ../config-tools/src/create-storm-config.ts
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
// ../config-tools/src/env/get-env.ts
|
|
126
|
-
var getConfigEnv = /* @__PURE__ */ _chunk4WKFVYTIjs.__name.call(void 0, () => {
|
|
127
|
-
const prefix = "STORM_";
|
|
128
|
-
let config = {
|
|
129
|
-
extends: process.env[`${prefix}EXTENDS`] || void 0,
|
|
130
|
-
name: process.env[`${prefix}NAME`] || void 0,
|
|
131
|
-
namespace: process.env[`${prefix}NAMESPACE`] || void 0,
|
|
132
|
-
owner: process.env[`${prefix}OWNER`] || void 0,
|
|
133
|
-
bot: {
|
|
134
|
-
name: process.env[`${prefix}BOT_NAME`] || void 0,
|
|
135
|
-
email: process.env[`${prefix}BOT_EMAIL`] || void 0
|
|
136
|
-
},
|
|
137
|
-
organization: process.env[`${prefix}ORGANIZATION`] || void 0,
|
|
138
|
-
packageManager: process.env[`${prefix}PACKAGE_MANAGER`] || void 0,
|
|
139
|
-
license: process.env[`${prefix}LICENSE`] || void 0,
|
|
140
|
-
homepage: process.env[`${prefix}HOMEPAGE`] || void 0,
|
|
141
|
-
docs: process.env[`${prefix}DOCS`] || void 0,
|
|
142
|
-
licensing: process.env[`${prefix}LICENSING`] || void 0,
|
|
143
|
-
timezone: process.env[`${prefix}TIMEZONE`] || process.env.TZ || void 0,
|
|
144
|
-
locale: process.env[`${prefix}LOCALE`] || process.env.LOCALE || void 0,
|
|
145
|
-
configFile: process.env[`${prefix}CONFIG_FILE`] ? _chunkUUI4UWA4js.correctPaths.call(void 0, process.env[`${prefix}CONFIG_FILE`]) : void 0,
|
|
146
|
-
workspaceRoot: process.env[`${prefix}WORKSPACE_ROOT`] ? _chunkUUI4UWA4js.correctPaths.call(void 0, process.env[`${prefix}WORKSPACE_ROOT`]) : void 0,
|
|
147
|
-
directories: {
|
|
148
|
-
cache: process.env[`${prefix}CACHE_DIR`] ? _chunkUUI4UWA4js.correctPaths.call(void 0, process.env[`${prefix}CACHE_DIR`]) : void 0,
|
|
149
|
-
data: process.env[`${prefix}DATA_DIR`] ? _chunkUUI4UWA4js.correctPaths.call(void 0, process.env[`${prefix}DATA_DIR`]) : void 0,
|
|
150
|
-
config: process.env[`${prefix}CONFIG_DIR`] ? _chunkUUI4UWA4js.correctPaths.call(void 0, process.env[`${prefix}CONFIG_DIR`]) : void 0,
|
|
151
|
-
temp: process.env[`${prefix}TEMP_DIR`] ? _chunkUUI4UWA4js.correctPaths.call(void 0, process.env[`${prefix}TEMP_DIR`]) : void 0,
|
|
152
|
-
log: process.env[`${prefix}LOG_DIR`] ? _chunkUUI4UWA4js.correctPaths.call(void 0, process.env[`${prefix}LOG_DIR`]) : void 0,
|
|
153
|
-
build: process.env[`${prefix}BUILD_DIR`] ? _chunkUUI4UWA4js.correctPaths.call(void 0, process.env[`${prefix}BUILD_DIR`]) : void 0
|
|
154
|
-
},
|
|
155
|
-
skipCache: process.env[`${prefix}SKIP_CACHE`] !== void 0 ? Boolean(process.env[`${prefix}SKIP_CACHE`]) : void 0,
|
|
156
|
-
env: (_nullishCoalesce(_nullishCoalesce(process.env[`${prefix}ENV`], () => ( process.env.NODE_ENV)), () => ( process.env.ENVIRONMENT))) || void 0,
|
|
157
|
-
// ci:
|
|
158
|
-
// process.env[`${prefix}CI`] !== undefined
|
|
159
|
-
// ? Boolean(
|
|
160
|
-
// process.env[`${prefix}CI`] ??
|
|
161
|
-
// process.env.CI ??
|
|
162
|
-
// process.env.CONTINUOUS_INTEGRATION
|
|
163
|
-
// )
|
|
164
|
-
// : undefined,
|
|
165
|
-
repository: process.env[`${prefix}REPOSITORY`] || void 0,
|
|
166
|
-
branch: process.env[`${prefix}BRANCH`] || void 0,
|
|
167
|
-
preid: process.env[`${prefix}PRE_ID`] || void 0,
|
|
168
|
-
externalPackagePatterns: process.env[`${prefix}EXTERNAL_PACKAGE_PATTERNS`] ? JSON.parse(process.env[`${prefix}EXTERNAL_PACKAGE_PATTERNS`]) : [],
|
|
169
|
-
registry: {
|
|
170
|
-
github: process.env[`${prefix}REGISTRY_GITHUB`] || void 0,
|
|
171
|
-
npm: process.env[`${prefix}REGISTRY_NPM`] || void 0,
|
|
172
|
-
cargo: process.env[`${prefix}REGISTRY_CARGO`] || void 0,
|
|
173
|
-
cyclone: process.env[`${prefix}REGISTRY_CYCLONE`] || void 0,
|
|
174
|
-
container: process.env[`${prefix}REGISTRY_CONTAINER`] || void 0
|
|
175
|
-
},
|
|
176
|
-
logLevel: process.env[`${prefix}LOG_LEVEL`] !== null && process.env[`${prefix}LOG_LEVEL`] !== void 0 ? process.env[`${prefix}LOG_LEVEL`] && Number.isSafeInteger(Number.parseInt(process.env[`${prefix}LOG_LEVEL`])) ? _chunkUUI4UWA4js.getLogLevelLabel.call(void 0, Number.parseInt(process.env[`${prefix}LOG_LEVEL`])) : process.env[`${prefix}LOG_LEVEL`] : void 0
|
|
177
|
-
};
|
|
178
|
-
const themeNames = Object.keys(process.env).filter((envKey) => envKey.startsWith(`${prefix}COLOR_`) && _chunkUUI4UWA4js.COLOR_KEYS.every((colorKey) => !envKey.startsWith(`${prefix}COLOR_LIGHT_${colorKey}`) && !envKey.startsWith(`${prefix}COLOR_DARK_${colorKey}`)));
|
|
179
|
-
config.colors = themeNames.length > 0 ? themeNames.reduce((ret, themeName) => {
|
|
180
|
-
ret[themeName] = getThemeColorConfigEnv(prefix, themeName);
|
|
181
|
-
return ret;
|
|
182
|
-
}, {}) : getThemeColorConfigEnv(prefix);
|
|
183
|
-
if (config.docs === _chunkUUI4UWA4js.STORM_DEFAULT_DOCS) {
|
|
184
|
-
if (config.homepage === _chunkUUI4UWA4js.STORM_DEFAULT_HOMEPAGE) {
|
|
185
|
-
config.docs = `${_chunkUUI4UWA4js.STORM_DEFAULT_HOMEPAGE}/projects/${config.name}/docs`;
|
|
186
|
-
} else {
|
|
187
|
-
config.docs = `${config.homepage}/docs`;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
if (config.licensing === _chunkUUI4UWA4js.STORM_DEFAULT_LICENSING) {
|
|
191
|
-
if (config.homepage === _chunkUUI4UWA4js.STORM_DEFAULT_HOMEPAGE) {
|
|
192
|
-
config.licensing = `${_chunkUUI4UWA4js.STORM_DEFAULT_HOMEPAGE}/projects/${config.name}/licensing`;
|
|
193
|
-
} else {
|
|
194
|
-
config.licensing = `${config.homepage}/docs`;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
const serializedConfig = process.env[`${prefix}CONFIG`];
|
|
198
|
-
if (serializedConfig) {
|
|
199
|
-
const parsed = JSON.parse(serializedConfig);
|
|
200
|
-
config = {
|
|
201
|
-
...config,
|
|
202
|
-
...parsed,
|
|
203
|
-
colors: {
|
|
204
|
-
...config.colors,
|
|
205
|
-
...parsed.colors
|
|
206
|
-
},
|
|
207
|
-
extensions: {
|
|
208
|
-
...config.extensions,
|
|
209
|
-
...parsed.extensions
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
return config;
|
|
214
|
-
}, "getConfigEnv");
|
|
215
|
-
var getThemeColorConfigEnv = /* @__PURE__ */ _chunk4WKFVYTIjs.__name.call(void 0, (prefix, theme) => {
|
|
216
|
-
const themeName = `COLOR_${theme && theme !== "base" ? `${theme}_` : ""}`.toUpperCase();
|
|
217
|
-
return process.env[`${prefix}${themeName}LIGHT_BRAND`] || process.env[`${prefix}${themeName}DARK_BRAND`] ? getMultiThemeColorConfigEnv(prefix + themeName) : getSingleThemeColorConfigEnv(prefix + themeName);
|
|
218
|
-
}, "getThemeColorConfigEnv");
|
|
219
|
-
var getSingleThemeColorConfigEnv = /* @__PURE__ */ _chunk4WKFVYTIjs.__name.call(void 0, (prefix) => {
|
|
220
|
-
return {
|
|
221
|
-
dark: process.env[`${prefix}DARK`],
|
|
222
|
-
light: process.env[`${prefix}LIGHT`],
|
|
223
|
-
brand: process.env[`${prefix}BRAND`],
|
|
224
|
-
alternate: process.env[`${prefix}ALTERNATE`],
|
|
225
|
-
accent: process.env[`${prefix}ACCENT`],
|
|
226
|
-
link: process.env[`${prefix}LINK`],
|
|
227
|
-
help: process.env[`${prefix}HELP`],
|
|
228
|
-
success: process.env[`${prefix}SUCCESS`],
|
|
229
|
-
info: process.env[`${prefix}INFO`],
|
|
230
|
-
warning: process.env[`${prefix}WARNING`],
|
|
231
|
-
danger: process.env[`${prefix}DANGER`],
|
|
232
|
-
fatal: process.env[`${prefix}FATAL`],
|
|
233
|
-
positive: process.env[`${prefix}POSITIVE`],
|
|
234
|
-
negative: process.env[`${prefix}NEGATIVE`]
|
|
235
|
-
};
|
|
236
|
-
}, "getSingleThemeColorConfigEnv");
|
|
237
|
-
var getMultiThemeColorConfigEnv = /* @__PURE__ */ _chunk4WKFVYTIjs.__name.call(void 0, (prefix) => {
|
|
238
|
-
return {
|
|
239
|
-
light: getBaseThemeColorConfigEnv(`${prefix}_LIGHT_`),
|
|
240
|
-
dark: getBaseThemeColorConfigEnv(`${prefix}_DARK_`)
|
|
241
|
-
};
|
|
242
|
-
}, "getMultiThemeColorConfigEnv");
|
|
243
|
-
var getBaseThemeColorConfigEnv = /* @__PURE__ */ _chunk4WKFVYTIjs.__name.call(void 0, (prefix) => {
|
|
244
|
-
return {
|
|
245
|
-
foreground: process.env[`${prefix}FOREGROUND`],
|
|
246
|
-
background: process.env[`${prefix}BACKGROUND`],
|
|
247
|
-
brand: process.env[`${prefix}BRAND`],
|
|
248
|
-
alternate: process.env[`${prefix}ALTERNATE`],
|
|
249
|
-
accent: process.env[`${prefix}ACCENT`],
|
|
250
|
-
link: process.env[`${prefix}LINK`],
|
|
251
|
-
help: process.env[`${prefix}HELP`],
|
|
252
|
-
success: process.env[`${prefix}SUCCESS`],
|
|
253
|
-
info: process.env[`${prefix}INFO`],
|
|
254
|
-
warning: process.env[`${prefix}WARNING`],
|
|
255
|
-
danger: process.env[`${prefix}DANGER`],
|
|
256
|
-
fatal: process.env[`${prefix}FATAL`],
|
|
257
|
-
positive: process.env[`${prefix}POSITIVE`],
|
|
258
|
-
negative: process.env[`${prefix}NEGATIVE`]
|
|
259
|
-
};
|
|
260
|
-
}, "getBaseThemeColorConfigEnv");
|
|
261
|
-
|
|
262
|
-
// ../config-tools/src/env/set-env.ts
|
|
263
|
-
var setExtensionEnv = /* @__PURE__ */ _chunk4WKFVYTIjs.__name.call(void 0, (extensionName, extension) => {
|
|
264
|
-
for (const key of Object.keys(_nullishCoalesce(extension, () => ( {})))) {
|
|
265
|
-
if (extension[key]) {
|
|
266
|
-
const result = _nullishCoalesce(_optionalChain([key, 'optionalAccess', _8 => _8.replace, 'call', _9 => _9(/([A-Z])+/g, (input) => input ? _optionalChain([input, 'access', _10 => _10[0], 'optionalAccess', _11 => _11.toUpperCase, 'call', _12 => _12()]) + input.slice(1) : ""), 'access', _13 => _13.split, 'call', _14 => _14(/(?=[A-Z])|[.\-\s_]/), 'access', _15 => _15.map, 'call', _16 => _16((x) => x.toLowerCase())]), () => ( []));
|
|
267
|
-
let extensionKey;
|
|
268
|
-
if (result.length === 0) {
|
|
269
|
-
return;
|
|
270
|
-
}
|
|
271
|
-
if (result.length === 1) {
|
|
272
|
-
extensionKey = _nullishCoalesce(_optionalChain([result, 'access', _17 => _17[0], 'optionalAccess', _18 => _18.toUpperCase, 'call', _19 => _19()]), () => ( ""));
|
|
273
|
-
} else {
|
|
274
|
-
extensionKey = result.reduce((ret, part) => {
|
|
275
|
-
return `${ret}_${part.toLowerCase()}`;
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
process.env[`STORM_EXTENSION_${extensionName.toUpperCase()}_${extensionKey.toUpperCase()}`] = extension[key];
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}, "setExtensionEnv");
|
|
282
|
-
var setConfigEnv = /* @__PURE__ */ _chunk4WKFVYTIjs.__name.call(void 0, (config) => {
|
|
283
|
-
const prefix = "STORM_";
|
|
284
|
-
if (config.extends) {
|
|
285
|
-
process.env[`${prefix}EXTENDS`] = config.extends;
|
|
286
|
-
}
|
|
287
|
-
if (config.name) {
|
|
288
|
-
process.env[`${prefix}NAME`] = config.name;
|
|
289
|
-
}
|
|
290
|
-
if (config.namespace) {
|
|
291
|
-
process.env[`${prefix}NAMESPACE`] = config.namespace;
|
|
292
|
-
}
|
|
293
|
-
if (config.owner) {
|
|
294
|
-
process.env[`${prefix}OWNER`] = config.owner;
|
|
295
|
-
}
|
|
296
|
-
if (config.bot) {
|
|
297
|
-
process.env[`${prefix}BOT_NAME`] = config.bot.name;
|
|
298
|
-
process.env[`${prefix}BOT_EMAIL`] = config.bot.email;
|
|
299
|
-
}
|
|
300
|
-
if (config.organization) {
|
|
301
|
-
process.env[`${prefix}ORGANIZATION`] = config.organization;
|
|
302
|
-
}
|
|
303
|
-
if (config.packageManager) {
|
|
304
|
-
process.env[`${prefix}PACKAGE_MANAGER`] = config.packageManager;
|
|
305
|
-
}
|
|
306
|
-
if (config.license) {
|
|
307
|
-
process.env[`${prefix}LICENSE`] = config.license;
|
|
308
|
-
}
|
|
309
|
-
if (config.homepage) {
|
|
310
|
-
process.env[`${prefix}HOMEPAGE`] = config.homepage;
|
|
311
|
-
}
|
|
312
|
-
if (config.docs) {
|
|
313
|
-
process.env[`${prefix}DOCS`] = config.docs;
|
|
314
|
-
}
|
|
315
|
-
if (config.licensing) {
|
|
316
|
-
process.env[`${prefix}LICENSING`] = config.licensing;
|
|
317
|
-
}
|
|
318
|
-
if (config.timezone) {
|
|
319
|
-
process.env[`${prefix}TIMEZONE`] = config.timezone;
|
|
320
|
-
process.env.TZ = config.timezone;
|
|
321
|
-
process.env.DEFAULT_TIMEZONE = config.timezone;
|
|
322
|
-
}
|
|
323
|
-
if (config.locale) {
|
|
324
|
-
process.env[`${prefix}LOCALE`] = config.locale;
|
|
325
|
-
process.env.LOCALE = config.locale;
|
|
326
|
-
process.env.DEFAULT_LOCALE = config.locale;
|
|
327
|
-
process.env.LANG = config.locale ? `${config.locale.replaceAll("-", "_")}.UTF-8` : "en_US.UTF-8";
|
|
328
|
-
}
|
|
329
|
-
if (config.configFile) {
|
|
330
|
-
process.env[`${prefix}CONFIG_FILE`] = _chunkUUI4UWA4js.correctPaths.call(void 0, config.configFile);
|
|
331
|
-
}
|
|
332
|
-
if (config.workspaceRoot) {
|
|
333
|
-
process.env[`${prefix}WORKSPACE_ROOT`] = _chunkUUI4UWA4js.correctPaths.call(void 0, config.workspaceRoot);
|
|
334
|
-
process.env.NX_WORKSPACE_ROOT = _chunkUUI4UWA4js.correctPaths.call(void 0, config.workspaceRoot);
|
|
335
|
-
process.env.NX_WORKSPACE_ROOT_PATH = _chunkUUI4UWA4js.correctPaths.call(void 0, config.workspaceRoot);
|
|
336
|
-
}
|
|
337
|
-
if (config.directories) {
|
|
338
|
-
if (!config.skipCache && config.directories.cache) {
|
|
339
|
-
process.env[`${prefix}CACHE_DIR`] = _chunkUUI4UWA4js.correctPaths.call(void 0, config.directories.cache);
|
|
340
|
-
}
|
|
341
|
-
if (config.directories.data) {
|
|
342
|
-
process.env[`${prefix}DATA_DIR`] = _chunkUUI4UWA4js.correctPaths.call(void 0, config.directories.data);
|
|
343
|
-
}
|
|
344
|
-
if (config.directories.config) {
|
|
345
|
-
process.env[`${prefix}CONFIG_DIR`] = _chunkUUI4UWA4js.correctPaths.call(void 0, config.directories.config);
|
|
346
|
-
}
|
|
347
|
-
if (config.directories.temp) {
|
|
348
|
-
process.env[`${prefix}TEMP_DIR`] = _chunkUUI4UWA4js.correctPaths.call(void 0, config.directories.temp);
|
|
349
|
-
}
|
|
350
|
-
if (config.directories.log) {
|
|
351
|
-
process.env[`${prefix}LOG_DIR`] = _chunkUUI4UWA4js.correctPaths.call(void 0, config.directories.log);
|
|
352
|
-
}
|
|
353
|
-
if (config.directories.build) {
|
|
354
|
-
process.env[`${prefix}BUILD_DIR`] = _chunkUUI4UWA4js.correctPaths.call(void 0, config.directories.build);
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
if (config.skipCache !== void 0) {
|
|
358
|
-
process.env[`${prefix}SKIP_CACHE`] = String(config.skipCache);
|
|
359
|
-
if (config.skipCache) {
|
|
360
|
-
process.env.NX_SKIP_NX_CACHE ??= String(config.skipCache);
|
|
361
|
-
process.env.NX_CACHE_PROJECT_GRAPH ??= String(config.skipCache);
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
if (config.env) {
|
|
365
|
-
process.env[`${prefix}ENV`] = config.env;
|
|
366
|
-
process.env.NODE_ENV = config.env;
|
|
367
|
-
process.env.ENVIRONMENT = config.env;
|
|
368
|
-
}
|
|
369
|
-
if (_optionalChain([config, 'access', _20 => _20.colors, 'optionalAccess', _21 => _21.base, 'optionalAccess', _22 => _22.light]) || _optionalChain([config, 'access', _23 => _23.colors, 'optionalAccess', _24 => _24.base, 'optionalAccess', _25 => _25.dark])) {
|
|
370
|
-
for (const key of Object.keys(config.colors)) {
|
|
371
|
-
setThemeColorConfigEnv(`${prefix}COLOR_${key}_`, config.colors[key]);
|
|
372
|
-
}
|
|
373
|
-
} else {
|
|
374
|
-
setThemeColorConfigEnv(`${prefix}COLOR_`, config.colors);
|
|
375
|
-
}
|
|
376
|
-
if (config.repository) {
|
|
377
|
-
process.env[`${prefix}REPOSITORY`] = config.repository;
|
|
378
|
-
}
|
|
379
|
-
if (config.branch) {
|
|
380
|
-
process.env[`${prefix}BRANCH`] = config.branch;
|
|
381
|
-
}
|
|
382
|
-
if (config.preid) {
|
|
383
|
-
process.env[`${prefix}PRE_ID`] = String(config.preid);
|
|
384
|
-
}
|
|
385
|
-
if (config.externalPackagePatterns) {
|
|
386
|
-
process.env[`${prefix}EXTERNAL_PACKAGE_PATTERNS`] = JSON.stringify(config.externalPackagePatterns);
|
|
387
|
-
}
|
|
388
|
-
if (config.registry) {
|
|
389
|
-
if (config.registry.github) {
|
|
390
|
-
process.env[`${prefix}REGISTRY_GITHUB`] = String(config.registry.github);
|
|
391
|
-
}
|
|
392
|
-
if (config.registry.npm) {
|
|
393
|
-
process.env[`${prefix}REGISTRY_NPM`] = String(config.registry.npm);
|
|
394
|
-
}
|
|
395
|
-
if (config.registry.cargo) {
|
|
396
|
-
process.env[`${prefix}REGISTRY_CARGO`] = String(config.registry.cargo);
|
|
397
|
-
}
|
|
398
|
-
if (config.registry.cyclone) {
|
|
399
|
-
process.env[`${prefix}REGISTRY_CYCLONE`] = String(config.registry.cyclone);
|
|
400
|
-
}
|
|
401
|
-
if (config.registry.container) {
|
|
402
|
-
process.env[`${prefix}REGISTRY_CONTAINER`] = String(config.registry.cyclone);
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
if (config.logLevel) {
|
|
406
|
-
process.env[`${prefix}LOG_LEVEL`] = String(config.logLevel);
|
|
407
|
-
process.env.LOG_LEVEL = String(config.logLevel);
|
|
408
|
-
process.env.NX_VERBOSE_LOGGING = String(_chunkUUI4UWA4js.getLogLevel.call(void 0, config.logLevel) >= _chunkUUI4UWA4js.LogLevel.DEBUG ? true : false);
|
|
409
|
-
process.env.RUST_BACKTRACE = _chunkUUI4UWA4js.getLogLevel.call(void 0, config.logLevel) >= _chunkUUI4UWA4js.LogLevel.DEBUG ? "full" : "none";
|
|
410
|
-
}
|
|
411
|
-
process.env[`${prefix}CONFIG`] = JSON.stringify(config);
|
|
412
|
-
for (const key of Object.keys(_nullishCoalesce(config.extensions, () => ( {})))) {
|
|
413
|
-
config.extensions[key] && Object.keys(config.extensions[key]) && setExtensionEnv(key, config.extensions[key]);
|
|
414
|
-
}
|
|
415
|
-
}, "setConfigEnv");
|
|
416
|
-
var setThemeColorConfigEnv = /* @__PURE__ */ _chunk4WKFVYTIjs.__name.call(void 0, (prefix, config) => {
|
|
417
|
-
return _optionalChain([config, 'optionalAccess', _26 => _26.light, 'optionalAccess', _27 => _27.brand]) || _optionalChain([config, 'optionalAccess', _28 => _28.dark, 'optionalAccess', _29 => _29.brand]) ? setMultiThemeColorConfigEnv(prefix, config) : setSingleThemeColorConfigEnv(prefix, config);
|
|
418
|
-
}, "setThemeColorConfigEnv");
|
|
419
|
-
var setSingleThemeColorConfigEnv = /* @__PURE__ */ _chunk4WKFVYTIjs.__name.call(void 0, (prefix, config) => {
|
|
420
|
-
if (config.dark) {
|
|
421
|
-
process.env[`${prefix}DARK`] = config.dark;
|
|
422
|
-
}
|
|
423
|
-
if (config.light) {
|
|
424
|
-
process.env[`${prefix}LIGHT`] = config.light;
|
|
425
|
-
}
|
|
426
|
-
if (config.brand) {
|
|
427
|
-
process.env[`${prefix}BRAND`] = config.brand;
|
|
428
|
-
}
|
|
429
|
-
if (config.alternate) {
|
|
430
|
-
process.env[`${prefix}ALTERNATE`] = config.alternate;
|
|
431
|
-
}
|
|
432
|
-
if (config.accent) {
|
|
433
|
-
process.env[`${prefix}ACCENT`] = config.accent;
|
|
434
|
-
}
|
|
435
|
-
if (config.link) {
|
|
436
|
-
process.env[`${prefix}LINK`] = config.link;
|
|
437
|
-
}
|
|
438
|
-
if (config.help) {
|
|
439
|
-
process.env[`${prefix}HELP`] = config.help;
|
|
440
|
-
}
|
|
441
|
-
if (config.success) {
|
|
442
|
-
process.env[`${prefix}SUCCESS`] = config.success;
|
|
443
|
-
}
|
|
444
|
-
if (config.info) {
|
|
445
|
-
process.env[`${prefix}INFO`] = config.info;
|
|
446
|
-
}
|
|
447
|
-
if (config.warning) {
|
|
448
|
-
process.env[`${prefix}WARNING`] = config.warning;
|
|
449
|
-
}
|
|
450
|
-
if (config.danger) {
|
|
451
|
-
process.env[`${prefix}DANGER`] = config.danger;
|
|
452
|
-
}
|
|
453
|
-
if (config.fatal) {
|
|
454
|
-
process.env[`${prefix}FATAL`] = config.fatal;
|
|
455
|
-
}
|
|
456
|
-
if (config.positive) {
|
|
457
|
-
process.env[`${prefix}POSITIVE`] = config.positive;
|
|
458
|
-
}
|
|
459
|
-
if (config.negative) {
|
|
460
|
-
process.env[`${prefix}NEGATIVE`] = config.negative;
|
|
461
|
-
}
|
|
462
|
-
}, "setSingleThemeColorConfigEnv");
|
|
463
|
-
var setMultiThemeColorConfigEnv = /* @__PURE__ */ _chunk4WKFVYTIjs.__name.call(void 0, (prefix, config) => {
|
|
464
|
-
return {
|
|
465
|
-
light: setBaseThemeColorConfigEnv(`${prefix}LIGHT_`, config.light),
|
|
466
|
-
dark: setBaseThemeColorConfigEnv(`${prefix}DARK_`, config.dark)
|
|
467
|
-
};
|
|
468
|
-
}, "setMultiThemeColorConfigEnv");
|
|
469
|
-
var setBaseThemeColorConfigEnv = /* @__PURE__ */ _chunk4WKFVYTIjs.__name.call(void 0, (prefix, config) => {
|
|
470
|
-
if (config.foreground) {
|
|
471
|
-
process.env[`${prefix}FOREGROUND`] = config.foreground;
|
|
472
|
-
}
|
|
473
|
-
if (config.background) {
|
|
474
|
-
process.env[`${prefix}BACKGROUND`] = config.background;
|
|
475
|
-
}
|
|
476
|
-
if (config.brand) {
|
|
477
|
-
process.env[`${prefix}BRAND`] = config.brand;
|
|
478
|
-
}
|
|
479
|
-
if (config.alternate) {
|
|
480
|
-
process.env[`${prefix}ALTERNATE`] = config.alternate;
|
|
481
|
-
}
|
|
482
|
-
if (config.accent) {
|
|
483
|
-
process.env[`${prefix}ACCENT`] = config.accent;
|
|
484
|
-
}
|
|
485
|
-
if (config.link) {
|
|
486
|
-
process.env[`${prefix}LINK`] = config.link;
|
|
487
|
-
}
|
|
488
|
-
if (config.help) {
|
|
489
|
-
process.env[`${prefix}HELP`] = config.help;
|
|
490
|
-
}
|
|
491
|
-
if (config.success) {
|
|
492
|
-
process.env[`${prefix}SUCCESS`] = config.success;
|
|
493
|
-
}
|
|
494
|
-
if (config.info) {
|
|
495
|
-
process.env[`${prefix}INFO`] = config.info;
|
|
496
|
-
}
|
|
497
|
-
if (config.warning) {
|
|
498
|
-
process.env[`${prefix}WARNING`] = config.warning;
|
|
499
|
-
}
|
|
500
|
-
if (config.danger) {
|
|
501
|
-
process.env[`${prefix}DANGER`] = config.danger;
|
|
502
|
-
}
|
|
503
|
-
if (config.fatal) {
|
|
504
|
-
process.env[`${prefix}FATAL`] = config.fatal;
|
|
505
|
-
}
|
|
506
|
-
if (config.positive) {
|
|
507
|
-
process.env[`${prefix}POSITIVE`] = config.positive;
|
|
508
|
-
}
|
|
509
|
-
if (config.negative) {
|
|
510
|
-
process.env[`${prefix}NEGATIVE`] = config.negative;
|
|
511
|
-
}
|
|
512
|
-
}, "setBaseThemeColorConfigEnv");
|
|
513
|
-
|
|
514
|
-
// ../config-tools/src/create-storm-config.ts
|
|
515
|
-
var _static_cache = void 0;
|
|
516
|
-
var loadStormConfig = /* @__PURE__ */ _chunk4WKFVYTIjs.__name.call(void 0, async (workspaceRoot) => {
|
|
517
|
-
let config = {};
|
|
518
|
-
if (_optionalChain([_static_cache, 'optionalAccess', _30 => _30.data]) && _optionalChain([_static_cache, 'optionalAccess', _31 => _31.timestamp]) && _static_cache.timestamp >= Date.now() + 3e4) {
|
|
519
|
-
_chunkUUI4UWA4js.writeTrace.call(void 0, `Configuration cache hit - ${_static_cache.timestamp}`, _static_cache.data);
|
|
520
|
-
return _static_cache.data;
|
|
521
|
-
}
|
|
522
|
-
let _workspaceRoot = workspaceRoot;
|
|
523
|
-
if (!_workspaceRoot) {
|
|
524
|
-
_workspaceRoot = _chunkUUI4UWA4js.findWorkspaceRoot.call(void 0, );
|
|
525
|
-
}
|
|
526
|
-
const configFile = await getConfigFile(_workspaceRoot);
|
|
527
|
-
if (!configFile) {
|
|
528
|
-
_chunkUUI4UWA4js.writeWarning.call(void 0, "No Storm config file found in the current workspace. Please ensure this is the expected behavior - you can add a `storm.json` file to the root of your workspace if it is not.\n", {
|
|
529
|
-
logLevel: "all"
|
|
530
|
-
});
|
|
531
|
-
}
|
|
532
|
-
config = _defu2.default.call(void 0, getConfigEnv(), configFile, _chunkUUI4UWA4js.getDefaultConfig.call(void 0, _workspaceRoot));
|
|
533
|
-
setConfigEnv(config);
|
|
534
|
-
_chunkUUI4UWA4js.writeTrace.call(void 0, `\u2699\uFE0F Using Storm configuration:
|
|
535
|
-
${_chunkUUI4UWA4js.formatLogMessage.call(void 0, config)}`, config);
|
|
536
|
-
return config;
|
|
537
|
-
}, "loadStormConfig");
|
|
538
|
-
|
|
539
|
-
// ../build-tools/src/utilities/read-nx-config.ts
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
var readNxConfig = /* @__PURE__ */ _chunk4WKFVYTIjs.__name.call(void 0, async (workspaceRoot) => {
|
|
543
|
-
let rootDir = workspaceRoot;
|
|
544
|
-
if (!rootDir) {
|
|
545
|
-
const config = await loadStormConfig();
|
|
546
|
-
rootDir = config.workspaceRoot;
|
|
547
|
-
}
|
|
548
|
-
const nxJsonPath = _chunkUUI4UWA4js.joinPaths.call(void 0, rootDir, "nx.json");
|
|
549
|
-
if (!_fs.existsSync.call(void 0, nxJsonPath)) {
|
|
550
|
-
throw new Error("Cannot find project.json configuration");
|
|
551
|
-
}
|
|
552
|
-
const configContent = await _promises.readFile.call(void 0, nxJsonPath, "utf8");
|
|
553
|
-
return JSON.parse(configContent);
|
|
554
|
-
}, "readNxConfig");
|
|
555
|
-
|
|
556
|
-
// ../build-tools/src/utilities/copy-assets.ts
|
|
557
|
-
var copyAssets = /* @__PURE__ */ _chunk4WKFVYTIjs.__name.call(void 0, async (config, assets, outputPath, projectRoot, projectName, sourceRoot, generatePackageJson2 = true, includeSrc = false, banner, footer) => {
|
|
558
|
-
const pendingAssets = Array.from(_nullishCoalesce(assets, () => ( [])));
|
|
559
|
-
if (!_optionalChain([pendingAssets, 'optionalAccess', _32 => _32.some, 'call', _33 => _33((asset) => _optionalChain([asset, 'optionalAccess', _34 => _34.glob]) === "*.md")])) {
|
|
560
|
-
pendingAssets.push({
|
|
561
|
-
input: projectRoot,
|
|
562
|
-
glob: "*.md",
|
|
563
|
-
output: "/"
|
|
564
|
-
});
|
|
565
|
-
}
|
|
566
|
-
if (generatePackageJson2 === false) {
|
|
567
|
-
pendingAssets.push({
|
|
568
|
-
input: sourceRoot,
|
|
569
|
-
glob: "package.json",
|
|
570
|
-
output: "."
|
|
571
|
-
});
|
|
572
|
-
}
|
|
573
|
-
if (!_optionalChain([pendingAssets, 'optionalAccess', _35 => _35.some, 'call', _36 => _36((asset) => _optionalChain([asset, 'optionalAccess', _37 => _37.glob]) === "LICENSE")])) {
|
|
574
|
-
pendingAssets.push({
|
|
575
|
-
input: "",
|
|
576
|
-
glob: "LICENSE",
|
|
577
|
-
output: "."
|
|
578
|
-
});
|
|
579
|
-
}
|
|
580
|
-
if (includeSrc === true) {
|
|
581
|
-
pendingAssets.push({
|
|
582
|
-
input: sourceRoot,
|
|
583
|
-
glob: "**/{*.ts,*.tsx,*.js,*.jsx}",
|
|
584
|
-
output: "src/"
|
|
585
|
-
});
|
|
586
|
-
}
|
|
587
|
-
const nxJson = readNxConfig(config.workspaceRoot);
|
|
588
|
-
const projectGraph = _devkit.readCachedProjectGraph.call(void 0, );
|
|
589
|
-
const projectsConfigurations = _devkit.readProjectsConfigurationFromProjectGraph.call(void 0, projectGraph);
|
|
590
|
-
if (!_optionalChain([projectsConfigurations, 'optionalAccess', _38 => _38.projects, 'optionalAccess', _39 => _39[projectName]])) {
|
|
591
|
-
throw new Error("The Build process failed because the project does not have a valid configuration in the project.json file. Check if the file exists in the root of the project.");
|
|
592
|
-
}
|
|
593
|
-
const buildTarget = _optionalChain([projectsConfigurations, 'access', _40 => _40.projects, 'access', _41 => _41[projectName], 'access', _42 => _42.targets, 'optionalAccess', _43 => _43.build]);
|
|
594
|
-
if (!buildTarget) {
|
|
595
|
-
throw new Error(`The Build process failed because the project does not have a valid build target in the project.json file. Check if the file exists in the root of the project at ${_chunkUUI4UWA4js.joinPaths.call(void 0, projectRoot, "project.json")}`);
|
|
596
|
-
}
|
|
597
|
-
const result = await _js.copyAssets.call(void 0, {
|
|
598
|
-
assets,
|
|
599
|
-
watch: false,
|
|
600
|
-
outputPath
|
|
601
|
-
}, {
|
|
602
|
-
root: config.workspaceRoot,
|
|
603
|
-
targetName: "build",
|
|
604
|
-
target: buildTarget,
|
|
605
|
-
projectName,
|
|
606
|
-
projectGraph,
|
|
607
|
-
projectsConfigurations,
|
|
608
|
-
nxJsonConfiguration: nxJson,
|
|
609
|
-
cwd: config.workspaceRoot,
|
|
610
|
-
isVerbose: _chunkUUI4UWA4js.isVerbose.call(void 0, config.logLevel)
|
|
611
|
-
});
|
|
612
|
-
if (!result.success) {
|
|
613
|
-
throw new Error("The Build process failed trying to copy assets");
|
|
614
|
-
}
|
|
615
|
-
if (includeSrc === true) {
|
|
616
|
-
_chunkUUI4UWA4js.writeDebug.call(void 0, `\u{1F4DD} Adding banner and writing source files: ${_chunkUUI4UWA4js.joinPaths.call(void 0, outputPath, "src")}`, config);
|
|
617
|
-
const files = await _glob.glob.call(void 0, [
|
|
618
|
-
_chunkUUI4UWA4js.joinPaths.call(void 0, config.workspaceRoot, outputPath, "src/**/*.ts"),
|
|
619
|
-
_chunkUUI4UWA4js.joinPaths.call(void 0, config.workspaceRoot, outputPath, "src/**/*.tsx"),
|
|
620
|
-
_chunkUUI4UWA4js.joinPaths.call(void 0, config.workspaceRoot, outputPath, "src/**/*.js"),
|
|
621
|
-
_chunkUUI4UWA4js.joinPaths.call(void 0, config.workspaceRoot, outputPath, "src/**/*.jsx")
|
|
622
|
-
]);
|
|
623
|
-
await Promise.allSettled(files.map(async (file) => _promises.writeFile.call(void 0, file, `${banner && typeof banner === "string" ? banner.startsWith("//") ? banner : `// ${banner}` : ""}
|
|
624
|
-
|
|
625
|
-
${await _promises.readFile.call(void 0, file, "utf8")}
|
|
626
|
-
|
|
627
|
-
${footer && typeof footer === "string" ? footer.startsWith("//") ? footer : `// ${footer}` : ""}`)));
|
|
628
|
-
}
|
|
629
|
-
}, "copyAssets");
|
|
630
|
-
|
|
631
|
-
// ../build-tools/src/utilities/generate-package-json.ts
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
var _projectgraph = require('nx/src/project-graph/project-graph');
|
|
637
|
-
var addPackageDependencies = /* @__PURE__ */ _chunk4WKFVYTIjs.__name.call(void 0, async (workspaceRoot, projectRoot, projectName, packageJson) => {
|
|
638
|
-
const projectDependencies = _buildablelibsutils.calculateProjectBuildableDependencies.call(void 0, void 0, _projectgraph.readCachedProjectGraph.call(void 0, ), workspaceRoot, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
|
|
639
|
-
const localPackages = [];
|
|
640
|
-
for (const project of projectDependencies.dependencies.filter((dep) => dep.node.type === "lib" && dep.node.data.root !== projectRoot && dep.node.data.root !== workspaceRoot)) {
|
|
641
|
-
const projectNode = project.node;
|
|
642
|
-
if (projectNode.data.root) {
|
|
643
|
-
const projectPackageJsonPath = _chunkUUI4UWA4js.joinPaths.call(void 0, workspaceRoot, projectNode.data.root, "package.json");
|
|
644
|
-
if (_fs.existsSync.call(void 0, projectPackageJsonPath)) {
|
|
645
|
-
const projectPackageJsonContent = await _promises.readFile.call(void 0, projectPackageJsonPath, "utf8");
|
|
646
|
-
const projectPackageJson = JSON.parse(projectPackageJsonContent);
|
|
647
|
-
if (projectPackageJson.private !== false) {
|
|
648
|
-
localPackages.push(projectPackageJson);
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
if (localPackages.length > 0) {
|
|
654
|
-
_chunkUUI4UWA4js.writeTrace.call(void 0, `\u{1F4E6} Adding local packages to package.json: ${localPackages.map((p) => p.name).join(", ")}`);
|
|
655
|
-
packageJson.peerDependencies = localPackages.reduce((ret, localPackage) => {
|
|
656
|
-
if (!ret[localPackage.name]) {
|
|
657
|
-
ret[localPackage.name] = `>=${localPackage.version || "0.0.1"}`;
|
|
658
|
-
}
|
|
659
|
-
return ret;
|
|
660
|
-
}, _nullishCoalesce(packageJson.peerDependencies, () => ( {})));
|
|
661
|
-
packageJson.peerDependenciesMeta = localPackages.reduce((ret, localPackage) => {
|
|
662
|
-
if (!ret[localPackage.name]) {
|
|
663
|
-
ret[localPackage.name] = {
|
|
664
|
-
optional: false
|
|
665
|
-
};
|
|
666
|
-
}
|
|
667
|
-
return ret;
|
|
668
|
-
}, _nullishCoalesce(packageJson.peerDependenciesMeta, () => ( {})));
|
|
669
|
-
packageJson.devDependencies = localPackages.reduce((ret, localPackage) => {
|
|
670
|
-
if (!ret[localPackage.name]) {
|
|
671
|
-
ret[localPackage.name] = localPackage.version || "0.0.1";
|
|
672
|
-
}
|
|
673
|
-
return ret;
|
|
674
|
-
}, _nullishCoalesce(packageJson.peerDependencies, () => ( {})));
|
|
675
|
-
} else {
|
|
676
|
-
_chunkUUI4UWA4js.writeTrace.call(void 0, "\u{1F4E6} No local packages dependencies to add to package.json");
|
|
677
|
-
}
|
|
678
|
-
return packageJson;
|
|
679
|
-
}, "addPackageDependencies");
|
|
680
|
-
var addWorkspacePackageJsonFields = /* @__PURE__ */ _chunk4WKFVYTIjs.__name.call(void 0, async (config, projectRoot, sourceRoot, projectName, includeSrc = false, packageJson) => {
|
|
681
|
-
const workspaceRoot = config.workspaceRoot ? config.workspaceRoot : _chunkUUI4UWA4js.findWorkspaceRoot.call(void 0, );
|
|
682
|
-
const workspacePackageJsonContent = await _promises.readFile.call(void 0, _chunkUUI4UWA4js.joinPaths.call(void 0, workspaceRoot, "package.json"), "utf8");
|
|
683
|
-
const workspacePackageJson = JSON.parse(workspacePackageJsonContent);
|
|
684
|
-
packageJson.type ??= "module";
|
|
685
|
-
packageJson.sideEffects ??= false;
|
|
686
|
-
if (includeSrc === true) {
|
|
687
|
-
let distSrc = sourceRoot.replace(projectRoot, "");
|
|
688
|
-
if (distSrc.startsWith("/")) {
|
|
689
|
-
distSrc = distSrc.substring(1);
|
|
690
|
-
}
|
|
691
|
-
packageJson.source ??= `${_chunkUUI4UWA4js.joinPaths.call(void 0, distSrc, "index.ts").replaceAll("\\", "/")}`;
|
|
692
|
-
}
|
|
693
|
-
packageJson.files ??= [
|
|
694
|
-
"dist/**/*"
|
|
695
|
-
];
|
|
696
|
-
if (includeSrc === true && !packageJson.files.includes("src")) {
|
|
697
|
-
packageJson.files.push("src/**/*");
|
|
698
|
-
}
|
|
699
|
-
packageJson.publishConfig ??= {
|
|
700
|
-
access: "public"
|
|
701
|
-
};
|
|
702
|
-
packageJson.description ??= workspacePackageJson.description;
|
|
703
|
-
packageJson.homepage ??= workspacePackageJson.homepage;
|
|
704
|
-
packageJson.bugs ??= workspacePackageJson.bugs;
|
|
705
|
-
packageJson.license ??= workspacePackageJson.license;
|
|
706
|
-
packageJson.keywords ??= workspacePackageJson.keywords;
|
|
707
|
-
packageJson.funding ??= workspacePackageJson.funding;
|
|
708
|
-
packageJson.author ??= workspacePackageJson.author;
|
|
709
|
-
packageJson.maintainers ??= workspacePackageJson.maintainers;
|
|
710
|
-
if (!packageJson.maintainers && packageJson.author) {
|
|
711
|
-
packageJson.maintainers = [
|
|
712
|
-
packageJson.author
|
|
713
|
-
];
|
|
714
|
-
}
|
|
715
|
-
packageJson.contributors ??= workspacePackageJson.contributors;
|
|
716
|
-
if (!packageJson.contributors && packageJson.author) {
|
|
717
|
-
packageJson.contributors = [
|
|
718
|
-
packageJson.author
|
|
719
|
-
];
|
|
720
|
-
}
|
|
721
|
-
packageJson.repository ??= workspacePackageJson.repository;
|
|
722
|
-
packageJson.repository.directory ??= projectRoot ? projectRoot : _chunkUUI4UWA4js.joinPaths.call(void 0, "packages", projectName);
|
|
723
|
-
return packageJson;
|
|
724
|
-
}, "addWorkspacePackageJsonFields");
|
|
725
|
-
var addPackageJsonExport = /* @__PURE__ */ _chunk4WKFVYTIjs.__name.call(void 0, (file, type = "module", sourceRoot) => {
|
|
726
|
-
let entry = file.replaceAll("\\", "/");
|
|
727
|
-
if (sourceRoot) {
|
|
728
|
-
entry = entry.replace(sourceRoot, "");
|
|
729
|
-
}
|
|
730
|
-
return {
|
|
731
|
-
"import": {
|
|
732
|
-
"types": `./dist/${entry}.d.${type === "module" ? "ts" : "mts"}`,
|
|
733
|
-
"default": `./dist/${entry}.${type === "module" ? "js" : "mjs"}`
|
|
734
|
-
},
|
|
735
|
-
"require": {
|
|
736
|
-
"types": `./dist/${entry}.d.${type === "commonjs" ? "ts" : "cts"}`,
|
|
737
|
-
"default": `./dist/${entry}.${type === "commonjs" ? "js" : "cjs"}`
|
|
738
|
-
},
|
|
739
|
-
"default": {
|
|
740
|
-
"types": `./dist/${entry}.d.ts`,
|
|
741
|
-
"default": `./dist/${entry}.js`
|
|
742
|
-
}
|
|
743
|
-
};
|
|
744
|
-
}, "addPackageJsonExport");
|
|
745
|
-
var addPackageJsonExports = /* @__PURE__ */ _chunk4WKFVYTIjs.__name.call(void 0, async (sourceRoot, packageJson) => {
|
|
746
|
-
packageJson.exports ??= {};
|
|
747
|
-
const files = await new (0, _glob.Glob)("**/*.{ts,tsx}", {
|
|
748
|
-
absolute: false,
|
|
749
|
-
cwd: sourceRoot,
|
|
750
|
-
root: sourceRoot
|
|
751
|
-
}).walk();
|
|
752
|
-
files.forEach((file) => {
|
|
753
|
-
addPackageJsonExport(file, packageJson.type, sourceRoot);
|
|
754
|
-
const split = file.split(".");
|
|
755
|
-
split.pop();
|
|
756
|
-
const entry = split.join(".").replaceAll("\\", "/");
|
|
757
|
-
packageJson.exports[`./${entry}`] ??= addPackageJsonExport(entry, packageJson.type, sourceRoot);
|
|
758
|
-
});
|
|
759
|
-
packageJson.main = packageJson.type === "commonjs" ? "./dist/index.js" : "./dist/index.cjs";
|
|
760
|
-
packageJson.module = packageJson.type === "module" ? "./dist/index.js" : "./dist/index.mjs";
|
|
761
|
-
packageJson.types = "./dist/index.d.ts";
|
|
762
|
-
packageJson.exports ??= {};
|
|
763
|
-
packageJson.exports = Object.keys(packageJson.exports).reduce((ret, key) => {
|
|
764
|
-
if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
|
|
765
|
-
ret[key.replace("/index", "")] = packageJson.exports[key];
|
|
766
|
-
}
|
|
767
|
-
return ret;
|
|
768
|
-
}, packageJson.exports);
|
|
769
|
-
packageJson.exports["./package.json"] ??= "./package.json";
|
|
770
|
-
packageJson.exports["."] = _nullishCoalesce(packageJson.exports["."], () => ( addPackageJsonExport("index", packageJson.type, sourceRoot)));
|
|
771
|
-
return packageJson;
|
|
772
|
-
}, "addPackageJsonExports");
|
|
773
|
-
|
|
774
|
-
// ../build-tools/src/utilities/get-entry-points.ts
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
// ../build-tools/src/utilities/task-graph.ts
|
|
778
|
-
var _createtaskgraph = require('nx/src/tasks-runner/create-task-graph');
|
|
779
|
-
|
|
780
|
-
// src/build.ts
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
var _findworkspaceroot = require('nx/src/utils/find-workspace-root');
|
|
786
|
-
|
|
787
|
-
// ../../node_modules/.pnpm/unbuild@3.3.1_sass@1.83.4_typescript@5.7.3/node_modules/unbuild/dist/shared/unbuild.B2_7OVir.mjs
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
var _pathe = require('pathe');
|
|
791
|
-
var _utils = require('consola/utils');
|
|
792
|
-
var _consola = require('consola'); var _consola2 = _interopRequireDefault(_consola);
|
|
793
|
-
|
|
794
|
-
var _hookable = require('hookable');
|
|
795
|
-
var _prettybytes = require('pretty-bytes'); var _prettybytes2 = _interopRequireDefault(_prettybytes);
|
|
796
|
-
var _tinyglobby = require('tinyglobby');
|
|
797
|
-
|
|
798
|
-
var _jiti = require('jiti');
|
|
799
|
-
var _rollup = require('rollup');
|
|
800
|
-
var _rollupplugindts = require('rollup-plugin-dts'); var _rollupplugindts2 = _interopRequireDefault(_rollupplugindts);
|
|
801
|
-
var _plugincommonjs = require('@rollup/plugin-commonjs'); var _plugincommonjs2 = _interopRequireDefault(_plugincommonjs);
|
|
802
|
-
var _pluginnoderesolve = require('@rollup/plugin-node-resolve');
|
|
803
|
-
var _pluginalias = require('@rollup/plugin-alias'); var _pluginalias2 = _interopRequireDefault(_pluginalias);
|
|
804
|
-
var _pluginreplace = require('@rollup/plugin-replace'); var _pluginreplace2 = _interopRequireDefault(_pluginreplace);
|
|
805
|
-
var _utils3 = require('pathe/utils');
|
|
806
|
-
var _mlly = require('mlly');
|
|
807
|
-
var _esbuild = require('esbuild');
|
|
808
|
-
var _pluginutils = require('@rollup/pluginutils');
|
|
809
|
-
var _pluginjson = require('@rollup/plugin-json'); var _pluginjson2 = _interopRequireDefault(_pluginjson);
|
|
810
|
-
var _magicstring = require('magic-string'); var _magicstring2 = _interopRequireDefault(_magicstring);
|
|
811
|
-
var _untyped = require('untyped');
|
|
812
|
-
var _babelplugin = require('untyped/babel-plugin'); var _babelplugin2 = _interopRequireDefault(_babelplugin);
|
|
813
|
-
var _scule = require('scule');
|
|
814
|
-
var _mkdist = require('mkdist');
|
|
815
|
-
function definePreset(preset) {
|
|
816
|
-
return preset;
|
|
817
|
-
}
|
|
818
|
-
_chunk4WKFVYTIjs.__name.call(void 0, definePreset, "definePreset");
|
|
819
|
-
var autoPreset = definePreset(() => {
|
|
820
|
-
return {
|
|
821
|
-
hooks: {
|
|
822
|
-
"build:prepare"(ctx) {
|
|
823
|
-
if (!ctx.pkg || ctx.options.entries.length > 0) {
|
|
824
|
-
return;
|
|
825
|
-
}
|
|
826
|
-
const sourceFiles = listRecursively(_pathe.join.call(void 0, ctx.options.rootDir, "src"));
|
|
827
|
-
const res = inferEntries(ctx.pkg, sourceFiles, ctx.options.rootDir);
|
|
828
|
-
for (const message of res.warnings) {
|
|
829
|
-
warn(ctx, message);
|
|
830
|
-
}
|
|
831
|
-
ctx.options.entries.push(...res.entries);
|
|
832
|
-
if (res.cjs) {
|
|
833
|
-
ctx.options.rollup.emitCJS = true;
|
|
834
|
-
}
|
|
835
|
-
if (ctx.options.declaration === void 0) {
|
|
836
|
-
ctx.options.declaration = res.dts ? "compatible" : false;
|
|
837
|
-
}
|
|
838
|
-
_consola.consola.info(
|
|
839
|
-
"Automatically detected entries:",
|
|
840
|
-
_utils.colors.cyan(
|
|
841
|
-
ctx.options.entries.map(
|
|
842
|
-
(e) => _utils.colors.bold(
|
|
843
|
-
e.input.replace(ctx.options.rootDir + "/", "").replace(/\/$/, "/*")
|
|
844
|
-
)
|
|
845
|
-
).join(", ")
|
|
846
|
-
),
|
|
847
|
-
_utils.colors.gray(
|
|
848
|
-
["esm", res.cjs && "cjs", res.dts && "dts"].filter(Boolean).map((tag) => `[${tag}]`).join(" ")
|
|
849
|
-
)
|
|
850
|
-
);
|
|
851
|
-
}
|
|
852
|
-
}
|
|
853
|
-
};
|
|
854
|
-
});
|
|
855
|
-
function inferEntries(pkg, sourceFiles, rootDir) {
|
|
856
|
-
const warnings = [];
|
|
857
|
-
sourceFiles.sort((a, b) => a.split("/").length - b.split("/").length);
|
|
858
|
-
const outputs = extractExportFilenames(pkg.exports);
|
|
859
|
-
if (pkg.bin) {
|
|
860
|
-
const binaries = typeof pkg.bin === "string" ? [pkg.bin] : Object.values(pkg.bin);
|
|
861
|
-
for (const file of binaries) {
|
|
862
|
-
outputs.push({ file });
|
|
863
|
-
}
|
|
864
|
-
}
|
|
865
|
-
if (pkg.main) {
|
|
866
|
-
outputs.push({ file: pkg.main });
|
|
867
|
-
}
|
|
868
|
-
if (pkg.module) {
|
|
869
|
-
outputs.push({ type: "esm", file: pkg.module });
|
|
870
|
-
}
|
|
871
|
-
if (pkg.types || pkg.typings) {
|
|
872
|
-
outputs.push({ file: pkg.types || pkg.typings });
|
|
873
|
-
}
|
|
874
|
-
const isESMPkg = pkg.type === "module";
|
|
875
|
-
for (const output of outputs.filter((o) => !o.type)) {
|
|
876
|
-
const isJS = output.file.endsWith(".js");
|
|
877
|
-
if (isESMPkg && isJS || output.file.endsWith(".mjs")) {
|
|
878
|
-
output.type = "esm";
|
|
879
|
-
} else if (!isESMPkg && isJS || output.file.endsWith(".cjs")) {
|
|
880
|
-
output.type = "cjs";
|
|
881
|
-
}
|
|
882
|
-
}
|
|
883
|
-
let cjs = false;
|
|
884
|
-
let dts2 = false;
|
|
885
|
-
const entries = [];
|
|
886
|
-
for (const output of outputs) {
|
|
887
|
-
const outputSlug = output.file.replace(
|
|
888
|
-
/(\*[^/\\]*|\.d\.(m|c)?ts|\.\w+)$/,
|
|
889
|
-
""
|
|
890
|
-
);
|
|
891
|
-
const isDir = outputSlug.endsWith("/");
|
|
892
|
-
if (isDir && ["./", "/"].includes(outputSlug)) {
|
|
893
|
-
continue;
|
|
894
|
-
}
|
|
895
|
-
const possiblePaths = getEntrypointPaths(outputSlug);
|
|
896
|
-
const input = possiblePaths.reduce((source, d) => {
|
|
897
|
-
if (source) {
|
|
898
|
-
return source;
|
|
899
|
-
}
|
|
900
|
-
const SOURCE_RE = new RegExp(
|
|
901
|
-
`(?<=/|$)${d}${isDir ? "" : String.raw`\.\w+`}$`
|
|
902
|
-
);
|
|
903
|
-
return _optionalChain([sourceFiles, 'access', _44 => _44.find, 'call', _45 => _45((i) => SOURCE_RE.test(i)), 'optionalAccess', _46 => _46.replace, 'call', _47 => _47(/(\.d\.(m|c)?ts|\.\w+)$/, "")]);
|
|
904
|
-
}, void 0);
|
|
905
|
-
if (!input) {
|
|
906
|
-
if (!_fs.existsSync.call(void 0, _pathe.resolve.call(void 0, rootDir || ".", output.file))) {
|
|
907
|
-
warnings.push(`Could not find entrypoint for \`${output.file}\``);
|
|
908
|
-
}
|
|
909
|
-
continue;
|
|
910
|
-
}
|
|
911
|
-
if (output.type === "cjs") {
|
|
912
|
-
cjs = true;
|
|
913
|
-
}
|
|
914
|
-
const entry = entries.find((i) => i.input === input) || entries[entries.push({ input }) - 1];
|
|
915
|
-
if (/\.d\.(m|c)?ts$/.test(output.file)) {
|
|
916
|
-
dts2 = true;
|
|
917
|
-
}
|
|
918
|
-
if (isDir) {
|
|
919
|
-
entry.outDir = outputSlug;
|
|
920
|
-
entry.format = output.type;
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
return { entries, cjs, dts: dts2, warnings };
|
|
924
|
-
}
|
|
925
|
-
_chunk4WKFVYTIjs.__name.call(void 0, inferEntries, "inferEntries");
|
|
926
|
-
var getEntrypointPaths = /* @__PURE__ */ _chunk4WKFVYTIjs.__name.call(void 0, (path2) => {
|
|
927
|
-
const segments = _pathe.normalize.call(void 0, path2).split("/");
|
|
928
|
-
return segments.map((_, index) => segments.slice(index).join("/")).filter(Boolean);
|
|
929
|
-
}, "getEntrypointPaths");
|
|
930
|
-
async function ensuredir(path2) {
|
|
931
|
-
await _promises2.default.mkdir(_pathe.dirname.call(void 0, path2), { recursive: true });
|
|
932
|
-
}
|
|
933
|
-
_chunk4WKFVYTIjs.__name.call(void 0, ensuredir, "ensuredir");
|
|
934
|
-
function warn(ctx, message) {
|
|
935
|
-
if (ctx.warnings.has(message)) {
|
|
936
|
-
return;
|
|
937
|
-
}
|
|
938
|
-
_consola.consola.debug("[unbuild] [warn]", message);
|
|
939
|
-
ctx.warnings.add(message);
|
|
940
|
-
}
|
|
941
|
-
_chunk4WKFVYTIjs.__name.call(void 0, warn, "warn");
|
|
942
|
-
async function symlink(from, to, force = true) {
|
|
943
|
-
await ensuredir(to);
|
|
944
|
-
if (force) {
|
|
945
|
-
await _promises2.default.unlink(to).catch(() => {
|
|
946
|
-
});
|
|
947
|
-
}
|
|
948
|
-
await _promises2.default.symlink(from, to, "junction");
|
|
949
|
-
}
|
|
950
|
-
_chunk4WKFVYTIjs.__name.call(void 0, symlink, "symlink");
|
|
951
|
-
function dumpObject(obj) {
|
|
952
|
-
return "{ " + Object.keys(obj).map((key) => `${key}: ${JSON.stringify(obj[key])}`).join(", ") + " }";
|
|
953
|
-
}
|
|
954
|
-
_chunk4WKFVYTIjs.__name.call(void 0, dumpObject, "dumpObject");
|
|
955
|
-
function getpkg(id = "") {
|
|
956
|
-
const s = id.split("/");
|
|
957
|
-
return s[0][0] === "@" ? `${s[0]}/${s[1]}` : s[0];
|
|
958
|
-
}
|
|
959
|
-
_chunk4WKFVYTIjs.__name.call(void 0, getpkg, "getpkg");
|
|
960
|
-
async function rmdir(dir) {
|
|
961
|
-
await _promises2.default.unlink(dir).catch(() => {
|
|
962
|
-
});
|
|
963
|
-
await _promises2.default.rm(dir, { recursive: true, force: true }).catch(() => {
|
|
964
|
-
});
|
|
965
|
-
}
|
|
966
|
-
_chunk4WKFVYTIjs.__name.call(void 0, rmdir, "rmdir");
|
|
967
|
-
function listRecursively(path2) {
|
|
968
|
-
const filenames = /* @__PURE__ */ new Set();
|
|
969
|
-
const walk = /* @__PURE__ */ _chunk4WKFVYTIjs.__name.call(void 0, (path22) => {
|
|
970
|
-
const files = _fs.readdirSync.call(void 0, path22);
|
|
971
|
-
for (const file of files) {
|
|
972
|
-
const fullPath = _pathe.resolve.call(void 0, path22, file);
|
|
973
|
-
if (_fs.statSync.call(void 0, fullPath).isDirectory()) {
|
|
974
|
-
filenames.add(fullPath + "/");
|
|
975
|
-
walk(fullPath);
|
|
976
|
-
} else {
|
|
977
|
-
filenames.add(fullPath);
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
}, "walk");
|
|
981
|
-
walk(path2);
|
|
982
|
-
return [...filenames];
|
|
983
|
-
}
|
|
984
|
-
_chunk4WKFVYTIjs.__name.call(void 0, listRecursively, "listRecursively");
|
|
985
|
-
async function resolvePreset(preset, rootDir) {
|
|
986
|
-
if (preset === "auto") {
|
|
987
|
-
preset = autoPreset;
|
|
988
|
-
} else if (typeof preset === "string") {
|
|
989
|
-
preset = await _jiti.createJiti.call(void 0, rootDir, { interopDefault: true }).import(preset, {
|
|
990
|
-
default: true
|
|
991
|
-
}) || {};
|
|
992
|
-
}
|
|
993
|
-
if (typeof preset === "function") {
|
|
994
|
-
preset = preset();
|
|
995
|
-
}
|
|
996
|
-
return preset;
|
|
997
|
-
}
|
|
998
|
-
_chunk4WKFVYTIjs.__name.call(void 0, resolvePreset, "resolvePreset");
|
|
999
|
-
function inferExportType(condition, previousConditions = [], filename = "") {
|
|
1000
|
-
if (filename) {
|
|
1001
|
-
if (filename.endsWith(".d.ts")) {
|
|
1002
|
-
return "esm";
|
|
1003
|
-
}
|
|
1004
|
-
if (filename.endsWith(".mjs")) {
|
|
1005
|
-
return "esm";
|
|
1006
|
-
}
|
|
1007
|
-
if (filename.endsWith(".cjs")) {
|
|
1008
|
-
return "cjs";
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
switch (condition) {
|
|
1012
|
-
case "import": {
|
|
1013
|
-
return "esm";
|
|
1014
|
-
}
|
|
1015
|
-
case "require": {
|
|
1016
|
-
return "cjs";
|
|
1017
|
-
}
|
|
1018
|
-
default: {
|
|
1019
|
-
if (previousConditions.length === 0) {
|
|
1020
|
-
return "esm";
|
|
1021
|
-
}
|
|
1022
|
-
const [newCondition, ...rest] = previousConditions;
|
|
1023
|
-
return inferExportType(newCondition, rest, filename);
|
|
1024
|
-
}
|
|
1025
|
-
}
|
|
1026
|
-
}
|
|
1027
|
-
_chunk4WKFVYTIjs.__name.call(void 0, inferExportType, "inferExportType");
|
|
1028
|
-
function extractExportFilenames(exports, conditions = []) {
|
|
1029
|
-
if (!exports) {
|
|
1030
|
-
return [];
|
|
1031
|
-
}
|
|
1032
|
-
if (typeof exports === "string") {
|
|
1033
|
-
return [{ file: exports, type: "esm" }];
|
|
1034
|
-
}
|
|
1035
|
-
return Object.entries(exports).filter(([subpath]) => !subpath.endsWith(".json")).flatMap(
|
|
1036
|
-
([condition, exports2]) => typeof exports2 === "string" ? {
|
|
1037
|
-
file: exports2,
|
|
1038
|
-
type: inferExportType(condition, conditions, exports2)
|
|
1039
|
-
} : extractExportFilenames(exports2, [...conditions, condition])
|
|
1040
|
-
);
|
|
1041
|
-
}
|
|
1042
|
-
_chunk4WKFVYTIjs.__name.call(void 0, extractExportFilenames, "extractExportFilenames");
|
|
1043
|
-
function arrayIncludes(arr, searchElement) {
|
|
1044
|
-
return arr.some(
|
|
1045
|
-
(entry) => entry instanceof RegExp ? entry.test(searchElement) : entry === searchElement
|
|
1046
|
-
);
|
|
1047
|
-
}
|
|
1048
|
-
_chunk4WKFVYTIjs.__name.call(void 0, arrayIncludes, "arrayIncludes");
|
|
1049
|
-
function removeExtension(filename) {
|
|
1050
|
-
return filename.replace(/\.(js|mjs|cjs|ts|mts|cts|json|jsx|tsx)$/, "");
|
|
1051
|
-
}
|
|
1052
|
-
_chunk4WKFVYTIjs.__name.call(void 0, removeExtension, "removeExtension");
|
|
1053
|
-
function inferPkgExternals(pkg) {
|
|
1054
|
-
const externals = [
|
|
1055
|
-
...Object.keys(pkg.dependencies || {}),
|
|
1056
|
-
...Object.keys(pkg.peerDependencies || {}),
|
|
1057
|
-
...Object.keys(pkg.devDependencies || {}).filter(
|
|
1058
|
-
(dep) => dep.startsWith("@types/")
|
|
1059
|
-
),
|
|
1060
|
-
...Object.keys(pkg.optionalDependencies || {})
|
|
1061
|
-
];
|
|
1062
|
-
if (pkg.name) {
|
|
1063
|
-
externals.push(pkg.name);
|
|
1064
|
-
if (pkg.exports) {
|
|
1065
|
-
for (const subpath of Object.keys(pkg.exports)) {
|
|
1066
|
-
if (subpath.startsWith("./")) {
|
|
1067
|
-
externals.push(pathToRegex(`${pkg.name}/${subpath.slice(2)}`));
|
|
1068
|
-
}
|
|
1069
|
-
}
|
|
1070
|
-
}
|
|
1071
|
-
}
|
|
1072
|
-
if (pkg.imports) {
|
|
1073
|
-
for (const importName of Object.keys(pkg.imports)) {
|
|
1074
|
-
if (importName.startsWith("#")) {
|
|
1075
|
-
externals.push(pathToRegex(importName));
|
|
1076
|
-
}
|
|
1077
|
-
}
|
|
1078
|
-
}
|
|
1079
|
-
return [...new Set(externals)];
|
|
1080
|
-
}
|
|
1081
|
-
_chunk4WKFVYTIjs.__name.call(void 0, inferPkgExternals, "inferPkgExternals");
|
|
1082
|
-
function pathToRegex(path2) {
|
|
1083
|
-
return path2.includes("*") ? new RegExp(
|
|
1084
|
-
`^${path2.replace(/\./g, String.raw`\.`).replace(/\*/g, ".*")}$`
|
|
1085
|
-
) : path2;
|
|
1086
|
-
}
|
|
1087
|
-
_chunk4WKFVYTIjs.__name.call(void 0, pathToRegex, "pathToRegex");
|
|
1088
|
-
function withTrailingSlash(path2) {
|
|
1089
|
-
return path2.endsWith("/") ? path2 : `${path2}/`;
|
|
1090
|
-
}
|
|
1091
|
-
_chunk4WKFVYTIjs.__name.call(void 0, withTrailingSlash, "withTrailingSlash");
|
|
1092
|
-
function validateDependencies(ctx) {
|
|
1093
|
-
const usedDependencies = /* @__PURE__ */ new Set();
|
|
1094
|
-
const unusedDependencies = new Set(
|
|
1095
|
-
Object.keys(ctx.pkg.dependencies || {})
|
|
1096
|
-
);
|
|
1097
|
-
const implicitDependencies = /* @__PURE__ */ new Set();
|
|
1098
|
-
for (const id of ctx.usedImports) {
|
|
1099
|
-
unusedDependencies.delete(id);
|
|
1100
|
-
usedDependencies.add(id);
|
|
1101
|
-
}
|
|
1102
|
-
if (Array.isArray(ctx.options.dependencies)) {
|
|
1103
|
-
for (const id of ctx.options.dependencies) {
|
|
1104
|
-
unusedDependencies.delete(id);
|
|
1105
|
-
}
|
|
1106
|
-
}
|
|
1107
|
-
for (const id of usedDependencies) {
|
|
1108
|
-
if (!arrayIncludes(ctx.options.externals, id) && !id.startsWith("chunks/") && !ctx.options.dependencies.includes(getpkg(id)) && !ctx.options.peerDependencies.includes(getpkg(id))) {
|
|
1109
|
-
implicitDependencies.add(id);
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
if (unusedDependencies.size > 0) {
|
|
1113
|
-
warn(
|
|
1114
|
-
ctx,
|
|
1115
|
-
"Potential unused dependencies found: " + [...unusedDependencies].map((id) => _utils.colors.cyan(id)).join(", ")
|
|
1116
|
-
);
|
|
1117
|
-
}
|
|
1118
|
-
if (implicitDependencies.size > 0 && !ctx.options.rollup.inlineDependencies) {
|
|
1119
|
-
warn(
|
|
1120
|
-
ctx,
|
|
1121
|
-
"Potential implicit dependencies found: " + [...implicitDependencies].map((id) => _utils.colors.cyan(id)).join(", ")
|
|
1122
|
-
);
|
|
1123
|
-
}
|
|
1124
|
-
}
|
|
1125
|
-
_chunk4WKFVYTIjs.__name.call(void 0, validateDependencies, "validateDependencies");
|
|
1126
|
-
function validatePackage(pkg, rootDir, ctx) {
|
|
1127
|
-
if (!pkg) {
|
|
1128
|
-
return;
|
|
1129
|
-
}
|
|
1130
|
-
const filenames = new Set(
|
|
1131
|
-
[
|
|
1132
|
-
...typeof pkg.bin === "string" ? [pkg.bin] : Object.values(pkg.bin || {}),
|
|
1133
|
-
pkg.main,
|
|
1134
|
-
pkg.module,
|
|
1135
|
-
pkg.types,
|
|
1136
|
-
pkg.typings,
|
|
1137
|
-
...extractExportFilenames(pkg.exports).map((i) => i.file)
|
|
1138
|
-
].map((i) => i && _pathe.resolve.call(void 0, rootDir, i.replace(/\/[^/]*\*.*$/, "")))
|
|
1139
|
-
);
|
|
1140
|
-
const missingOutputs = [];
|
|
1141
|
-
for (const filename of filenames) {
|
|
1142
|
-
if (filename && !filename.includes("*") && !_fs.existsSync.call(void 0, filename)) {
|
|
1143
|
-
missingOutputs.push(filename.replace(rootDir + "/", ""));
|
|
1144
|
-
}
|
|
1145
|
-
}
|
|
1146
|
-
if (missingOutputs.length > 0) {
|
|
1147
|
-
warn(
|
|
1148
|
-
ctx,
|
|
1149
|
-
`Potential missing package.json files: ${missingOutputs.map((o) => _utils.colors.cyan(o)).join(", ")}`
|
|
1150
|
-
);
|
|
1151
|
-
}
|
|
1152
|
-
}
|
|
1153
|
-
_chunk4WKFVYTIjs.__name.call(void 0, validatePackage, "validatePackage");
|
|
1154
|
-
var SHEBANG_RE = /^#![^\n]*/;
|
|
1155
|
-
function shebangPlugin() {
|
|
1156
|
-
return {
|
|
1157
|
-
name: "unbuild-shebang",
|
|
1158
|
-
async writeBundle(options, bundle) {
|
|
1159
|
-
for (const [fileName, output] of Object.entries(bundle)) {
|
|
1160
|
-
if (output.type !== "chunk") {
|
|
1161
|
-
continue;
|
|
1162
|
-
}
|
|
1163
|
-
if (_optionalChain([output, 'access', _48 => _48.code, 'optionalAccess', _49 => _49.match, 'call', _50 => _50(SHEBANG_RE)])) {
|
|
1164
|
-
const outFile = _pathe.resolve.call(void 0, options.dir, fileName);
|
|
1165
|
-
await makeExecutable(outFile);
|
|
1166
|
-
}
|
|
1167
|
-
}
|
|
1168
|
-
}
|
|
1169
|
-
};
|
|
1170
|
-
}
|
|
1171
|
-
_chunk4WKFVYTIjs.__name.call(void 0, shebangPlugin, "shebangPlugin");
|
|
1172
|
-
function removeShebangPlugin() {
|
|
1173
|
-
return {
|
|
1174
|
-
name: "unbuild-remove-shebang",
|
|
1175
|
-
renderChunk(code) {
|
|
1176
|
-
return code.replace(SHEBANG_RE, "");
|
|
1177
|
-
}
|
|
1178
|
-
};
|
|
1179
|
-
}
|
|
1180
|
-
_chunk4WKFVYTIjs.__name.call(void 0, removeShebangPlugin, "removeShebangPlugin");
|
|
1181
|
-
async function makeExecutable(filePath) {
|
|
1182
|
-
await _fs.promises.chmod(
|
|
1183
|
-
filePath,
|
|
1184
|
-
493
|
|
1185
|
-
/* rwx r-x r-x */
|
|
1186
|
-
).catch(() => {
|
|
1187
|
-
});
|
|
1188
|
-
}
|
|
1189
|
-
_chunk4WKFVYTIjs.__name.call(void 0, makeExecutable, "makeExecutable");
|
|
1190
|
-
function getShebang(code, append = "\n") {
|
|
1191
|
-
const m = code.match(SHEBANG_RE);
|
|
1192
|
-
return m ? m + append : "";
|
|
1193
|
-
}
|
|
1194
|
-
_chunk4WKFVYTIjs.__name.call(void 0, getShebang, "getShebang");
|
|
1195
|
-
var DefaultLoaders = {
|
|
1196
|
-
".js": "js",
|
|
1197
|
-
".mjs": "js",
|
|
1198
|
-
".cjs": "js",
|
|
1199
|
-
".ts": "ts",
|
|
1200
|
-
".mts": "ts",
|
|
1201
|
-
".cts": "ts",
|
|
1202
|
-
".tsx": "tsx",
|
|
1203
|
-
".jsx": "jsx"
|
|
1204
|
-
};
|
|
1205
|
-
function esbuild(options) {
|
|
1206
|
-
const {
|
|
1207
|
-
include = new RegExp(Object.keys(DefaultLoaders).join("|")),
|
|
1208
|
-
exclude = /node_modules/,
|
|
1209
|
-
loaders: loaderOptions,
|
|
1210
|
-
...esbuildOptions
|
|
1211
|
-
} = options;
|
|
1212
|
-
const loaders = { ...DefaultLoaders };
|
|
1213
|
-
if (loaderOptions) {
|
|
1214
|
-
for (const [key, value] of Object.entries(loaderOptions)) {
|
|
1215
|
-
if (typeof value === "string") {
|
|
1216
|
-
loaders[key] = value;
|
|
1217
|
-
} else if (value === false) {
|
|
1218
|
-
delete loaders[key];
|
|
1219
|
-
}
|
|
1220
|
-
}
|
|
1221
|
-
}
|
|
1222
|
-
const getLoader = /* @__PURE__ */ _chunk4WKFVYTIjs.__name.call(void 0, (id = "") => {
|
|
1223
|
-
return loaders[_pathe.extname.call(void 0, id)];
|
|
1224
|
-
}, "getLoader");
|
|
1225
|
-
const filter = _pluginutils.createFilter.call(void 0, include, exclude);
|
|
1226
|
-
return {
|
|
1227
|
-
name: "esbuild",
|
|
1228
|
-
async transform(code, id) {
|
|
1229
|
-
if (!filter(id)) {
|
|
1230
|
-
return null;
|
|
1231
|
-
}
|
|
1232
|
-
const loader = getLoader(id);
|
|
1233
|
-
if (!loader) {
|
|
1234
|
-
return null;
|
|
1235
|
-
}
|
|
1236
|
-
const result = await _esbuild.transform.call(void 0, code, {
|
|
1237
|
-
...esbuildOptions,
|
|
1238
|
-
loader,
|
|
1239
|
-
sourcefile: id
|
|
1240
|
-
});
|
|
1241
|
-
printWarnings(id, result, this);
|
|
1242
|
-
return {
|
|
1243
|
-
code: result.code || "",
|
|
1244
|
-
map: result.map || null
|
|
1245
|
-
};
|
|
1246
|
-
},
|
|
1247
|
-
async renderChunk(code, { fileName }) {
|
|
1248
|
-
if (!options.minify) {
|
|
1249
|
-
return null;
|
|
1250
|
-
}
|
|
1251
|
-
if (/\.d\.(c|m)?tsx?$/.test(fileName)) {
|
|
1252
|
-
return null;
|
|
1253
|
-
}
|
|
1254
|
-
const loader = getLoader(fileName);
|
|
1255
|
-
if (!loader) {
|
|
1256
|
-
return null;
|
|
1257
|
-
}
|
|
1258
|
-
const result = await _esbuild.transform.call(void 0, code, {
|
|
1259
|
-
...esbuildOptions,
|
|
1260
|
-
loader,
|
|
1261
|
-
sourcefile: fileName,
|
|
1262
|
-
minify: true
|
|
1263
|
-
});
|
|
1264
|
-
return {
|
|
1265
|
-
code: result.code || "",
|
|
1266
|
-
map: result.map || null
|
|
1267
|
-
};
|
|
1268
|
-
}
|
|
1269
|
-
};
|
|
1270
|
-
}
|
|
1271
|
-
_chunk4WKFVYTIjs.__name.call(void 0, esbuild, "esbuild");
|
|
1272
|
-
function printWarnings(id, result, plugin) {
|
|
1273
|
-
if (result.warnings) {
|
|
1274
|
-
for (const warning of result.warnings) {
|
|
1275
|
-
let message = "[esbuild]";
|
|
1276
|
-
if (warning.location) {
|
|
1277
|
-
message += ` (${_pathe.relative.call(void 0, process.cwd(), id)}:${warning.location.line}:${warning.location.column})`;
|
|
1278
|
-
}
|
|
1279
|
-
message += ` ${warning.text}`;
|
|
1280
|
-
plugin.warn(message);
|
|
1281
|
-
}
|
|
1282
|
-
}
|
|
1283
|
-
}
|
|
1284
|
-
_chunk4WKFVYTIjs.__name.call(void 0, printWarnings, "printWarnings");
|
|
1285
|
-
var EXPORT_DEFAULT = "export default ";
|
|
1286
|
-
function JSONPlugin(options) {
|
|
1287
|
-
const plugin = _pluginjson2.default.call(void 0, options);
|
|
1288
|
-
return {
|
|
1289
|
-
...plugin,
|
|
1290
|
-
name: "unbuild-json",
|
|
1291
|
-
transform(code, id) {
|
|
1292
|
-
const res = plugin.transform.call(this, code, id);
|
|
1293
|
-
if (res && typeof res !== "string" && "code" in res && res.code && res.code.startsWith(EXPORT_DEFAULT)) {
|
|
1294
|
-
res.code = res.code.replace(EXPORT_DEFAULT, "module.exports = ");
|
|
1295
|
-
}
|
|
1296
|
-
return res;
|
|
1297
|
-
}
|
|
1298
|
-
};
|
|
1299
|
-
}
|
|
1300
|
-
_chunk4WKFVYTIjs.__name.call(void 0, JSONPlugin, "JSONPlugin");
|
|
1301
|
-
var defaults = {
|
|
1302
|
-
include: [/\.(md|txt|css|htm|html)$/],
|
|
1303
|
-
exclude: []
|
|
1304
|
-
};
|
|
1305
|
-
function rawPlugin(opts = {}) {
|
|
1306
|
-
opts = { ...opts, ...defaults };
|
|
1307
|
-
const filter = _pluginutils.createFilter.call(void 0, opts.include, opts.exclude);
|
|
1308
|
-
return {
|
|
1309
|
-
name: "unbuild-raw",
|
|
1310
|
-
transform(code, id) {
|
|
1311
|
-
if (filter(id)) {
|
|
1312
|
-
return {
|
|
1313
|
-
code: `export default ${JSON.stringify(code)}`,
|
|
1314
|
-
map: null
|
|
1315
|
-
};
|
|
1316
|
-
}
|
|
1317
|
-
}
|
|
1318
|
-
};
|
|
1319
|
-
}
|
|
1320
|
-
_chunk4WKFVYTIjs.__name.call(void 0, rawPlugin, "rawPlugin");
|
|
1321
|
-
function cjsPlugin(_opts) {
|
|
1322
|
-
return {
|
|
1323
|
-
name: "unbuild-cjs",
|
|
1324
|
-
renderChunk(code, _chunk, opts) {
|
|
1325
|
-
if (opts.format === "es") {
|
|
1326
|
-
return CJSToESM(code);
|
|
1327
|
-
}
|
|
1328
|
-
return null;
|
|
1329
|
-
}
|
|
1330
|
-
};
|
|
1331
|
-
}
|
|
1332
|
-
_chunk4WKFVYTIjs.__name.call(void 0, cjsPlugin, "cjsPlugin");
|
|
1333
|
-
function fixCJSExportTypePlugin() {
|
|
1334
|
-
return {
|
|
1335
|
-
name: "unbuild-fix-cjs-export-type",
|
|
1336
|
-
renderChunk(code, info, opts) {
|
|
1337
|
-
if (info.type !== "chunk" || !info.fileName.endsWith(".d.cts") || !info.isEntry || _optionalChain([info, 'access', _51 => _51.exports, 'optionalAccess', _52 => _52.length]) !== 1 || info.exports[0] !== "default") {
|
|
1338
|
-
return;
|
|
1339
|
-
}
|
|
1340
|
-
return code.replace(
|
|
1341
|
-
/(?<=(?<=[;}]|^)\s*export\s*){\s*([\w$]+)\s*as\s+default\s*}/,
|
|
1342
|
-
`= $1`
|
|
1343
|
-
);
|
|
1344
|
-
}
|
|
1345
|
-
};
|
|
1346
|
-
}
|
|
1347
|
-
_chunk4WKFVYTIjs.__name.call(void 0, fixCJSExportTypePlugin, "fixCJSExportTypePlugin");
|
|
1348
|
-
var CJSyntaxRe = /__filename|__dirname|require\(|require\.resolve\(/;
|
|
1349
|
-
var CJSShim = `
|
|
1350
|
-
|
|
1351
|
-
// -- Unbuild CommonJS Shims --
|
|
1352
|
-
import __cjs_url__ from 'url';
|
|
1353
|
-
import __cjs_path__ from 'path';
|
|
1354
|
-
import __cjs_mod__ from 'module';
|
|
1355
|
-
const __filename = __cjs_url__.fileURLToPath(import.meta.url);
|
|
1356
|
-
const __dirname = __cjs_path__.dirname(__filename);
|
|
1357
|
-
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
1358
|
-
`;
|
|
1359
|
-
function CJSToESM(code) {
|
|
1360
|
-
if (code.includes(CJSShim) || !CJSyntaxRe.test(code)) {
|
|
1361
|
-
return null;
|
|
1362
|
-
}
|
|
1363
|
-
const lastESMImport = _mlly.findStaticImports.call(void 0, code).pop();
|
|
1364
|
-
const indexToAppend = lastESMImport ? lastESMImport.end : 0;
|
|
1365
|
-
const s = new (0, _magicstring2.default)(code);
|
|
1366
|
-
s.appendRight(indexToAppend, CJSShim);
|
|
1367
|
-
return {
|
|
1368
|
-
code: s.toString(),
|
|
1369
|
-
map: s.generateMap()
|
|
1370
|
-
};
|
|
1371
|
-
}
|
|
1372
|
-
_chunk4WKFVYTIjs.__name.call(void 0, CJSToESM, "CJSToESM");
|
|
1373
|
-
var DEFAULT_EXTENSIONS = [
|
|
1374
|
-
".ts",
|
|
1375
|
-
".tsx",
|
|
1376
|
-
".mts",
|
|
1377
|
-
".cts",
|
|
1378
|
-
".mjs",
|
|
1379
|
-
".cjs",
|
|
1380
|
-
".js",
|
|
1381
|
-
".jsx",
|
|
1382
|
-
".json"
|
|
1383
|
-
];
|
|
1384
|
-
function resolveAliases(ctx) {
|
|
1385
|
-
const aliases = {
|
|
1386
|
-
[ctx.pkg.name]: ctx.options.rootDir,
|
|
1387
|
-
...ctx.options.alias
|
|
1388
|
-
};
|
|
1389
|
-
if (ctx.options.rollup.alias) {
|
|
1390
|
-
if (Array.isArray(ctx.options.rollup.alias.entries)) {
|
|
1391
|
-
Object.assign(
|
|
1392
|
-
aliases,
|
|
1393
|
-
Object.fromEntries(
|
|
1394
|
-
ctx.options.rollup.alias.entries.map((entry) => {
|
|
1395
|
-
return [entry.find, entry.replacement];
|
|
1396
|
-
})
|
|
1397
|
-
)
|
|
1398
|
-
);
|
|
1399
|
-
} else {
|
|
1400
|
-
Object.assign(
|
|
1401
|
-
aliases,
|
|
1402
|
-
ctx.options.rollup.alias.entries || ctx.options.rollup.alias
|
|
1403
|
-
);
|
|
1404
|
-
}
|
|
1405
|
-
}
|
|
1406
|
-
return aliases;
|
|
1407
|
-
}
|
|
1408
|
-
_chunk4WKFVYTIjs.__name.call(void 0, resolveAliases, "resolveAliases");
|
|
1409
|
-
function getChunkFilename(ctx, chunk, ext) {
|
|
1410
|
-
if (chunk.isDynamicEntry) {
|
|
1411
|
-
return `chunks/[name].${ext}`;
|
|
1412
|
-
}
|
|
1413
|
-
return `shared/${ctx.options.name}.[hash].${ext}`;
|
|
1414
|
-
}
|
|
1415
|
-
_chunk4WKFVYTIjs.__name.call(void 0, getChunkFilename, "getChunkFilename");
|
|
1416
|
-
function getRollupOptions(ctx) {
|
|
1417
|
-
const _aliases = resolveAliases(ctx);
|
|
1418
|
-
return {
|
|
1419
|
-
input: Object.fromEntries(
|
|
1420
|
-
ctx.options.entries.filter((entry) => entry.builder === "rollup").map((entry) => [
|
|
1421
|
-
entry.name,
|
|
1422
|
-
_pathe.resolve.call(void 0, ctx.options.rootDir, entry.input)
|
|
1423
|
-
])
|
|
1424
|
-
),
|
|
1425
|
-
output: [
|
|
1426
|
-
ctx.options.rollup.emitCJS && {
|
|
1427
|
-
dir: _pathe.resolve.call(void 0, ctx.options.rootDir, ctx.options.outDir),
|
|
1428
|
-
entryFileNames: "[name].cjs",
|
|
1429
|
-
chunkFileNames: /* @__PURE__ */ _chunk4WKFVYTIjs.__name.call(void 0, (chunk) => getChunkFilename(ctx, chunk, "cjs"), "chunkFileNames"),
|
|
1430
|
-
format: "cjs",
|
|
1431
|
-
exports: "auto",
|
|
1432
|
-
interop: "compat",
|
|
1433
|
-
generatedCode: { constBindings: true },
|
|
1434
|
-
externalLiveBindings: false,
|
|
1435
|
-
freeze: false,
|
|
1436
|
-
sourcemap: ctx.options.sourcemap,
|
|
1437
|
-
...ctx.options.rollup.output
|
|
1438
|
-
},
|
|
1439
|
-
{
|
|
1440
|
-
dir: _pathe.resolve.call(void 0, ctx.options.rootDir, ctx.options.outDir),
|
|
1441
|
-
entryFileNames: "[name].mjs",
|
|
1442
|
-
chunkFileNames: /* @__PURE__ */ _chunk4WKFVYTIjs.__name.call(void 0, (chunk) => getChunkFilename(ctx, chunk, "mjs"), "chunkFileNames"),
|
|
1443
|
-
format: "esm",
|
|
1444
|
-
exports: "auto",
|
|
1445
|
-
generatedCode: { constBindings: true },
|
|
1446
|
-
externalLiveBindings: false,
|
|
1447
|
-
freeze: false,
|
|
1448
|
-
sourcemap: ctx.options.sourcemap,
|
|
1449
|
-
...ctx.options.rollup.output
|
|
1450
|
-
}
|
|
1451
|
-
].filter(Boolean),
|
|
1452
|
-
external(originalId) {
|
|
1453
|
-
const resolvedId = _utils3.resolveAlias.call(void 0, originalId, _aliases);
|
|
1454
|
-
const pkgName = _optionalChain([_mlly.parseNodeModulePath.call(void 0, resolvedId), 'optionalAccess', _53 => _53.name]) || _optionalChain([_mlly.parseNodeModulePath.call(void 0, originalId), 'optionalAccess', _54 => _54.name]) || getpkg(originalId);
|
|
1455
|
-
if (arrayIncludes(ctx.options.externals, pkgName) || arrayIncludes(ctx.options.externals, originalId) || arrayIncludes(ctx.options.externals, resolvedId)) {
|
|
1456
|
-
return true;
|
|
1457
|
-
}
|
|
1458
|
-
for (const id of [originalId, resolvedId]) {
|
|
1459
|
-
if (id[0] === "." || _pathe.isAbsolute.call(void 0, id) || /src[/\\]/.test(id) || id.startsWith(ctx.pkg.name)) {
|
|
1460
|
-
return false;
|
|
1461
|
-
}
|
|
1462
|
-
}
|
|
1463
|
-
if (ctx.options.rollup.inlineDependencies === true || Array.isArray(ctx.options.rollup.inlineDependencies) && (arrayIncludes(ctx.options.rollup.inlineDependencies, pkgName) || arrayIncludes(ctx.options.rollup.inlineDependencies, originalId) || arrayIncludes(ctx.options.rollup.inlineDependencies, resolvedId))) {
|
|
1464
|
-
return false;
|
|
1465
|
-
}
|
|
1466
|
-
warn(ctx, `Implicitly bundling "${originalId}"`);
|
|
1467
|
-
return false;
|
|
1468
|
-
},
|
|
1469
|
-
onwarn(warning, rollupWarn) {
|
|
1470
|
-
if (!warning.code || !["CIRCULAR_DEPENDENCY"].includes(warning.code)) {
|
|
1471
|
-
rollupWarn(warning);
|
|
1472
|
-
}
|
|
1473
|
-
},
|
|
1474
|
-
plugins: [
|
|
1475
|
-
ctx.options.rollup.replace && _pluginreplace2.default.call(void 0, {
|
|
1476
|
-
...ctx.options.rollup.replace,
|
|
1477
|
-
values: {
|
|
1478
|
-
...ctx.options.replace,
|
|
1479
|
-
...ctx.options.rollup.replace.values
|
|
1480
|
-
}
|
|
1481
|
-
}),
|
|
1482
|
-
ctx.options.rollup.alias && _pluginalias2.default.call(void 0, {
|
|
1483
|
-
...ctx.options.rollup.alias,
|
|
1484
|
-
entries: _aliases
|
|
1485
|
-
}),
|
|
1486
|
-
ctx.options.rollup.resolve && _pluginnoderesolve.nodeResolve.call(void 0, {
|
|
1487
|
-
extensions: DEFAULT_EXTENSIONS,
|
|
1488
|
-
exportConditions: ["production"],
|
|
1489
|
-
...ctx.options.rollup.resolve
|
|
1490
|
-
}),
|
|
1491
|
-
ctx.options.rollup.json && JSONPlugin({
|
|
1492
|
-
...ctx.options.rollup.json
|
|
1493
|
-
}),
|
|
1494
|
-
shebangPlugin(),
|
|
1495
|
-
ctx.options.rollup.esbuild && esbuild({
|
|
1496
|
-
sourcemap: ctx.options.sourcemap,
|
|
1497
|
-
...ctx.options.rollup.esbuild
|
|
1498
|
-
}),
|
|
1499
|
-
ctx.options.rollup.commonjs && _plugincommonjs2.default.call(void 0, {
|
|
1500
|
-
extensions: DEFAULT_EXTENSIONS,
|
|
1501
|
-
...ctx.options.rollup.commonjs
|
|
1502
|
-
}),
|
|
1503
|
-
ctx.options.rollup.preserveDynamicImports && {
|
|
1504
|
-
renderDynamicImport() {
|
|
1505
|
-
return { left: "import(", right: ")" };
|
|
1506
|
-
}
|
|
1507
|
-
},
|
|
1508
|
-
ctx.options.rollup.cjsBridge && cjsPlugin(),
|
|
1509
|
-
rawPlugin()
|
|
1510
|
-
].filter(Boolean)
|
|
1511
|
-
};
|
|
1512
|
-
}
|
|
1513
|
-
_chunk4WKFVYTIjs.__name.call(void 0, getRollupOptions, "getRollupOptions");
|
|
1514
|
-
async function rollupStub(ctx) {
|
|
1515
|
-
const babelPlugins = _optionalChain([ctx, 'access', _55 => _55.options, 'access', _56 => _56.stubOptions, 'access', _57 => _57.jiti, 'access', _58 => _58.transformOptions, 'optionalAccess', _59 => _59.babel, 'optionalAccess', _60 => _60.plugins]);
|
|
1516
|
-
const importedBabelPlugins = [];
|
|
1517
|
-
const serializedJitiOptions = JSON.stringify(
|
|
1518
|
-
{
|
|
1519
|
-
...ctx.options.stubOptions.jiti,
|
|
1520
|
-
alias: {
|
|
1521
|
-
...resolveAliases(ctx),
|
|
1522
|
-
...ctx.options.stubOptions.jiti.alias
|
|
1523
|
-
},
|
|
1524
|
-
transformOptions: {
|
|
1525
|
-
...ctx.options.stubOptions.jiti.transformOptions,
|
|
1526
|
-
babel: {
|
|
1527
|
-
..._optionalChain([ctx, 'access', _61 => _61.options, 'access', _62 => _62.stubOptions, 'access', _63 => _63.jiti, 'access', _64 => _64.transformOptions, 'optionalAccess', _65 => _65.babel]),
|
|
1528
|
-
plugins: "__$BABEL_PLUGINS"
|
|
1529
|
-
}
|
|
1530
|
-
}
|
|
1531
|
-
},
|
|
1532
|
-
null,
|
|
1533
|
-
2
|
|
1534
|
-
).replace(
|
|
1535
|
-
'"__$BABEL_PLUGINS"',
|
|
1536
|
-
Array.isArray(babelPlugins) ? "[" + babelPlugins.map((plugin, i) => {
|
|
1537
|
-
if (Array.isArray(plugin)) {
|
|
1538
|
-
const [name, ...args] = plugin;
|
|
1539
|
-
importedBabelPlugins.push(name);
|
|
1540
|
-
return `[` + [
|
|
1541
|
-
`plugin${i}`,
|
|
1542
|
-
...args.map((val) => JSON.stringify(val))
|
|
1543
|
-
].join(", ") + "]";
|
|
1544
|
-
} else {
|
|
1545
|
-
importedBabelPlugins.push(plugin);
|
|
1546
|
-
return `plugin${i}`;
|
|
1547
|
-
}
|
|
1548
|
-
}).join(",") + "]" : "[]"
|
|
1549
|
-
);
|
|
1550
|
-
for (const entry of ctx.options.entries.filter(
|
|
1551
|
-
(entry2) => entry2.builder === "rollup"
|
|
1552
|
-
)) {
|
|
1553
|
-
const output = _pathe.resolve.call(void 0,
|
|
1554
|
-
ctx.options.rootDir,
|
|
1555
|
-
ctx.options.outDir,
|
|
1556
|
-
entry.name
|
|
1557
|
-
);
|
|
1558
|
-
const isESM = ctx.pkg.type === "module";
|
|
1559
|
-
const resolvedEntry = _mlly.fileURLToPath.call(void 0, ctx.jiti.esmResolve(entry.input));
|
|
1560
|
-
const resolvedEntryWithoutExt = resolvedEntry.slice(
|
|
1561
|
-
0,
|
|
1562
|
-
Math.max(0, resolvedEntry.length - _pathe.extname.call(void 0, resolvedEntry).length)
|
|
1563
|
-
);
|
|
1564
|
-
const resolvedEntryForTypeImport = isESM ? `${resolvedEntry.replace(/(\.m?)(ts)$/, "$1js")}` : resolvedEntryWithoutExt;
|
|
1565
|
-
const code = await _fs.promises.readFile(resolvedEntry, "utf8");
|
|
1566
|
-
const shebang = getShebang(code);
|
|
1567
|
-
await _promises.mkdir.call(void 0, _pathe.dirname.call(void 0, output), { recursive: true });
|
|
1568
|
-
if (ctx.options.rollup.emitCJS) {
|
|
1569
|
-
const jitiCJSPath = _pathe.relative.call(void 0,
|
|
1570
|
-
_pathe.dirname.call(void 0, output),
|
|
1571
|
-
await _mlly.resolvePath.call(void 0, "jiti", {
|
|
1572
|
-
url: _chunk4WKFVYTIjs.importMetaUrl,
|
|
1573
|
-
conditions: ["node", "require"]
|
|
1574
|
-
})
|
|
1575
|
-
);
|
|
1576
|
-
await _promises.writeFile.call(void 0,
|
|
1577
|
-
output + ".cjs",
|
|
1578
|
-
shebang + [
|
|
1579
|
-
`const { createJiti } = require(${JSON.stringify(jitiCJSPath)})`,
|
|
1580
|
-
...importedBabelPlugins.map(
|
|
1581
|
-
(plugin, i) => `const plugin${i} = require(${JSON.stringify(plugin)})`
|
|
1582
|
-
),
|
|
1583
|
-
"",
|
|
1584
|
-
`const jiti = createJiti(__filename, ${serializedJitiOptions})`,
|
|
1585
|
-
"",
|
|
1586
|
-
`/** @type {import(${JSON.stringify(
|
|
1587
|
-
resolvedEntryForTypeImport
|
|
1588
|
-
)})} */`,
|
|
1589
|
-
`module.exports = jiti(${JSON.stringify(resolvedEntry)})`
|
|
1590
|
-
].join("\n")
|
|
1591
|
-
);
|
|
1592
|
-
}
|
|
1593
|
-
const namedExports = await _mlly.resolveModuleExportNames.call(void 0,
|
|
1594
|
-
resolvedEntry,
|
|
1595
|
-
{
|
|
1596
|
-
extensions: DEFAULT_EXTENSIONS
|
|
1597
|
-
}
|
|
1598
|
-
).catch((error) => {
|
|
1599
|
-
warn(ctx, `Cannot analyze ${resolvedEntry} for exports:` + error);
|
|
1600
|
-
return [];
|
|
1601
|
-
});
|
|
1602
|
-
const hasDefaultExport = namedExports.includes("default") || namedExports.length === 0;
|
|
1603
|
-
const jitiESMPath = _pathe.relative.call(void 0,
|
|
1604
|
-
_pathe.dirname.call(void 0, output),
|
|
1605
|
-
await _mlly.resolvePath.call(void 0, "jiti", {
|
|
1606
|
-
url: _chunk4WKFVYTIjs.importMetaUrl,
|
|
1607
|
-
conditions: ["node", "import"]
|
|
1608
|
-
})
|
|
1609
|
-
);
|
|
1610
|
-
await _promises.writeFile.call(void 0,
|
|
1611
|
-
output + ".mjs",
|
|
1612
|
-
shebang + [
|
|
1613
|
-
`import { createJiti } from ${JSON.stringify(jitiESMPath)};`,
|
|
1614
|
-
...importedBabelPlugins.map(
|
|
1615
|
-
(plugin, i) => `import plugin${i} from ${JSON.stringify(plugin)}`
|
|
1616
|
-
),
|
|
1617
|
-
"",
|
|
1618
|
-
`const jiti = createJiti(import.meta.url, ${serializedJitiOptions})`,
|
|
1619
|
-
"",
|
|
1620
|
-
`/** @type {import(${JSON.stringify(resolvedEntryForTypeImport)})} */`,
|
|
1621
|
-
`const _module = await jiti.import(${JSON.stringify(
|
|
1622
|
-
resolvedEntry
|
|
1623
|
-
)});`,
|
|
1624
|
-
hasDefaultExport ? "\nexport default _module?.default ?? _module;" : "",
|
|
1625
|
-
...namedExports.filter((name) => name !== "default").map((name) => `export const ${name} = _module.${name};`)
|
|
1626
|
-
].join("\n")
|
|
1627
|
-
);
|
|
1628
|
-
if (ctx.options.declaration) {
|
|
1629
|
-
const dtsContent = [
|
|
1630
|
-
`export * from ${JSON.stringify(resolvedEntryForTypeImport)};`,
|
|
1631
|
-
hasDefaultExport ? `export { default } from ${JSON.stringify(resolvedEntryForTypeImport)};` : ""
|
|
1632
|
-
].join("\n");
|
|
1633
|
-
await _promises.writeFile.call(void 0, output + ".d.cts", dtsContent);
|
|
1634
|
-
await _promises.writeFile.call(void 0, output + ".d.mts", dtsContent);
|
|
1635
|
-
if (ctx.options.declaration === "compatible" || ctx.options.declaration === true) {
|
|
1636
|
-
await _promises.writeFile.call(void 0, output + ".d.ts", dtsContent);
|
|
1637
|
-
}
|
|
1638
|
-
}
|
|
1639
|
-
if (shebang) {
|
|
1640
|
-
await makeExecutable(output + ".cjs");
|
|
1641
|
-
await makeExecutable(output + ".mjs");
|
|
1642
|
-
}
|
|
1643
|
-
}
|
|
1644
|
-
}
|
|
1645
|
-
_chunk4WKFVYTIjs.__name.call(void 0, rollupStub, "rollupStub");
|
|
1646
|
-
function rollupWatch(rollupOptions) {
|
|
1647
|
-
const watcher = _rollup.watch.call(void 0, rollupOptions);
|
|
1648
|
-
let inputs;
|
|
1649
|
-
if (Array.isArray(rollupOptions.input)) {
|
|
1650
|
-
inputs = rollupOptions.input;
|
|
1651
|
-
} else if (typeof rollupOptions.input === "string") {
|
|
1652
|
-
inputs = [rollupOptions.input];
|
|
1653
|
-
} else {
|
|
1654
|
-
inputs = Object.keys(rollupOptions.input || {});
|
|
1655
|
-
}
|
|
1656
|
-
_consola2.default.info(
|
|
1657
|
-
`[unbuild] [rollup] Starting watchers for entries: ${inputs.map((input) => "./" + _pathe.relative.call(void 0, process.cwd(), input)).join(", ")}`
|
|
1658
|
-
);
|
|
1659
|
-
_consola2.default.warn(
|
|
1660
|
-
"[unbuild] [rollup] Watch mode is experimental and may be unstable"
|
|
1661
|
-
);
|
|
1662
|
-
watcher.on("change", (id, { event }) => {
|
|
1663
|
-
_consola2.default.info(`${_utils.colors.cyan(_pathe.relative.call(void 0, ".", id))} was ${event}d`);
|
|
1664
|
-
});
|
|
1665
|
-
watcher.on("restart", () => {
|
|
1666
|
-
_consola2.default.info(_utils.colors.gray("[unbuild] [rollup] Rebuilding bundle"));
|
|
1667
|
-
});
|
|
1668
|
-
watcher.on("event", (event) => {
|
|
1669
|
-
if (event.code === "END") {
|
|
1670
|
-
_consola2.default.success(_utils.colors.green("[unbuild] [rollup] Rebuild finished\n"));
|
|
1671
|
-
}
|
|
1672
|
-
});
|
|
1673
|
-
}
|
|
1674
|
-
_chunk4WKFVYTIjs.__name.call(void 0, rollupWatch, "rollupWatch");
|
|
1675
|
-
async function rollupBuild(ctx) {
|
|
1676
|
-
if (ctx.options.stub) {
|
|
1677
|
-
await rollupStub(ctx);
|
|
1678
|
-
await ctx.hooks.callHook("rollup:done", ctx);
|
|
1679
|
-
return;
|
|
1680
|
-
}
|
|
1681
|
-
const rollupOptions = getRollupOptions(ctx);
|
|
1682
|
-
await ctx.hooks.callHook("rollup:options", ctx, rollupOptions);
|
|
1683
|
-
if (Object.keys(rollupOptions.input).length === 0) {
|
|
1684
|
-
await ctx.hooks.callHook("rollup:done", ctx);
|
|
1685
|
-
return;
|
|
1686
|
-
}
|
|
1687
|
-
const buildResult = await _rollup.rollup.call(void 0, rollupOptions);
|
|
1688
|
-
await ctx.hooks.callHook("rollup:build", ctx, buildResult);
|
|
1689
|
-
const allOutputOptions = rollupOptions.output;
|
|
1690
|
-
for (const outputOptions of allOutputOptions) {
|
|
1691
|
-
const { output } = await buildResult.write(outputOptions);
|
|
1692
|
-
const chunkFileNames = /* @__PURE__ */ new Set();
|
|
1693
|
-
const outputChunks = output.filter(
|
|
1694
|
-
(e) => e.type === "chunk"
|
|
1695
|
-
);
|
|
1696
|
-
for (const entry of outputChunks) {
|
|
1697
|
-
chunkFileNames.add(entry.fileName);
|
|
1698
|
-
for (const id of entry.imports) {
|
|
1699
|
-
ctx.usedImports.add(id);
|
|
1700
|
-
}
|
|
1701
|
-
if (entry.isEntry) {
|
|
1702
|
-
ctx.buildEntries.push({
|
|
1703
|
-
chunks: entry.imports.filter(
|
|
1704
|
-
(i) => outputChunks.find((c) => c.fileName === i)
|
|
1705
|
-
),
|
|
1706
|
-
modules: Object.entries(entry.modules).map(([id, mod]) => ({
|
|
1707
|
-
id,
|
|
1708
|
-
bytes: mod.renderedLength
|
|
1709
|
-
})),
|
|
1710
|
-
path: entry.fileName,
|
|
1711
|
-
bytes: Buffer.byteLength(entry.code, "utf8"),
|
|
1712
|
-
exports: entry.exports
|
|
1713
|
-
});
|
|
1714
|
-
}
|
|
1715
|
-
}
|
|
1716
|
-
for (const chunkFileName of chunkFileNames) {
|
|
1717
|
-
ctx.usedImports.delete(chunkFileName);
|
|
1718
|
-
}
|
|
1719
|
-
}
|
|
1720
|
-
if (ctx.options.watch) {
|
|
1721
|
-
rollupWatch(rollupOptions);
|
|
1722
|
-
if (ctx.options.declaration && ctx.options.watch) {
|
|
1723
|
-
_consola2.default.warn("`rollup` DTS builder does not support watch mode yet.");
|
|
1724
|
-
}
|
|
1725
|
-
return;
|
|
1726
|
-
}
|
|
1727
|
-
if (ctx.options.declaration) {
|
|
1728
|
-
rollupOptions.plugins = [
|
|
1729
|
-
...rollupOptions.plugins,
|
|
1730
|
-
_rollupplugindts2.default.call(void 0, ctx.options.rollup.dts),
|
|
1731
|
-
removeShebangPlugin(),
|
|
1732
|
-
ctx.options.rollup.emitCJS && fixCJSExportTypePlugin()
|
|
1733
|
-
].filter(Boolean);
|
|
1734
|
-
await ctx.hooks.callHook("rollup:dts:options", ctx, rollupOptions);
|
|
1735
|
-
const typesBuild2 = await _rollup.rollup.call(void 0, rollupOptions);
|
|
1736
|
-
await ctx.hooks.callHook("rollup:dts:build", ctx, typesBuild2);
|
|
1737
|
-
if (ctx.options.rollup.emitCJS) {
|
|
1738
|
-
await typesBuild2.write({
|
|
1739
|
-
dir: _pathe.resolve.call(void 0, ctx.options.rootDir, ctx.options.outDir),
|
|
1740
|
-
entryFileNames: "[name].d.cts",
|
|
1741
|
-
chunkFileNames: /* @__PURE__ */ _chunk4WKFVYTIjs.__name.call(void 0, (chunk) => getChunkFilename(ctx, chunk, "d.cts"), "chunkFileNames")
|
|
1742
|
-
});
|
|
1743
|
-
}
|
|
1744
|
-
await typesBuild2.write({
|
|
1745
|
-
dir: _pathe.resolve.call(void 0, ctx.options.rootDir, ctx.options.outDir),
|
|
1746
|
-
entryFileNames: "[name].d.mts",
|
|
1747
|
-
chunkFileNames: /* @__PURE__ */ _chunk4WKFVYTIjs.__name.call(void 0, (chunk) => getChunkFilename(ctx, chunk, "d.mts"), "chunkFileNames")
|
|
1748
|
-
});
|
|
1749
|
-
if (ctx.options.declaration === true || ctx.options.declaration === "compatible") {
|
|
1750
|
-
await typesBuild2.write({
|
|
1751
|
-
dir: _pathe.resolve.call(void 0, ctx.options.rootDir, ctx.options.outDir),
|
|
1752
|
-
entryFileNames: "[name].d.ts",
|
|
1753
|
-
chunkFileNames: /* @__PURE__ */ _chunk4WKFVYTIjs.__name.call(void 0, (chunk) => getChunkFilename(ctx, chunk, "d.ts"), "chunkFileNames")
|
|
1754
|
-
});
|
|
1755
|
-
}
|
|
1756
|
-
}
|
|
1757
|
-
await ctx.hooks.callHook("rollup:done", ctx);
|
|
1758
|
-
}
|
|
1759
|
-
_chunk4WKFVYTIjs.__name.call(void 0, rollupBuild, "rollupBuild");
|
|
1760
|
-
async function typesBuild(ctx) {
|
|
1761
|
-
const entries = ctx.options.entries.filter(
|
|
1762
|
-
(entry) => entry.builder === "untyped"
|
|
1763
|
-
);
|
|
1764
|
-
await ctx.hooks.callHook("untyped:entries", ctx, entries);
|
|
1765
|
-
for (const entry of entries) {
|
|
1766
|
-
const options = {
|
|
1767
|
-
jiti: {
|
|
1768
|
-
interopDefault: true,
|
|
1769
|
-
transformOptions: {
|
|
1770
|
-
babel: {
|
|
1771
|
-
plugins: [_babelplugin2.default]
|
|
1772
|
-
}
|
|
1773
|
-
}
|
|
1774
|
-
}
|
|
1775
|
-
};
|
|
1776
|
-
await ctx.hooks.callHook("untyped:entry:options", ctx, entry, options);
|
|
1777
|
-
const untypedJiti = _jiti.createJiti.call(void 0, ctx.options.rootDir, options.jiti);
|
|
1778
|
-
const distDir = entry.outDir;
|
|
1779
|
-
let rawSchema = await untypedJiti.import(_pathe.resolve.call(void 0, ctx.options.rootDir, entry.input), {
|
|
1780
|
-
try: true
|
|
1781
|
-
}) || {};
|
|
1782
|
-
const rawSchemaKeys = Object.keys(rawSchema);
|
|
1783
|
-
if (rawSchemaKeys.length === 1 && rawSchemaKeys[0] === "default") {
|
|
1784
|
-
rawSchema = rawSchema.default;
|
|
1785
|
-
}
|
|
1786
|
-
const defaults2 = entry.defaults || {};
|
|
1787
|
-
const schema = await _untyped.resolveSchema.call(void 0, rawSchema, defaults2);
|
|
1788
|
-
await ctx.hooks.callHook("untyped:entry:schema", ctx, entry, schema);
|
|
1789
|
-
const outputs = {
|
|
1790
|
-
markdown: {
|
|
1791
|
-
fileName: _pathe.resolve.call(void 0, distDir, `${entry.name}.md`),
|
|
1792
|
-
contents: _untyped.generateMarkdown.call(void 0, schema)
|
|
1793
|
-
},
|
|
1794
|
-
schema: {
|
|
1795
|
-
fileName: `${entry.name}.schema.json`,
|
|
1796
|
-
contents: JSON.stringify(schema, null, 2)
|
|
1797
|
-
},
|
|
1798
|
-
defaults: {
|
|
1799
|
-
fileName: `${entry.name}.defaults.json`,
|
|
1800
|
-
contents: JSON.stringify(defaults2, null, 2)
|
|
1801
|
-
},
|
|
1802
|
-
declaration: entry.declaration ? {
|
|
1803
|
-
fileName: `${entry.name}.d.ts`,
|
|
1804
|
-
contents: _untyped.generateTypes.call(void 0, schema, {
|
|
1805
|
-
interfaceName: _scule.pascalCase.call(void 0, entry.name + "-schema")
|
|
1806
|
-
})
|
|
1807
|
-
} : void 0
|
|
1808
|
-
};
|
|
1809
|
-
await ctx.hooks.callHook("untyped:entry:outputs", ctx, entry, outputs);
|
|
1810
|
-
for (const output of Object.values(outputs)) {
|
|
1811
|
-
if (!output) continue;
|
|
1812
|
-
await _promises.writeFile.call(void 0,
|
|
1813
|
-
_pathe.resolve.call(void 0, distDir, output.fileName),
|
|
1814
|
-
output.contents,
|
|
1815
|
-
"utf8"
|
|
1816
|
-
);
|
|
1817
|
-
}
|
|
1818
|
-
}
|
|
1819
|
-
await ctx.hooks.callHook("untyped:done", ctx);
|
|
1820
|
-
if (entries.length > 0 && ctx.options.watch) {
|
|
1821
|
-
_consola2.default.warn("`untyped` builder does not support watch mode yet.");
|
|
1822
|
-
}
|
|
1823
|
-
}
|
|
1824
|
-
_chunk4WKFVYTIjs.__name.call(void 0, typesBuild, "typesBuild");
|
|
1825
|
-
async function mkdistBuild(ctx) {
|
|
1826
|
-
const entries = ctx.options.entries.filter(
|
|
1827
|
-
(e) => e.builder === "mkdist"
|
|
1828
|
-
);
|
|
1829
|
-
await ctx.hooks.callHook("mkdist:entries", ctx, entries);
|
|
1830
|
-
for (const entry of entries) {
|
|
1831
|
-
const distDir = entry.outDir;
|
|
1832
|
-
if (ctx.options.stub) {
|
|
1833
|
-
await rmdir(distDir);
|
|
1834
|
-
await symlink(entry.input, distDir);
|
|
1835
|
-
} else {
|
|
1836
|
-
const mkdistOptions = {
|
|
1837
|
-
rootDir: ctx.options.rootDir,
|
|
1838
|
-
srcDir: entry.input,
|
|
1839
|
-
distDir,
|
|
1840
|
-
cleanDist: false,
|
|
1841
|
-
...entry
|
|
1842
|
-
};
|
|
1843
|
-
await ctx.hooks.callHook(
|
|
1844
|
-
"mkdist:entry:options",
|
|
1845
|
-
ctx,
|
|
1846
|
-
entry,
|
|
1847
|
-
mkdistOptions
|
|
1848
|
-
);
|
|
1849
|
-
const output = await _mkdist.mkdist.call(void 0, mkdistOptions);
|
|
1850
|
-
ctx.buildEntries.push({
|
|
1851
|
-
path: distDir,
|
|
1852
|
-
chunks: output.writtenFiles.map((p) => _pathe.relative.call(void 0, ctx.options.outDir, p))
|
|
1853
|
-
});
|
|
1854
|
-
await ctx.hooks.callHook("mkdist:entry:build", ctx, entry, output);
|
|
1855
|
-
if (output.errors) {
|
|
1856
|
-
for (const error of output.errors) {
|
|
1857
|
-
warn(
|
|
1858
|
-
ctx,
|
|
1859
|
-
`mkdist build failed for \`${_pathe.relative.call(void 0, ctx.options.rootDir, error.filename)}\`:
|
|
1860
|
-
${error.errors.map((e) => ` - ${e}`).join("\n")}`
|
|
1861
|
-
);
|
|
1862
|
-
}
|
|
1863
|
-
}
|
|
1864
|
-
}
|
|
1865
|
-
}
|
|
1866
|
-
await ctx.hooks.callHook("mkdist:done", ctx);
|
|
1867
|
-
if (entries.length > 0 && ctx.options.watch) {
|
|
1868
|
-
_consola2.default.warn("`mkdist` builder does not support watch mode yet.");
|
|
1869
|
-
}
|
|
1870
|
-
}
|
|
1871
|
-
_chunk4WKFVYTIjs.__name.call(void 0, mkdistBuild, "mkdistBuild");
|
|
1872
|
-
var copy = _fs.promises.cp || _fs.promises.copyFile;
|
|
1873
|
-
async function copyBuild(ctx) {
|
|
1874
|
-
const entries = ctx.options.entries.filter(
|
|
1875
|
-
(e) => e.builder === "copy"
|
|
1876
|
-
);
|
|
1877
|
-
await ctx.hooks.callHook("copy:entries", ctx, entries);
|
|
1878
|
-
for (const entry of entries) {
|
|
1879
|
-
const distDir = entry.outDir;
|
|
1880
|
-
if (ctx.options.stub) {
|
|
1881
|
-
await rmdir(distDir);
|
|
1882
|
-
await symlink(entry.input, distDir);
|
|
1883
|
-
} else {
|
|
1884
|
-
const patterns = Array.isArray(entry.pattern) ? entry.pattern : [entry.pattern || "**"];
|
|
1885
|
-
const paths = await _tinyglobby.glob.call(void 0, patterns, {
|
|
1886
|
-
cwd: _pathe.resolve.call(void 0, ctx.options.rootDir, entry.input),
|
|
1887
|
-
absolute: false
|
|
1888
|
-
});
|
|
1889
|
-
const outputList = await Promise.allSettled(
|
|
1890
|
-
paths.map(async (path2) => {
|
|
1891
|
-
const src = _pathe.resolve.call(void 0, ctx.options.rootDir, entry.input, path2);
|
|
1892
|
-
const dist = _pathe.resolve.call(void 0, ctx.options.rootDir, distDir, path2);
|
|
1893
|
-
await copy(src, dist);
|
|
1894
|
-
return dist;
|
|
1895
|
-
})
|
|
1896
|
-
);
|
|
1897
|
-
for (const output of outputList) {
|
|
1898
|
-
if (output.status === "rejected") {
|
|
1899
|
-
warn(ctx, output.reason);
|
|
1900
|
-
}
|
|
1901
|
-
}
|
|
1902
|
-
ctx.buildEntries.push({
|
|
1903
|
-
path: distDir,
|
|
1904
|
-
chunks: outputList.filter(({ status }) => status === "fulfilled").map(
|
|
1905
|
-
(p) => _pathe.relative.call(void 0,
|
|
1906
|
-
ctx.options.outDir,
|
|
1907
|
-
p.value
|
|
1908
|
-
)
|
|
1909
|
-
)
|
|
1910
|
-
});
|
|
1911
|
-
}
|
|
1912
|
-
}
|
|
1913
|
-
await ctx.hooks.callHook("copy:done", ctx);
|
|
1914
|
-
if (entries.length > 0 && ctx.options.watch) {
|
|
1915
|
-
_consola2.default.warn("`untyped` builder does not support watch mode yet.");
|
|
1916
|
-
}
|
|
1917
|
-
}
|
|
1918
|
-
_chunk4WKFVYTIjs.__name.call(void 0, copyBuild, "copyBuild");
|
|
1919
|
-
async function build(rootDir, stub, inputConfig = {}) {
|
|
1920
|
-
rootDir = _pathe.resolve.call(void 0, process.cwd(), rootDir || ".");
|
|
1921
|
-
const jiti = _jiti.createJiti.call(void 0, rootDir);
|
|
1922
|
-
const _buildConfig = await jiti.import(_optionalChain([inputConfig, 'optionalAccess', _66 => _66.config]) || "./build.config", {
|
|
1923
|
-
try: !inputConfig.config,
|
|
1924
|
-
default: true
|
|
1925
|
-
}) || {};
|
|
1926
|
-
const buildConfigs = (Array.isArray(_buildConfig) ? _buildConfig : [_buildConfig]).filter(Boolean);
|
|
1927
|
-
const pkg = await jiti.import("./package.json", {
|
|
1928
|
-
try: true,
|
|
1929
|
-
default: true
|
|
1930
|
-
}) || {};
|
|
1931
|
-
const cleanedDirs = [];
|
|
1932
|
-
const _watchMode = inputConfig.watch === true;
|
|
1933
|
-
const _stubMode = !_watchMode && (stub || inputConfig.stub === true);
|
|
1934
|
-
for (const buildConfig of buildConfigs) {
|
|
1935
|
-
await _build(
|
|
1936
|
-
rootDir,
|
|
1937
|
-
inputConfig,
|
|
1938
|
-
buildConfig,
|
|
1939
|
-
pkg,
|
|
1940
|
-
cleanedDirs,
|
|
1941
|
-
_stubMode,
|
|
1942
|
-
_watchMode
|
|
1943
|
-
);
|
|
1944
|
-
}
|
|
1945
|
-
}
|
|
1946
|
-
_chunk4WKFVYTIjs.__name.call(void 0, build, "build");
|
|
1947
|
-
async function _build(rootDir, inputConfig = {}, buildConfig, pkg, cleanedDirs, _stubMode, _watchMode) {
|
|
1948
|
-
const preset = await resolvePreset(
|
|
1949
|
-
buildConfig.preset || _optionalChain([pkg, 'access', _67 => _67.unbuild, 'optionalAccess', _68 => _68.preset]) || _optionalChain([pkg, 'access', _69 => _69.build, 'optionalAccess', _70 => _70.preset]) || inputConfig.preset || "auto",
|
|
1950
|
-
rootDir
|
|
1951
|
-
);
|
|
1952
|
-
const options = _defu.defu.call(void 0,
|
|
1953
|
-
buildConfig,
|
|
1954
|
-
pkg.unbuild || pkg.build,
|
|
1955
|
-
inputConfig,
|
|
1956
|
-
preset,
|
|
1957
|
-
{
|
|
1958
|
-
name: (_optionalChain([pkg, 'optionalAccess', _71 => _71.name]) || "").split("/").pop() || "default",
|
|
1959
|
-
rootDir,
|
|
1960
|
-
entries: [],
|
|
1961
|
-
clean: true,
|
|
1962
|
-
declaration: void 0,
|
|
1963
|
-
outDir: "dist",
|
|
1964
|
-
stub: _stubMode,
|
|
1965
|
-
stubOptions: {
|
|
1966
|
-
/**
|
|
1967
|
-
* See https://github.com/unjs/jiti#%EF%B8%8F-options
|
|
1968
|
-
*/
|
|
1969
|
-
jiti: {
|
|
1970
|
-
interopDefault: true,
|
|
1971
|
-
alias: {}
|
|
1972
|
-
}
|
|
1973
|
-
},
|
|
1974
|
-
watch: _watchMode,
|
|
1975
|
-
watchOptions: _watchMode ? {
|
|
1976
|
-
exclude: "node_modules/**",
|
|
1977
|
-
include: "src/**"
|
|
1978
|
-
} : void 0,
|
|
1979
|
-
externals: [
|
|
1980
|
-
..._module2.default.builtinModules,
|
|
1981
|
-
..._module2.default.builtinModules.map((m) => "node:" + m)
|
|
1982
|
-
],
|
|
1983
|
-
dependencies: [],
|
|
1984
|
-
devDependencies: [],
|
|
1985
|
-
peerDependencies: [],
|
|
1986
|
-
alias: {},
|
|
1987
|
-
replace: {},
|
|
1988
|
-
failOnWarn: true,
|
|
1989
|
-
sourcemap: false,
|
|
1990
|
-
rollup: {
|
|
1991
|
-
emitCJS: false,
|
|
1992
|
-
watch: false,
|
|
1993
|
-
cjsBridge: false,
|
|
1994
|
-
inlineDependencies: false,
|
|
1995
|
-
preserveDynamicImports: true,
|
|
1996
|
-
output: {
|
|
1997
|
-
// https://v8.dev/features/import-attributes
|
|
1998
|
-
importAttributesKey: "with"
|
|
1999
|
-
},
|
|
2000
|
-
// Plugins
|
|
2001
|
-
replace: {
|
|
2002
|
-
preventAssignment: true
|
|
2003
|
-
},
|
|
2004
|
-
alias: {},
|
|
2005
|
-
resolve: {
|
|
2006
|
-
preferBuiltins: true
|
|
2007
|
-
},
|
|
2008
|
-
json: {
|
|
2009
|
-
preferConst: true
|
|
2010
|
-
},
|
|
2011
|
-
commonjs: {
|
|
2012
|
-
ignoreTryCatch: true
|
|
2013
|
-
},
|
|
2014
|
-
esbuild: { target: "esnext" },
|
|
2015
|
-
dts: {
|
|
2016
|
-
// https://github.com/Swatinem/rollup-plugin-dts/issues/143
|
|
2017
|
-
compilerOptions: { preserveSymlinks: false },
|
|
2018
|
-
respectExternal: true
|
|
2019
|
-
}
|
|
2020
|
-
},
|
|
2021
|
-
parallel: false
|
|
2022
|
-
}
|
|
2023
|
-
);
|
|
2024
|
-
options.outDir = _pathe.resolve.call(void 0, options.rootDir, options.outDir);
|
|
2025
|
-
const jiti = _jiti.createJiti.call(void 0, options.rootDir, { interopDefault: true });
|
|
2026
|
-
const ctx = {
|
|
2027
|
-
options,
|
|
2028
|
-
jiti,
|
|
2029
|
-
warnings: /* @__PURE__ */ new Set(),
|
|
2030
|
-
pkg,
|
|
2031
|
-
buildEntries: [],
|
|
2032
|
-
usedImports: /* @__PURE__ */ new Set(),
|
|
2033
|
-
hooks: _hookable.createHooks.call(void 0, )
|
|
2034
|
-
};
|
|
2035
|
-
if (preset.hooks) {
|
|
2036
|
-
ctx.hooks.addHooks(preset.hooks);
|
|
2037
|
-
}
|
|
2038
|
-
if (inputConfig.hooks) {
|
|
2039
|
-
ctx.hooks.addHooks(inputConfig.hooks);
|
|
2040
|
-
}
|
|
2041
|
-
if (buildConfig.hooks) {
|
|
2042
|
-
ctx.hooks.addHooks(buildConfig.hooks);
|
|
2043
|
-
}
|
|
2044
|
-
await ctx.hooks.callHook("build:prepare", ctx);
|
|
2045
|
-
options.entries = options.entries.map(
|
|
2046
|
-
(entry) => typeof entry === "string" ? { input: entry } : entry
|
|
2047
|
-
);
|
|
2048
|
-
for (const entry of options.entries) {
|
|
2049
|
-
if (typeof entry.name !== "string") {
|
|
2050
|
-
let relativeInput = _pathe.isAbsolute.call(void 0, entry.input) ? _pathe.relative.call(void 0, rootDir, entry.input) : _pathe.normalize.call(void 0, entry.input);
|
|
2051
|
-
if (relativeInput.startsWith("./")) {
|
|
2052
|
-
relativeInput = relativeInput.slice(2);
|
|
2053
|
-
}
|
|
2054
|
-
entry.name = removeExtension(relativeInput.replace(/^src\//, ""));
|
|
2055
|
-
}
|
|
2056
|
-
if (!entry.input) {
|
|
2057
|
-
throw new Error("Missing entry input: " + dumpObject(entry));
|
|
2058
|
-
}
|
|
2059
|
-
if (!entry.builder) {
|
|
2060
|
-
entry.builder = entry.input.endsWith("/") ? "mkdist" : "rollup";
|
|
2061
|
-
}
|
|
2062
|
-
if (options.declaration !== void 0 && entry.declaration === void 0) {
|
|
2063
|
-
entry.declaration = options.declaration;
|
|
2064
|
-
}
|
|
2065
|
-
entry.input = _pathe.resolve.call(void 0, options.rootDir, entry.input);
|
|
2066
|
-
entry.outDir = _pathe.resolve.call(void 0, options.rootDir, entry.outDir || options.outDir);
|
|
2067
|
-
}
|
|
2068
|
-
options.dependencies = Object.keys(pkg.dependencies || {});
|
|
2069
|
-
options.peerDependencies = Object.keys(pkg.peerDependencies || {});
|
|
2070
|
-
options.devDependencies = Object.keys(pkg.devDependencies || {});
|
|
2071
|
-
options.externals.push(...inferPkgExternals(pkg));
|
|
2072
|
-
options.externals = [...new Set(options.externals)];
|
|
2073
|
-
await ctx.hooks.callHook("build:before", ctx);
|
|
2074
|
-
_consola.consola.info(
|
|
2075
|
-
_utils.colors.cyan(`${options.stub ? "Stubbing" : "Building"} ${options.name}`)
|
|
2076
|
-
);
|
|
2077
|
-
if (process.env.DEBUG) {
|
|
2078
|
-
_consola.consola.info(`${_utils.colors.bold("Root dir:")} ${options.rootDir}
|
|
2079
|
-
${_utils.colors.bold("Entries:")}
|
|
2080
|
-
${options.entries.map((entry) => " " + dumpObject(entry)).join("\n ")}
|
|
2081
|
-
`);
|
|
2082
|
-
}
|
|
2083
|
-
if (options.clean) {
|
|
2084
|
-
for (const dir of new Set(
|
|
2085
|
-
options.entries.map((e) => e.outDir).filter(Boolean).sort()
|
|
2086
|
-
)) {
|
|
2087
|
-
if (dir === options.rootDir || options.rootDir.startsWith(withTrailingSlash(dir)) || cleanedDirs.some((c) => dir.startsWith(c))) {
|
|
2088
|
-
continue;
|
|
2089
|
-
}
|
|
2090
|
-
cleanedDirs.push(dir);
|
|
2091
|
-
_consola.consola.info(
|
|
2092
|
-
`Cleaning dist directory: \`./${_pathe.relative.call(void 0, process.cwd(), dir)}\``
|
|
2093
|
-
);
|
|
2094
|
-
await rmdir(dir);
|
|
2095
|
-
await _fs.promises.mkdir(dir, { recursive: true });
|
|
2096
|
-
}
|
|
2097
|
-
}
|
|
2098
|
-
const buildTasks = [
|
|
2099
|
-
typesBuild,
|
|
2100
|
-
// untyped
|
|
2101
|
-
mkdistBuild,
|
|
2102
|
-
// mkdist
|
|
2103
|
-
rollupBuild,
|
|
2104
|
-
// rollup
|
|
2105
|
-
copyBuild
|
|
2106
|
-
// copy
|
|
2107
|
-
];
|
|
2108
|
-
if (options.parallel) {
|
|
2109
|
-
await Promise.all(buildTasks.map((task) => task(ctx)));
|
|
2110
|
-
} else {
|
|
2111
|
-
for (const task of buildTasks) {
|
|
2112
|
-
await task(ctx);
|
|
2113
|
-
}
|
|
2114
|
-
}
|
|
2115
|
-
if (options.stub || options.watch) {
|
|
2116
|
-
await ctx.hooks.callHook("build:done", ctx);
|
|
2117
|
-
return;
|
|
2118
|
-
}
|
|
2119
|
-
_consola.consola.success(_utils.colors.green("Build succeeded for " + options.name));
|
|
2120
|
-
const outFiles = await _tinyglobby.glob.call(void 0, ["**"], { cwd: options.outDir });
|
|
2121
|
-
for (const file of outFiles) {
|
|
2122
|
-
let entry = ctx.buildEntries.find((e) => e.path === file);
|
|
2123
|
-
if (!entry) {
|
|
2124
|
-
entry = {
|
|
2125
|
-
path: file,
|
|
2126
|
-
chunk: true
|
|
2127
|
-
};
|
|
2128
|
-
ctx.buildEntries.push(entry);
|
|
2129
|
-
}
|
|
2130
|
-
if (!entry.bytes) {
|
|
2131
|
-
const stat = await _fs.promises.stat(_pathe.resolve.call(void 0, options.outDir, file));
|
|
2132
|
-
entry.bytes = stat.size;
|
|
2133
|
-
}
|
|
2134
|
-
}
|
|
2135
|
-
const rPath = /* @__PURE__ */ _chunk4WKFVYTIjs.__name.call(void 0, (p) => _pathe.relative.call(void 0, process.cwd(), _pathe.resolve.call(void 0, options.outDir, p)), "rPath");
|
|
2136
|
-
for (const entry of ctx.buildEntries.filter((e) => !e.chunk)) {
|
|
2137
|
-
let totalBytes = entry.bytes || 0;
|
|
2138
|
-
for (const chunk of entry.chunks || []) {
|
|
2139
|
-
totalBytes += _optionalChain([ctx, 'access', _72 => _72.buildEntries, 'access', _73 => _73.find, 'call', _74 => _74((e) => e.path === chunk), 'optionalAccess', _75 => _75.bytes]) || 0;
|
|
2140
|
-
}
|
|
2141
|
-
let line = ` ${_utils.colors.bold(rPath(entry.path))} (` + [
|
|
2142
|
-
totalBytes && `total size: ${_utils.colors.cyan(_prettybytes2.default.call(void 0, totalBytes))}`,
|
|
2143
|
-
entry.bytes && `chunk size: ${_utils.colors.cyan(_prettybytes2.default.call(void 0, entry.bytes))}`,
|
|
2144
|
-
_optionalChain([entry, 'access', _76 => _76.exports, 'optionalAccess', _77 => _77.length]) && `exports: ${_utils.colors.gray(entry.exports.join(", "))}`
|
|
2145
|
-
].filter(Boolean).join(", ") + ")";
|
|
2146
|
-
if (_optionalChain([entry, 'access', _78 => _78.chunks, 'optionalAccess', _79 => _79.length])) {
|
|
2147
|
-
line += "\n" + entry.chunks.map((p) => {
|
|
2148
|
-
const chunk = ctx.buildEntries.find((e) => e.path === p) || {};
|
|
2149
|
-
return _utils.colors.gray(
|
|
2150
|
-
" \u2514\u2500 " + rPath(p) + _utils.colors.bold(
|
|
2151
|
-
chunk.bytes ? ` (${_prettybytes2.default.call(void 0, _optionalChain([chunk, 'optionalAccess', _80 => _80.bytes]))})` : ""
|
|
2152
|
-
)
|
|
2153
|
-
);
|
|
2154
|
-
}).join("\n");
|
|
2155
|
-
}
|
|
2156
|
-
if (_optionalChain([entry, 'access', _81 => _81.modules, 'optionalAccess', _82 => _82.length])) {
|
|
2157
|
-
line += "\n" + entry.modules.filter((m) => m.id.includes("node_modules")).sort((a, b) => (b.bytes || 0) - (a.bytes || 0)).map((m) => {
|
|
2158
|
-
return _utils.colors.gray(
|
|
2159
|
-
" \u{1F4E6} " + rPath(m.id) + _utils.colors.bold(m.bytes ? ` (${_prettybytes2.default.call(void 0, m.bytes)})` : "")
|
|
2160
|
-
);
|
|
2161
|
-
}).join("\n");
|
|
2162
|
-
}
|
|
2163
|
-
_consola.consola.log(entry.chunk ? _utils.colors.gray(line) : line);
|
|
2164
|
-
}
|
|
2165
|
-
console.log(
|
|
2166
|
-
"\u03A3 Total dist size (byte size):",
|
|
2167
|
-
_utils.colors.cyan(
|
|
2168
|
-
_prettybytes2.default.call(void 0, ctx.buildEntries.reduce((a, e) => a + (e.bytes || 0), 0))
|
|
2169
|
-
)
|
|
2170
|
-
);
|
|
2171
|
-
validateDependencies(ctx);
|
|
2172
|
-
validatePackage(pkg, rootDir, ctx);
|
|
2173
|
-
await ctx.hooks.callHook("build:done", ctx);
|
|
2174
|
-
_consola.consola.log("");
|
|
2175
|
-
if (ctx.warnings.size > 0) {
|
|
2176
|
-
_consola.consola.warn(
|
|
2177
|
-
"Build is done with some warnings:\n\n" + [...ctx.warnings].map((msg) => "- " + msg).join("\n")
|
|
2178
|
-
);
|
|
2179
|
-
if (ctx.options.failOnWarn) {
|
|
2180
|
-
_consola.consola.error(
|
|
2181
|
-
"Exiting with code (1). You can change this behavior by setting `failOnWarn: false` ."
|
|
2182
|
-
);
|
|
2183
|
-
process.exit(1);
|
|
2184
|
-
}
|
|
2185
|
-
}
|
|
2186
|
-
}
|
|
2187
|
-
_chunk4WKFVYTIjs.__name.call(void 0, _build, "_build");
|
|
2188
|
-
|
|
2189
|
-
// ../../node_modules/.pnpm/unbuild@3.3.1_sass@1.83.4_typescript@5.7.3/node_modules/unbuild/dist/index.mjs
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
// src/build.ts
|
|
2219
|
-
async function resolveOptions(options) {
|
|
2220
|
-
const projectRoot = options.projectRoot;
|
|
2221
|
-
if (!projectRoot) {
|
|
2222
|
-
throw new Error("Cannot find project root");
|
|
2223
|
-
}
|
|
2224
|
-
const outputPath = options.outputPath || _chunkUUI4UWA4js.joinPaths.call(void 0, "dist", projectRoot);
|
|
2225
|
-
const workspaceRoot = _findworkspaceroot.findWorkspaceRoot.call(void 0, projectRoot);
|
|
2226
|
-
if (!workspaceRoot) {
|
|
2227
|
-
throw new Error("Cannot find workspace root");
|
|
2228
|
-
}
|
|
2229
|
-
const config = await loadStormConfig(workspaceRoot.dir);
|
|
2230
|
-
_chunkUUI4UWA4js.writeDebug.call(void 0, " \u2699\uFE0F Resolving build options", config);
|
|
2231
|
-
const stopwatch = _chunkUUI4UWA4js.getStopwatch.call(void 0, "Build options resolution");
|
|
2232
|
-
if (options.configPath) {
|
|
2233
|
-
const configFile = await _chunkB2WY6JG2js.loadConfig.call(void 0, options.configPath);
|
|
2234
|
-
if (configFile) {
|
|
2235
|
-
options = _defu2.default.call(void 0, options, configFile);
|
|
2236
|
-
}
|
|
2237
|
-
}
|
|
2238
|
-
const projectGraph = _devkit.readCachedProjectGraph.call(void 0, );
|
|
2239
|
-
const projectJsonPath = _chunkUUI4UWA4js.joinPaths.call(void 0, config.workspaceRoot, projectRoot, "project.json");
|
|
2240
|
-
if (!_fs.existsSync.call(void 0, projectJsonPath)) {
|
|
2241
|
-
throw new Error("Cannot find project.json configuration");
|
|
2242
|
-
}
|
|
2243
|
-
const projectJsonContent = await _promises.readFile.call(void 0, projectJsonPath, "utf8");
|
|
2244
|
-
const projectJson = JSON.parse(projectJsonContent);
|
|
2245
|
-
const projectName = projectJson.name;
|
|
2246
|
-
const packageJsonPath = _chunkUUI4UWA4js.joinPaths.call(void 0, workspaceRoot.dir, projectRoot, "package.json");
|
|
2247
|
-
if (!_fs.existsSync.call(void 0, packageJsonPath)) {
|
|
2248
|
-
throw new Error("Cannot find package.json configuration");
|
|
2249
|
-
}
|
|
2250
|
-
const packageJsonContent = await _promises.readFile.call(void 0, packageJsonPath, "utf8");
|
|
2251
|
-
const packageJson = JSON.parse(packageJsonContent);
|
|
2252
|
-
let tsconfig = options.tsconfig;
|
|
2253
|
-
if (!tsconfig) {
|
|
2254
|
-
tsconfig = _chunkUUI4UWA4js.joinPaths.call(void 0, workspaceRoot.dir, projectRoot, "tsconfig.json");
|
|
2255
|
-
}
|
|
2256
|
-
if (!_fs.existsSync.call(void 0, tsconfig)) {
|
|
2257
|
-
throw new Error("Cannot find tsconfig.json configuration");
|
|
2258
|
-
}
|
|
2259
|
-
let sourceRoot = projectJson.sourceRoot;
|
|
2260
|
-
if (!sourceRoot) {
|
|
2261
|
-
sourceRoot = _chunkUUI4UWA4js.joinPaths.call(void 0, projectRoot, "src");
|
|
2262
|
-
}
|
|
2263
|
-
if (!_fs.existsSync.call(void 0, sourceRoot)) {
|
|
2264
|
-
throw new Error("Cannot find sourceRoot directory");
|
|
2265
|
-
}
|
|
2266
|
-
const result = _buildablelibsutils.calculateProjectBuildableDependencies.call(void 0, void 0, projectGraph, workspaceRoot.dir, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
|
|
2267
|
-
let dependencies = result.dependencies;
|
|
2268
|
-
const tsLibDependency = _js.getHelperDependency.call(void 0, _js.HelperDependency.tsc, tsconfig, dependencies, projectGraph, true);
|
|
2269
|
-
if (tsLibDependency) {
|
|
2270
|
-
dependencies = dependencies.filter((deps) => deps.name !== tsLibDependency.name);
|
|
2271
|
-
dependencies.push(tsLibDependency);
|
|
2272
|
-
}
|
|
2273
|
-
const resolvedOptions = {
|
|
2274
|
-
name: projectName,
|
|
2275
|
-
config,
|
|
2276
|
-
projectRoot,
|
|
2277
|
-
sourceRoot,
|
|
2278
|
-
projectName,
|
|
2279
|
-
tsconfig,
|
|
2280
|
-
clean: false,
|
|
2281
|
-
entries: [
|
|
2282
|
-
{
|
|
2283
|
-
builder: "mkdist",
|
|
2284
|
-
input: `.${sourceRoot.replace(projectRoot, "")}`,
|
|
2285
|
-
outDir: _chunkUUI4UWA4js.joinPaths.call(void 0, _path.relative.call(void 0, _chunkUUI4UWA4js.joinPaths.call(void 0, config.workspaceRoot, projectRoot), config.workspaceRoot).replaceAll("\\", "/"), outputPath, "dist").replaceAll("\\", "/"),
|
|
2286
|
-
declaration: options.emitTypes !== false,
|
|
2287
|
-
format: "esm"
|
|
2288
|
-
},
|
|
2289
|
-
{
|
|
2290
|
-
builder: "mkdist",
|
|
2291
|
-
input: `.${sourceRoot.replace(projectRoot, "")}`,
|
|
2292
|
-
outDir: _chunkUUI4UWA4js.joinPaths.call(void 0, _path.relative.call(void 0, _chunkUUI4UWA4js.joinPaths.call(void 0, config.workspaceRoot, projectRoot), config.workspaceRoot).replaceAll("\\", "/"), outputPath, "dist").replaceAll("\\", "/"),
|
|
2293
|
-
declaration: options.emitTypes !== false,
|
|
2294
|
-
format: "cjs",
|
|
2295
|
-
ext: "cjs"
|
|
2296
|
-
}
|
|
2297
|
-
],
|
|
2298
|
-
declaration: options.emitTypes !== false ? "compatible" : false,
|
|
2299
|
-
failOnWarn: false,
|
|
2300
|
-
sourcemap: _nullishCoalesce(options.sourcemap, () => ( !!options.debug)),
|
|
2301
|
-
outDir: outputPath,
|
|
2302
|
-
parallel: true,
|
|
2303
|
-
stub: false,
|
|
2304
|
-
stubOptions: {
|
|
2305
|
-
jiti: {}
|
|
2306
|
-
},
|
|
2307
|
-
externals: _nullishCoalesce(options.external, () => ( [])),
|
|
2308
|
-
dependencies: [],
|
|
2309
|
-
peerDependencies: [],
|
|
2310
|
-
devDependencies: [],
|
|
2311
|
-
hooks: {},
|
|
2312
|
-
alias: {},
|
|
2313
|
-
replace: {},
|
|
2314
|
-
rollup: {
|
|
2315
|
-
replace: {},
|
|
2316
|
-
alias: {},
|
|
2317
|
-
json: {},
|
|
2318
|
-
commonjs: {
|
|
2319
|
-
sourceMap: _nullishCoalesce(options.sourcemap, () => ( true))
|
|
2320
|
-
},
|
|
2321
|
-
emitCJS: true,
|
|
2322
|
-
cjsBridge: true,
|
|
2323
|
-
dts: {
|
|
2324
|
-
respectExternal: true,
|
|
2325
|
-
tsconfig
|
|
2326
|
-
},
|
|
2327
|
-
output: {
|
|
2328
|
-
banner: options.banner || `
|
|
2329
|
-
// \u26A1 Built by Storm Software
|
|
2330
|
-
`,
|
|
2331
|
-
footer: options.footer
|
|
2332
|
-
},
|
|
2333
|
-
resolve: {
|
|
2334
|
-
preferBuiltins: true,
|
|
2335
|
-
extensions: [
|
|
2336
|
-
".cjs",
|
|
2337
|
-
".mjs",
|
|
2338
|
-
".js",
|
|
2339
|
-
".jsx",
|
|
2340
|
-
".ts",
|
|
2341
|
-
".tsx",
|
|
2342
|
-
".json"
|
|
2343
|
-
]
|
|
2344
|
-
},
|
|
2345
|
-
esbuild: {
|
|
2346
|
-
minify: !!options.minify,
|
|
2347
|
-
splitting: options.splitting !== false,
|
|
2348
|
-
treeShaking: options.treeShaking !== false,
|
|
2349
|
-
color: true,
|
|
2350
|
-
logLevel: config.logLevel === _chunkUUI4UWA4js.LogLevelLabel.FATAL ? _chunkUUI4UWA4js.LogLevelLabel.ERROR : _chunkUUI4UWA4js.isVerbose.call(void 0, ) ? "verbose" : config.logLevel
|
|
2351
|
-
}
|
|
2352
|
-
}
|
|
2353
|
-
};
|
|
2354
|
-
dependencies = dependencies.filter((dep) => dep.node.type === "npm" || dep.node.type === "lib" || dep.node.type === "app");
|
|
2355
|
-
if (dependencies.length > 0) {
|
|
2356
|
-
resolvedOptions.dependencies = dependencies.map((dep) => dep.name);
|
|
2357
|
-
}
|
|
2358
|
-
if (packageJson.devDependencies) {
|
|
2359
|
-
resolvedOptions.devDependencies = Object.keys(packageJson.devDependencies);
|
|
2360
|
-
}
|
|
2361
|
-
if (packageJson.peerDependencies) {
|
|
2362
|
-
resolvedOptions.peerDependencies = Object.keys(packageJson.peerDependencies);
|
|
2363
|
-
}
|
|
2364
|
-
if (options.rollup) {
|
|
2365
|
-
let rollup2 = {};
|
|
2366
|
-
if (typeof options.rollup === "string") {
|
|
2367
|
-
const rollupFile = await _chunkB2WY6JG2js.loadConfig.call(void 0, options.rollup);
|
|
2368
|
-
if (rollupFile) {
|
|
2369
|
-
rollup2 = rollupFile;
|
|
2370
|
-
}
|
|
2371
|
-
} else {
|
|
2372
|
-
rollup2 = options.rollup;
|
|
2373
|
-
}
|
|
2374
|
-
resolvedOptions.rollup = _defu2.default.call(void 0, _nullishCoalesce(resolvedOptions.rollup, () => ( {})), rollup2);
|
|
2375
|
-
}
|
|
2376
|
-
resolvedOptions.hooks = {
|
|
2377
|
-
"rollup:options": /* @__PURE__ */ _chunk4WKFVYTIjs.__name.call(void 0, async (ctx, opts) => {
|
|
2378
|
-
opts.plugins = await _asyncNullishCoalesce(options.plugins, async () => ( await _chunkJ5YBLOB7js.getDefaultBuildPlugins.call(void 0, options, resolvedOptions)));
|
|
2379
|
-
}, "rollup:options")
|
|
2380
|
-
};
|
|
2381
|
-
stopwatch();
|
|
2382
|
-
return resolvedOptions;
|
|
2383
|
-
}
|
|
2384
|
-
_chunk4WKFVYTIjs.__name.call(void 0, resolveOptions, "resolveOptions");
|
|
2385
|
-
async function generatePackageJson(options) {
|
|
2386
|
-
if (options.generatePackageJson !== false && _fs.existsSync.call(void 0, _chunkUUI4UWA4js.joinPaths.call(void 0, options.projectRoot, "package.json"))) {
|
|
2387
|
-
_chunkUUI4UWA4js.writeDebug.call(void 0, " \u270D\uFE0F Writing package.json file", options.config);
|
|
2388
|
-
const stopwatch = _chunkUUI4UWA4js.getStopwatch.call(void 0, "Write package.json file");
|
|
2389
|
-
const packageJsonPath = _chunkUUI4UWA4js.joinPaths.call(void 0, options.projectRoot, "project.json");
|
|
2390
|
-
if (!_fs.existsSync.call(void 0, packageJsonPath)) {
|
|
2391
|
-
throw new Error("Cannot find package.json configuration");
|
|
2392
|
-
}
|
|
2393
|
-
let packageJsonContent = await _promises.readFile.call(void 0, _chunkUUI4UWA4js.joinPaths.call(void 0, options.config.workspaceRoot, options.projectRoot, "package.json"), "utf8");
|
|
2394
|
-
if (!packageJsonContent) {
|
|
2395
|
-
throw new Error("Cannot find package.json configuration file");
|
|
2396
|
-
}
|
|
2397
|
-
let packageJson = JSON.parse(packageJsonContent);
|
|
2398
|
-
packageJson = await addPackageDependencies(options.config.workspaceRoot, options.projectRoot, options.projectName, packageJson);
|
|
2399
|
-
packageJson = await addWorkspacePackageJsonFields(options.config, options.projectRoot, options.sourceRoot, options.projectName, false, packageJson);
|
|
2400
|
-
await _devkit.writeJsonFile.call(void 0, _chunkUUI4UWA4js.joinPaths.call(void 0, options.outDir, "package.json"), await addPackageJsonExports(options.sourceRoot, packageJson));
|
|
2401
|
-
stopwatch();
|
|
2402
|
-
}
|
|
2403
|
-
return options;
|
|
2404
|
-
}
|
|
2405
|
-
_chunk4WKFVYTIjs.__name.call(void 0, generatePackageJson, "generatePackageJson");
|
|
2406
|
-
async function executeUnbuild(options) {
|
|
2407
|
-
_chunkUUI4UWA4js.writeDebug.call(void 0, ` \u{1F680} Running ${options.name} (${options.projectRoot}) build`, options.config);
|
|
2408
|
-
const stopwatch = _chunkUUI4UWA4js.getStopwatch.call(void 0, `${options.name} (${options.projectRoot}) build`);
|
|
2409
|
-
try {
|
|
2410
|
-
await build(options.projectRoot, false, {
|
|
2411
|
-
...options,
|
|
2412
|
-
rootDir: options.projectRoot
|
|
2413
|
-
});
|
|
2414
|
-
} finally {
|
|
2415
|
-
stopwatch();
|
|
2416
|
-
}
|
|
2417
|
-
return options;
|
|
2418
|
-
}
|
|
2419
|
-
_chunk4WKFVYTIjs.__name.call(void 0, executeUnbuild, "executeUnbuild");
|
|
2420
|
-
async function copyBuildAssets(options) {
|
|
2421
|
-
_chunkUUI4UWA4js.writeDebug.call(void 0, ` \u{1F4CB} Copying asset files to output directory: ${options.outDir}`, options.config);
|
|
2422
|
-
const stopwatch = _chunkUUI4UWA4js.getStopwatch.call(void 0, `${options.name} asset copy`);
|
|
2423
|
-
await copyAssets(options.config, _nullishCoalesce(options.assets, () => ( [])), options.outDir, options.projectRoot, options.projectName, options.sourceRoot, options.generatePackageJson, options.includeSrc);
|
|
2424
|
-
stopwatch();
|
|
2425
|
-
return options;
|
|
2426
|
-
}
|
|
2427
|
-
_chunk4WKFVYTIjs.__name.call(void 0, copyBuildAssets, "copyBuildAssets");
|
|
2428
|
-
async function cleanOutputPath(options) {
|
|
2429
|
-
if (options.clean !== false && options.outDir) {
|
|
2430
|
-
await _chunkE73BVQF5js.clean.call(void 0, options.name, options.outDir, options.config);
|
|
2431
|
-
}
|
|
2432
|
-
return options;
|
|
2433
|
-
}
|
|
2434
|
-
_chunk4WKFVYTIjs.__name.call(void 0, cleanOutputPath, "cleanOutputPath");
|
|
2435
|
-
async function build2(options) {
|
|
2436
|
-
_chunkUUI4UWA4js.writeDebug.call(void 0, ` \u26A1 Executing Storm Unbuild pipeline`);
|
|
2437
|
-
const stopwatch = _chunkUUI4UWA4js.getStopwatch.call(void 0, "Unbuild pipeline");
|
|
2438
|
-
try {
|
|
2439
|
-
const resolvedOptions = await resolveOptions(options);
|
|
2440
|
-
await cleanOutputPath(resolvedOptions);
|
|
2441
|
-
await generatePackageJson(resolvedOptions);
|
|
2442
|
-
await executeUnbuild(resolvedOptions);
|
|
2443
|
-
await copyBuildAssets(resolvedOptions);
|
|
2444
|
-
_chunkUUI4UWA4js.writeSuccess.call(void 0, ` \u{1F3C1} The ${resolvedOptions.name} build completed successfully`, resolvedOptions.config);
|
|
2445
|
-
} catch (error) {
|
|
2446
|
-
_chunkUUI4UWA4js.writeFatal.call(void 0, " \u274C Fatal errors occurred during the build that could not be recovered from. The build process has been terminated.");
|
|
2447
|
-
throw error;
|
|
2448
|
-
} finally {
|
|
2449
|
-
stopwatch();
|
|
2450
|
-
}
|
|
2451
|
-
}
|
|
2452
|
-
_chunk4WKFVYTIjs.__name.call(void 0, build2, "build");
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
exports.build = build2;
|