@storm-software/unbuild 0.26.2 → 0.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/unbuild.cjs +75 -76
- package/bin/unbuild.js +75 -76
- package/dist/build.cjs +12 -2
- package/dist/build.d.cts +25 -2
- package/dist/build.d.ts +25 -2
- package/dist/build.js +13 -3
- package/dist/{chunk-PEWJLNIH.js → chunk-DORAESSZ.js} +80 -76
- package/dist/{chunk-RLJB5Z47.cjs → chunk-SN3G5SIP.cjs} +97 -93
- package/dist/index.cjs +12 -2
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +13 -3
- package/dist/types.d.cts +6 -0
- package/dist/types.d.ts +6 -0
- package/package.json +3 -2
package/bin/unbuild.cjs
CHANGED
|
@@ -1170,27 +1170,23 @@ var readNxConfig = /* @__PURE__ */ __name(async (workspaceRoot) => {
|
|
|
1170
1170
|
// ../build-tools/src/utilities/copy-assets.ts
|
|
1171
1171
|
var copyAssets = /* @__PURE__ */ __name(async (config, assets, outputPath, projectRoot, projectName, sourceRoot, generatePackageJson2 = true, includeSrc = false, banner, footer) => {
|
|
1172
1172
|
const pendingAssets = Array.from(assets ?? []);
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1173
|
+
pendingAssets.push({
|
|
1174
|
+
input: projectRoot,
|
|
1175
|
+
glob: "*.md",
|
|
1176
|
+
output: "."
|
|
1177
|
+
});
|
|
1178
|
+
pendingAssets.push({
|
|
1179
|
+
input: config.workspaceRoot,
|
|
1180
|
+
glob: "LICENSE",
|
|
1181
|
+
output: "."
|
|
1182
|
+
});
|
|
1180
1183
|
if (generatePackageJson2 === false) {
|
|
1181
1184
|
pendingAssets.push({
|
|
1182
|
-
input:
|
|
1185
|
+
input: projectRoot,
|
|
1183
1186
|
glob: "package.json",
|
|
1184
1187
|
output: "."
|
|
1185
1188
|
});
|
|
1186
1189
|
}
|
|
1187
|
-
if (!pendingAssets?.some((asset) => asset?.glob === "LICENSE")) {
|
|
1188
|
-
pendingAssets.push({
|
|
1189
|
-
input: "",
|
|
1190
|
-
glob: "LICENSE",
|
|
1191
|
-
output: "."
|
|
1192
|
-
});
|
|
1193
|
-
}
|
|
1194
1190
|
if (includeSrc === true) {
|
|
1195
1191
|
pendingAssets.push({
|
|
1196
1192
|
input: sourceRoot,
|
|
@@ -1336,54 +1332,6 @@ var addWorkspacePackageJsonFields = /* @__PURE__ */ __name(async (config, projec
|
|
|
1336
1332
|
packageJson.repository.directory ??= projectRoot ? projectRoot : joinPaths("packages", projectName);
|
|
1337
1333
|
return packageJson;
|
|
1338
1334
|
}, "addWorkspacePackageJsonFields");
|
|
1339
|
-
var addPackageJsonExport = /* @__PURE__ */ __name((file, type = "module", sourceRoot) => {
|
|
1340
|
-
let entry = file.replaceAll("\\", "/");
|
|
1341
|
-
if (sourceRoot) {
|
|
1342
|
-
entry = entry.replace(sourceRoot, "");
|
|
1343
|
-
}
|
|
1344
|
-
return {
|
|
1345
|
-
"import": {
|
|
1346
|
-
"types": `./dist/${entry}.d.${type === "module" ? "ts" : "mts"}`,
|
|
1347
|
-
"default": `./dist/${entry}.${type === "module" ? "js" : "mjs"}`
|
|
1348
|
-
},
|
|
1349
|
-
"require": {
|
|
1350
|
-
"types": `./dist/${entry}.d.${type === "commonjs" ? "ts" : "cts"}`,
|
|
1351
|
-
"default": `./dist/${entry}.${type === "commonjs" ? "js" : "cjs"}`
|
|
1352
|
-
},
|
|
1353
|
-
"default": {
|
|
1354
|
-
"types": `./dist/${entry}.d.ts`,
|
|
1355
|
-
"default": `./dist/${entry}.js`
|
|
1356
|
-
}
|
|
1357
|
-
};
|
|
1358
|
-
}, "addPackageJsonExport");
|
|
1359
|
-
var addPackageJsonExports = /* @__PURE__ */ __name(async (sourceRoot, packageJson) => {
|
|
1360
|
-
packageJson.exports ??= {};
|
|
1361
|
-
const files = await new import_glob2.Glob("**/*.{ts,tsx}", {
|
|
1362
|
-
absolute: false,
|
|
1363
|
-
cwd: sourceRoot,
|
|
1364
|
-
root: sourceRoot
|
|
1365
|
-
}).walk();
|
|
1366
|
-
files.forEach((file) => {
|
|
1367
|
-
addPackageJsonExport(file, packageJson.type, sourceRoot);
|
|
1368
|
-
const split = file.split(".");
|
|
1369
|
-
split.pop();
|
|
1370
|
-
const entry = split.join(".").replaceAll("\\", "/");
|
|
1371
|
-
packageJson.exports[`./${entry}`] ??= addPackageJsonExport(entry, packageJson.type, sourceRoot);
|
|
1372
|
-
});
|
|
1373
|
-
packageJson.main = packageJson.type === "commonjs" ? "./dist/index.js" : "./dist/index.cjs";
|
|
1374
|
-
packageJson.module = packageJson.type === "module" ? "./dist/index.js" : "./dist/index.mjs";
|
|
1375
|
-
packageJson.types = "./dist/index.d.ts";
|
|
1376
|
-
packageJson.exports ??= {};
|
|
1377
|
-
packageJson.exports = Object.keys(packageJson.exports).reduce((ret, key) => {
|
|
1378
|
-
if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
|
|
1379
|
-
ret[key.replace("/index", "")] = packageJson.exports[key];
|
|
1380
|
-
}
|
|
1381
|
-
return ret;
|
|
1382
|
-
}, packageJson.exports);
|
|
1383
|
-
packageJson.exports["./package.json"] ??= "./package.json";
|
|
1384
|
-
packageJson.exports["."] = packageJson.exports["."] ?? addPackageJsonExport("index", packageJson.type, sourceRoot);
|
|
1385
|
-
return packageJson;
|
|
1386
|
-
}, "addPackageJsonExports");
|
|
1387
1335
|
|
|
1388
1336
|
// ../build-tools/src/utilities/get-entry-points.ts
|
|
1389
1337
|
var import_glob3 = require("glob");
|
|
@@ -1393,6 +1341,7 @@ var import_create_task_graph = require("nx/src/tasks-runner/create-task-graph");
|
|
|
1393
1341
|
|
|
1394
1342
|
// src/build.ts
|
|
1395
1343
|
var import_defu5 = __toESM(require("defu"), 1);
|
|
1344
|
+
var import_glob4 = require("glob");
|
|
1396
1345
|
var import_node_fs8 = require("fs");
|
|
1397
1346
|
var import_promises7 = require("fs/promises");
|
|
1398
1347
|
var import_node_path6 = require("path");
|
|
@@ -3028,6 +2977,9 @@ async function resolveOptions(options, config) {
|
|
|
3028
2977
|
dependencies = dependencies.filter((deps) => deps.name !== tsLibDependency.name);
|
|
3029
2978
|
dependencies.push(tsLibDependency);
|
|
3030
2979
|
}
|
|
2980
|
+
const entries = options.entry ?? [
|
|
2981
|
+
sourceRoot
|
|
2982
|
+
];
|
|
3031
2983
|
const resolvedOptions = {
|
|
3032
2984
|
name: projectName,
|
|
3033
2985
|
config,
|
|
@@ -3036,23 +2988,24 @@ async function resolveOptions(options, config) {
|
|
|
3036
2988
|
projectName,
|
|
3037
2989
|
tsconfig,
|
|
3038
2990
|
clean: false,
|
|
3039
|
-
entries:
|
|
3040
|
-
{
|
|
2991
|
+
entries: entries.reduce((ret, entry) => {
|
|
2992
|
+
ret.push({
|
|
3041
2993
|
builder: "mkdist",
|
|
3042
|
-
input: `.${
|
|
2994
|
+
input: `.${entry.replace(options.projectRoot, "")}`,
|
|
3043
2995
|
outDir: joinPaths((0, import_node_path6.relative)(joinPaths(config.workspaceRoot, options.projectRoot), config.workspaceRoot), outputPath, "dist"),
|
|
3044
|
-
declaration: options.emitTypes !== false,
|
|
2996
|
+
declaration: options.emitTypes !== false ? "compatible" : false,
|
|
3045
2997
|
format: "esm"
|
|
3046
|
-
}
|
|
3047
|
-
{
|
|
2998
|
+
});
|
|
2999
|
+
ret.push({
|
|
3048
3000
|
builder: "mkdist",
|
|
3049
|
-
input: `.${
|
|
3001
|
+
input: `.${entry.replace(options.projectRoot, "")}`,
|
|
3050
3002
|
outDir: joinPaths((0, import_node_path6.relative)(joinPaths(config.workspaceRoot, options.projectRoot), config.workspaceRoot), outputPath, "dist"),
|
|
3051
|
-
declaration: options.emitTypes !== false,
|
|
3003
|
+
declaration: options.emitTypes !== false ? "compatible" : false,
|
|
3052
3004
|
format: "cjs",
|
|
3053
3005
|
ext: "cjs"
|
|
3054
|
-
}
|
|
3055
|
-
|
|
3006
|
+
});
|
|
3007
|
+
return ret;
|
|
3008
|
+
}, []),
|
|
3056
3009
|
declaration: options.emitTypes !== false ? "compatible" : false,
|
|
3057
3010
|
failOnWarn: false,
|
|
3058
3011
|
sourcemap: options.sourcemap ?? !!options.debug,
|
|
@@ -3101,7 +3054,8 @@ async function resolveOptions(options, config) {
|
|
|
3101
3054
|
]
|
|
3102
3055
|
},
|
|
3103
3056
|
esbuild: {
|
|
3104
|
-
minify: options.minify
|
|
3057
|
+
minify: options.minify || !options.debug,
|
|
3058
|
+
sourceMap: options.sourcemap || !!options.debug,
|
|
3105
3059
|
splitting: options.splitting !== false,
|
|
3106
3060
|
treeShaking: options.treeShaking !== false,
|
|
3107
3061
|
color: true,
|
|
@@ -3140,6 +3094,26 @@ async function resolveOptions(options, config) {
|
|
|
3140
3094
|
return resolvedOptions;
|
|
3141
3095
|
}
|
|
3142
3096
|
__name(resolveOptions, "resolveOptions");
|
|
3097
|
+
var addPackageJsonExport = /* @__PURE__ */ __name((file, type = "module", sourceRoot) => {
|
|
3098
|
+
let entry = file.replaceAll("\\", "/");
|
|
3099
|
+
if (sourceRoot) {
|
|
3100
|
+
entry = entry.replace(sourceRoot, "");
|
|
3101
|
+
}
|
|
3102
|
+
return {
|
|
3103
|
+
"import": {
|
|
3104
|
+
"types": `./dist/${entry}.d.ts`,
|
|
3105
|
+
"default": `./dist/${entry}.mjs`
|
|
3106
|
+
},
|
|
3107
|
+
"require": {
|
|
3108
|
+
"types": `./dist/${entry}.d.ts`,
|
|
3109
|
+
"default": `./dist/${entry}.cjs`
|
|
3110
|
+
},
|
|
3111
|
+
"default": {
|
|
3112
|
+
"types": `./dist/${entry}.d.ts`,
|
|
3113
|
+
"default": type === "commonjs" ? `./dist/${entry}.cjs` : `./dist/${entry}.mjs`
|
|
3114
|
+
}
|
|
3115
|
+
};
|
|
3116
|
+
}, "addPackageJsonExport");
|
|
3143
3117
|
async function generatePackageJson(options) {
|
|
3144
3118
|
if (options.generatePackageJson !== false && (0, import_node_fs8.existsSync)(joinPaths(options.projectRoot, "package.json"))) {
|
|
3145
3119
|
writeDebug(" \u270D\uFE0F Writing package.json file", options.config);
|
|
@@ -3155,7 +3129,32 @@ async function generatePackageJson(options) {
|
|
|
3155
3129
|
let packageJson = JSON.parse(packageJsonContent);
|
|
3156
3130
|
packageJson = await addPackageDependencies(options.config.workspaceRoot, options.projectRoot, options.projectName, packageJson);
|
|
3157
3131
|
packageJson = await addWorkspacePackageJsonFields(options.config, options.projectRoot, options.sourceRoot, options.projectName, false, packageJson);
|
|
3158
|
-
|
|
3132
|
+
packageJson.exports ??= {};
|
|
3133
|
+
const files = await new import_glob4.Glob("**/*.{ts,tsx}", {
|
|
3134
|
+
absolute: false,
|
|
3135
|
+
cwd: options.sourceRoot,
|
|
3136
|
+
root: options.sourceRoot
|
|
3137
|
+
}).walk();
|
|
3138
|
+
files.forEach((file) => {
|
|
3139
|
+
addPackageJsonExport(file, packageJson.type, options.sourceRoot);
|
|
3140
|
+
const split = file.split(".");
|
|
3141
|
+
split.pop();
|
|
3142
|
+
const entry = split.join(".").replaceAll("\\", "/");
|
|
3143
|
+
packageJson.exports[`./${entry}`] ??= addPackageJsonExport(entry, packageJson.type, options.sourceRoot);
|
|
3144
|
+
});
|
|
3145
|
+
packageJson.main ??= "./dist/index.cjs";
|
|
3146
|
+
packageJson.module ??= "./dist/index.mjs";
|
|
3147
|
+
packageJson.types ??= "./dist/index.d.ts";
|
|
3148
|
+
packageJson.exports ??= {};
|
|
3149
|
+
packageJson.exports = Object.keys(packageJson.exports).reduce((ret, key) => {
|
|
3150
|
+
if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
|
|
3151
|
+
ret[key.replace("/index", "")] = packageJson.exports[key];
|
|
3152
|
+
}
|
|
3153
|
+
return ret;
|
|
3154
|
+
}, packageJson.exports);
|
|
3155
|
+
packageJson.exports["./package.json"] ??= "./package.json";
|
|
3156
|
+
packageJson.exports["."] ??= addPackageJsonExport("index", packageJson.type, options.sourceRoot);
|
|
3157
|
+
await (0, import_devkit6.writeJsonFile)(joinPaths(options.outDir, "package.json"), packageJson);
|
|
3159
3158
|
stopwatch();
|
|
3160
3159
|
}
|
|
3161
3160
|
return options;
|
|
@@ -3168,7 +3167,7 @@ async function executeUnbuild(options) {
|
|
|
3168
3167
|
const config = {
|
|
3169
3168
|
...options,
|
|
3170
3169
|
config: null,
|
|
3171
|
-
rootDir: options.projectRoot
|
|
3170
|
+
rootDir: joinPaths(options.config.workspaceRoot, options.projectRoot)
|
|
3172
3171
|
};
|
|
3173
3172
|
writeTrace(`Running with unbuild configuration:
|
|
3174
3173
|
${formatLogMessage(config)}
|
package/bin/unbuild.js
CHANGED
|
@@ -1145,27 +1145,23 @@ var readNxConfig = /* @__PURE__ */ __name(async (workspaceRoot) => {
|
|
|
1145
1145
|
// ../build-tools/src/utilities/copy-assets.ts
|
|
1146
1146
|
var copyAssets = /* @__PURE__ */ __name(async (config, assets, outputPath, projectRoot, projectName, sourceRoot, generatePackageJson2 = true, includeSrc = false, banner, footer) => {
|
|
1147
1147
|
const pendingAssets = Array.from(assets ?? []);
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1148
|
+
pendingAssets.push({
|
|
1149
|
+
input: projectRoot,
|
|
1150
|
+
glob: "*.md",
|
|
1151
|
+
output: "."
|
|
1152
|
+
});
|
|
1153
|
+
pendingAssets.push({
|
|
1154
|
+
input: config.workspaceRoot,
|
|
1155
|
+
glob: "LICENSE",
|
|
1156
|
+
output: "."
|
|
1157
|
+
});
|
|
1155
1158
|
if (generatePackageJson2 === false) {
|
|
1156
1159
|
pendingAssets.push({
|
|
1157
|
-
input:
|
|
1160
|
+
input: projectRoot,
|
|
1158
1161
|
glob: "package.json",
|
|
1159
1162
|
output: "."
|
|
1160
1163
|
});
|
|
1161
1164
|
}
|
|
1162
|
-
if (!pendingAssets?.some((asset) => asset?.glob === "LICENSE")) {
|
|
1163
|
-
pendingAssets.push({
|
|
1164
|
-
input: "",
|
|
1165
|
-
glob: "LICENSE",
|
|
1166
|
-
output: "."
|
|
1167
|
-
});
|
|
1168
|
-
}
|
|
1169
1165
|
if (includeSrc === true) {
|
|
1170
1166
|
pendingAssets.push({
|
|
1171
1167
|
input: sourceRoot,
|
|
@@ -1311,54 +1307,6 @@ var addWorkspacePackageJsonFields = /* @__PURE__ */ __name(async (config, projec
|
|
|
1311
1307
|
packageJson.repository.directory ??= projectRoot ? projectRoot : joinPaths("packages", projectName);
|
|
1312
1308
|
return packageJson;
|
|
1313
1309
|
}, "addWorkspacePackageJsonFields");
|
|
1314
|
-
var addPackageJsonExport = /* @__PURE__ */ __name((file, type = "module", sourceRoot) => {
|
|
1315
|
-
let entry = file.replaceAll("\\", "/");
|
|
1316
|
-
if (sourceRoot) {
|
|
1317
|
-
entry = entry.replace(sourceRoot, "");
|
|
1318
|
-
}
|
|
1319
|
-
return {
|
|
1320
|
-
"import": {
|
|
1321
|
-
"types": `./dist/${entry}.d.${type === "module" ? "ts" : "mts"}`,
|
|
1322
|
-
"default": `./dist/${entry}.${type === "module" ? "js" : "mjs"}`
|
|
1323
|
-
},
|
|
1324
|
-
"require": {
|
|
1325
|
-
"types": `./dist/${entry}.d.${type === "commonjs" ? "ts" : "cts"}`,
|
|
1326
|
-
"default": `./dist/${entry}.${type === "commonjs" ? "js" : "cjs"}`
|
|
1327
|
-
},
|
|
1328
|
-
"default": {
|
|
1329
|
-
"types": `./dist/${entry}.d.ts`,
|
|
1330
|
-
"default": `./dist/${entry}.js`
|
|
1331
|
-
}
|
|
1332
|
-
};
|
|
1333
|
-
}, "addPackageJsonExport");
|
|
1334
|
-
var addPackageJsonExports = /* @__PURE__ */ __name(async (sourceRoot, packageJson) => {
|
|
1335
|
-
packageJson.exports ??= {};
|
|
1336
|
-
const files = await new Glob("**/*.{ts,tsx}", {
|
|
1337
|
-
absolute: false,
|
|
1338
|
-
cwd: sourceRoot,
|
|
1339
|
-
root: sourceRoot
|
|
1340
|
-
}).walk();
|
|
1341
|
-
files.forEach((file) => {
|
|
1342
|
-
addPackageJsonExport(file, packageJson.type, sourceRoot);
|
|
1343
|
-
const split = file.split(".");
|
|
1344
|
-
split.pop();
|
|
1345
|
-
const entry = split.join(".").replaceAll("\\", "/");
|
|
1346
|
-
packageJson.exports[`./${entry}`] ??= addPackageJsonExport(entry, packageJson.type, sourceRoot);
|
|
1347
|
-
});
|
|
1348
|
-
packageJson.main = packageJson.type === "commonjs" ? "./dist/index.js" : "./dist/index.cjs";
|
|
1349
|
-
packageJson.module = packageJson.type === "module" ? "./dist/index.js" : "./dist/index.mjs";
|
|
1350
|
-
packageJson.types = "./dist/index.d.ts";
|
|
1351
|
-
packageJson.exports ??= {};
|
|
1352
|
-
packageJson.exports = Object.keys(packageJson.exports).reduce((ret, key) => {
|
|
1353
|
-
if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
|
|
1354
|
-
ret[key.replace("/index", "")] = packageJson.exports[key];
|
|
1355
|
-
}
|
|
1356
|
-
return ret;
|
|
1357
|
-
}, packageJson.exports);
|
|
1358
|
-
packageJson.exports["./package.json"] ??= "./package.json";
|
|
1359
|
-
packageJson.exports["."] = packageJson.exports["."] ?? addPackageJsonExport("index", packageJson.type, sourceRoot);
|
|
1360
|
-
return packageJson;
|
|
1361
|
-
}, "addPackageJsonExports");
|
|
1362
1310
|
|
|
1363
1311
|
// ../build-tools/src/utilities/get-entry-points.ts
|
|
1364
1312
|
import { glob as glob2 } from "glob";
|
|
@@ -1368,6 +1316,7 @@ import { createTaskGraph, mapTargetDefaultsToDependencies } from "nx/src/tasks-r
|
|
|
1368
1316
|
|
|
1369
1317
|
// src/build.ts
|
|
1370
1318
|
import defu4 from "defu";
|
|
1319
|
+
import { Glob as Glob2 } from "glob";
|
|
1371
1320
|
import { existsSync as existsSync6 } from "node:fs";
|
|
1372
1321
|
import { readFile as readFile4 } from "node:fs/promises";
|
|
1373
1322
|
import { relative as relative4 } from "node:path";
|
|
@@ -3003,6 +2952,9 @@ async function resolveOptions(options, config) {
|
|
|
3003
2952
|
dependencies = dependencies.filter((deps) => deps.name !== tsLibDependency.name);
|
|
3004
2953
|
dependencies.push(tsLibDependency);
|
|
3005
2954
|
}
|
|
2955
|
+
const entries = options.entry ?? [
|
|
2956
|
+
sourceRoot
|
|
2957
|
+
];
|
|
3006
2958
|
const resolvedOptions = {
|
|
3007
2959
|
name: projectName,
|
|
3008
2960
|
config,
|
|
@@ -3011,23 +2963,24 @@ async function resolveOptions(options, config) {
|
|
|
3011
2963
|
projectName,
|
|
3012
2964
|
tsconfig,
|
|
3013
2965
|
clean: false,
|
|
3014
|
-
entries:
|
|
3015
|
-
{
|
|
2966
|
+
entries: entries.reduce((ret, entry) => {
|
|
2967
|
+
ret.push({
|
|
3016
2968
|
builder: "mkdist",
|
|
3017
|
-
input: `.${
|
|
2969
|
+
input: `.${entry.replace(options.projectRoot, "")}`,
|
|
3018
2970
|
outDir: joinPaths(relative4(joinPaths(config.workspaceRoot, options.projectRoot), config.workspaceRoot), outputPath, "dist"),
|
|
3019
|
-
declaration: options.emitTypes !== false,
|
|
2971
|
+
declaration: options.emitTypes !== false ? "compatible" : false,
|
|
3020
2972
|
format: "esm"
|
|
3021
|
-
}
|
|
3022
|
-
{
|
|
2973
|
+
});
|
|
2974
|
+
ret.push({
|
|
3023
2975
|
builder: "mkdist",
|
|
3024
|
-
input: `.${
|
|
2976
|
+
input: `.${entry.replace(options.projectRoot, "")}`,
|
|
3025
2977
|
outDir: joinPaths(relative4(joinPaths(config.workspaceRoot, options.projectRoot), config.workspaceRoot), outputPath, "dist"),
|
|
3026
|
-
declaration: options.emitTypes !== false,
|
|
2978
|
+
declaration: options.emitTypes !== false ? "compatible" : false,
|
|
3027
2979
|
format: "cjs",
|
|
3028
2980
|
ext: "cjs"
|
|
3029
|
-
}
|
|
3030
|
-
|
|
2981
|
+
});
|
|
2982
|
+
return ret;
|
|
2983
|
+
}, []),
|
|
3031
2984
|
declaration: options.emitTypes !== false ? "compatible" : false,
|
|
3032
2985
|
failOnWarn: false,
|
|
3033
2986
|
sourcemap: options.sourcemap ?? !!options.debug,
|
|
@@ -3076,7 +3029,8 @@ async function resolveOptions(options, config) {
|
|
|
3076
3029
|
]
|
|
3077
3030
|
},
|
|
3078
3031
|
esbuild: {
|
|
3079
|
-
minify: options.minify
|
|
3032
|
+
minify: options.minify || !options.debug,
|
|
3033
|
+
sourceMap: options.sourcemap || !!options.debug,
|
|
3080
3034
|
splitting: options.splitting !== false,
|
|
3081
3035
|
treeShaking: options.treeShaking !== false,
|
|
3082
3036
|
color: true,
|
|
@@ -3115,6 +3069,26 @@ async function resolveOptions(options, config) {
|
|
|
3115
3069
|
return resolvedOptions;
|
|
3116
3070
|
}
|
|
3117
3071
|
__name(resolveOptions, "resolveOptions");
|
|
3072
|
+
var addPackageJsonExport = /* @__PURE__ */ __name((file, type = "module", sourceRoot) => {
|
|
3073
|
+
let entry = file.replaceAll("\\", "/");
|
|
3074
|
+
if (sourceRoot) {
|
|
3075
|
+
entry = entry.replace(sourceRoot, "");
|
|
3076
|
+
}
|
|
3077
|
+
return {
|
|
3078
|
+
"import": {
|
|
3079
|
+
"types": `./dist/${entry}.d.ts`,
|
|
3080
|
+
"default": `./dist/${entry}.mjs`
|
|
3081
|
+
},
|
|
3082
|
+
"require": {
|
|
3083
|
+
"types": `./dist/${entry}.d.ts`,
|
|
3084
|
+
"default": `./dist/${entry}.cjs`
|
|
3085
|
+
},
|
|
3086
|
+
"default": {
|
|
3087
|
+
"types": `./dist/${entry}.d.ts`,
|
|
3088
|
+
"default": type === "commonjs" ? `./dist/${entry}.cjs` : `./dist/${entry}.mjs`
|
|
3089
|
+
}
|
|
3090
|
+
};
|
|
3091
|
+
}, "addPackageJsonExport");
|
|
3118
3092
|
async function generatePackageJson(options) {
|
|
3119
3093
|
if (options.generatePackageJson !== false && existsSync6(joinPaths(options.projectRoot, "package.json"))) {
|
|
3120
3094
|
writeDebug(" \u270D\uFE0F Writing package.json file", options.config);
|
|
@@ -3130,7 +3104,32 @@ async function generatePackageJson(options) {
|
|
|
3130
3104
|
let packageJson = JSON.parse(packageJsonContent);
|
|
3131
3105
|
packageJson = await addPackageDependencies(options.config.workspaceRoot, options.projectRoot, options.projectName, packageJson);
|
|
3132
3106
|
packageJson = await addWorkspacePackageJsonFields(options.config, options.projectRoot, options.sourceRoot, options.projectName, false, packageJson);
|
|
3133
|
-
|
|
3107
|
+
packageJson.exports ??= {};
|
|
3108
|
+
const files = await new Glob2("**/*.{ts,tsx}", {
|
|
3109
|
+
absolute: false,
|
|
3110
|
+
cwd: options.sourceRoot,
|
|
3111
|
+
root: options.sourceRoot
|
|
3112
|
+
}).walk();
|
|
3113
|
+
files.forEach((file) => {
|
|
3114
|
+
addPackageJsonExport(file, packageJson.type, options.sourceRoot);
|
|
3115
|
+
const split = file.split(".");
|
|
3116
|
+
split.pop();
|
|
3117
|
+
const entry = split.join(".").replaceAll("\\", "/");
|
|
3118
|
+
packageJson.exports[`./${entry}`] ??= addPackageJsonExport(entry, packageJson.type, options.sourceRoot);
|
|
3119
|
+
});
|
|
3120
|
+
packageJson.main ??= "./dist/index.cjs";
|
|
3121
|
+
packageJson.module ??= "./dist/index.mjs";
|
|
3122
|
+
packageJson.types ??= "./dist/index.d.ts";
|
|
3123
|
+
packageJson.exports ??= {};
|
|
3124
|
+
packageJson.exports = Object.keys(packageJson.exports).reduce((ret, key) => {
|
|
3125
|
+
if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
|
|
3126
|
+
ret[key.replace("/index", "")] = packageJson.exports[key];
|
|
3127
|
+
}
|
|
3128
|
+
return ret;
|
|
3129
|
+
}, packageJson.exports);
|
|
3130
|
+
packageJson.exports["./package.json"] ??= "./package.json";
|
|
3131
|
+
packageJson.exports["."] ??= addPackageJsonExport("index", packageJson.type, options.sourceRoot);
|
|
3132
|
+
await writeJsonFile(joinPaths(options.outDir, "package.json"), packageJson);
|
|
3134
3133
|
stopwatch();
|
|
3135
3134
|
}
|
|
3136
3135
|
return options;
|
|
@@ -3143,7 +3142,7 @@ async function executeUnbuild(options) {
|
|
|
3143
3142
|
const config = {
|
|
3144
3143
|
...options,
|
|
3145
3144
|
config: null,
|
|
3146
|
-
rootDir: options.projectRoot
|
|
3145
|
+
rootDir: joinPaths(options.config.workspaceRoot, options.projectRoot)
|
|
3147
3146
|
};
|
|
3148
3147
|
writeTrace(`Running with unbuild configuration:
|
|
3149
3148
|
${formatLogMessage(config)}
|
package/dist/build.cjs
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _chunkSN3G5SIPcjs = require('./chunk-SN3G5SIP.cjs');
|
|
4
9
|
require('./chunk-5E3NJ26L.cjs');
|
|
5
10
|
require('./chunk-Y2DOCJBE.cjs');
|
|
6
11
|
require('./chunk-V627S7QU.cjs');
|
|
@@ -11,4 +16,9 @@ require('./chunk-FG6XQ26M.cjs');
|
|
|
11
16
|
require('./chunk-YDYGZTJK.cjs');
|
|
12
17
|
|
|
13
18
|
|
|
14
|
-
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
exports.build = _chunkSN3G5SIPcjs.build; exports.cleanOutputPath = _chunkSN3G5SIPcjs.cleanOutputPath; exports.copyBuildAssets = _chunkSN3G5SIPcjs.copyBuildAssets; exports.executeUnbuild = _chunkSN3G5SIPcjs.executeUnbuild; exports.generatePackageJson = _chunkSN3G5SIPcjs.generatePackageJson; exports.resolveOptions = _chunkSN3G5SIPcjs.resolveOptions;
|
package/dist/build.d.cts
CHANGED
|
@@ -1,7 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StormConfig } from '@storm-software/config/types';
|
|
2
|
+
import { UnbuildOptions, UnbuildResolvedOptions } from './types.cjs';
|
|
2
3
|
import '@storm-software/build-tools';
|
|
3
4
|
import 'unbuild';
|
|
4
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Get the build options for the unbuild process
|
|
8
|
+
*
|
|
9
|
+
* @param options - the unbuild options
|
|
10
|
+
* @returns the resolved options
|
|
11
|
+
*/
|
|
12
|
+
declare function resolveOptions(options: UnbuildOptions, config: StormConfig): Promise<UnbuildResolvedOptions>;
|
|
13
|
+
declare function generatePackageJson(options: UnbuildResolvedOptions): Promise<UnbuildResolvedOptions>;
|
|
14
|
+
/**
|
|
15
|
+
* Execute Unbuild with all the configurations we pass
|
|
16
|
+
*/
|
|
17
|
+
declare function executeUnbuild(options: UnbuildResolvedOptions): Promise<UnbuildResolvedOptions>;
|
|
18
|
+
/**
|
|
19
|
+
* Copy the assets to the build directory
|
|
20
|
+
*/
|
|
21
|
+
declare function copyBuildAssets(options: UnbuildResolvedOptions): Promise<UnbuildResolvedOptions>;
|
|
22
|
+
/**
|
|
23
|
+
* Clean the output path
|
|
24
|
+
*
|
|
25
|
+
* @param options - the build options
|
|
26
|
+
*/
|
|
27
|
+
declare function cleanOutputPath(options: UnbuildResolvedOptions): Promise<UnbuildResolvedOptions>;
|
|
5
28
|
/**
|
|
6
29
|
* Execution pipeline that applies a set of actions
|
|
7
30
|
*
|
|
@@ -10,4 +33,4 @@ import 'unbuild';
|
|
|
10
33
|
*/
|
|
11
34
|
declare function build(options: UnbuildOptions): Promise<void>;
|
|
12
35
|
|
|
13
|
-
export { build };
|
|
36
|
+
export { build, cleanOutputPath, copyBuildAssets, executeUnbuild, generatePackageJson, resolveOptions };
|
package/dist/build.d.ts
CHANGED
|
@@ -1,7 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StormConfig } from '@storm-software/config/types';
|
|
2
|
+
import { UnbuildOptions, UnbuildResolvedOptions } from './types.js';
|
|
2
3
|
import '@storm-software/build-tools';
|
|
3
4
|
import 'unbuild';
|
|
4
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Get the build options for the unbuild process
|
|
8
|
+
*
|
|
9
|
+
* @param options - the unbuild options
|
|
10
|
+
* @returns the resolved options
|
|
11
|
+
*/
|
|
12
|
+
declare function resolveOptions(options: UnbuildOptions, config: StormConfig): Promise<UnbuildResolvedOptions>;
|
|
13
|
+
declare function generatePackageJson(options: UnbuildResolvedOptions): Promise<UnbuildResolvedOptions>;
|
|
14
|
+
/**
|
|
15
|
+
* Execute Unbuild with all the configurations we pass
|
|
16
|
+
*/
|
|
17
|
+
declare function executeUnbuild(options: UnbuildResolvedOptions): Promise<UnbuildResolvedOptions>;
|
|
18
|
+
/**
|
|
19
|
+
* Copy the assets to the build directory
|
|
20
|
+
*/
|
|
21
|
+
declare function copyBuildAssets(options: UnbuildResolvedOptions): Promise<UnbuildResolvedOptions>;
|
|
22
|
+
/**
|
|
23
|
+
* Clean the output path
|
|
24
|
+
*
|
|
25
|
+
* @param options - the build options
|
|
26
|
+
*/
|
|
27
|
+
declare function cleanOutputPath(options: UnbuildResolvedOptions): Promise<UnbuildResolvedOptions>;
|
|
5
28
|
/**
|
|
6
29
|
* Execution pipeline that applies a set of actions
|
|
7
30
|
*
|
|
@@ -10,4 +33,4 @@ import 'unbuild';
|
|
|
10
33
|
*/
|
|
11
34
|
declare function build(options: UnbuildOptions): Promise<void>;
|
|
12
35
|
|
|
13
|
-
export { build };
|
|
36
|
+
export { build, cleanOutputPath, copyBuildAssets, executeUnbuild, generatePackageJson, resolveOptions };
|
package/dist/build.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
build
|
|
3
|
-
|
|
2
|
+
build,
|
|
3
|
+
cleanOutputPath,
|
|
4
|
+
copyBuildAssets,
|
|
5
|
+
executeUnbuild,
|
|
6
|
+
generatePackageJson,
|
|
7
|
+
resolveOptions
|
|
8
|
+
} from "./chunk-DORAESSZ.js";
|
|
4
9
|
import "./chunk-VC7N2YVM.js";
|
|
5
10
|
import "./chunk-K2D7TQ7G.js";
|
|
6
11
|
import "./chunk-C5IHRWT3.js";
|
|
@@ -10,5 +15,10 @@ import "./chunk-5S4A4OEA.js";
|
|
|
10
15
|
import "./chunk-TPFSDZCR.js";
|
|
11
16
|
import "./chunk-3GQAWCBQ.js";
|
|
12
17
|
export {
|
|
13
|
-
build
|
|
18
|
+
build,
|
|
19
|
+
cleanOutputPath,
|
|
20
|
+
copyBuildAssets,
|
|
21
|
+
executeUnbuild,
|
|
22
|
+
generatePackageJson,
|
|
23
|
+
resolveOptions
|
|
14
24
|
};
|
|
@@ -555,27 +555,23 @@ var readNxConfig = /* @__PURE__ */ __name(async (workspaceRoot) => {
|
|
|
555
555
|
// ../build-tools/src/utilities/copy-assets.ts
|
|
556
556
|
var copyAssets = /* @__PURE__ */ __name(async (config, assets, outputPath, projectRoot, projectName, sourceRoot, generatePackageJson2 = true, includeSrc = false, banner, footer) => {
|
|
557
557
|
const pendingAssets = Array.from(assets ?? []);
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
558
|
+
pendingAssets.push({
|
|
559
|
+
input: projectRoot,
|
|
560
|
+
glob: "*.md",
|
|
561
|
+
output: "."
|
|
562
|
+
});
|
|
563
|
+
pendingAssets.push({
|
|
564
|
+
input: config.workspaceRoot,
|
|
565
|
+
glob: "LICENSE",
|
|
566
|
+
output: "."
|
|
567
|
+
});
|
|
565
568
|
if (generatePackageJson2 === false) {
|
|
566
569
|
pendingAssets.push({
|
|
567
|
-
input:
|
|
570
|
+
input: projectRoot,
|
|
568
571
|
glob: "package.json",
|
|
569
572
|
output: "."
|
|
570
573
|
});
|
|
571
574
|
}
|
|
572
|
-
if (!pendingAssets?.some((asset) => asset?.glob === "LICENSE")) {
|
|
573
|
-
pendingAssets.push({
|
|
574
|
-
input: "",
|
|
575
|
-
glob: "LICENSE",
|
|
576
|
-
output: "."
|
|
577
|
-
});
|
|
578
|
-
}
|
|
579
575
|
if (includeSrc === true) {
|
|
580
576
|
pendingAssets.push({
|
|
581
577
|
input: sourceRoot,
|
|
@@ -721,54 +717,6 @@ var addWorkspacePackageJsonFields = /* @__PURE__ */ __name(async (config, projec
|
|
|
721
717
|
packageJson.repository.directory ??= projectRoot ? projectRoot : joinPaths("packages", projectName);
|
|
722
718
|
return packageJson;
|
|
723
719
|
}, "addWorkspacePackageJsonFields");
|
|
724
|
-
var addPackageJsonExport = /* @__PURE__ */ __name((file, type = "module", sourceRoot) => {
|
|
725
|
-
let entry = file.replaceAll("\\", "/");
|
|
726
|
-
if (sourceRoot) {
|
|
727
|
-
entry = entry.replace(sourceRoot, "");
|
|
728
|
-
}
|
|
729
|
-
return {
|
|
730
|
-
"import": {
|
|
731
|
-
"types": `./dist/${entry}.d.${type === "module" ? "ts" : "mts"}`,
|
|
732
|
-
"default": `./dist/${entry}.${type === "module" ? "js" : "mjs"}`
|
|
733
|
-
},
|
|
734
|
-
"require": {
|
|
735
|
-
"types": `./dist/${entry}.d.${type === "commonjs" ? "ts" : "cts"}`,
|
|
736
|
-
"default": `./dist/${entry}.${type === "commonjs" ? "js" : "cjs"}`
|
|
737
|
-
},
|
|
738
|
-
"default": {
|
|
739
|
-
"types": `./dist/${entry}.d.ts`,
|
|
740
|
-
"default": `./dist/${entry}.js`
|
|
741
|
-
}
|
|
742
|
-
};
|
|
743
|
-
}, "addPackageJsonExport");
|
|
744
|
-
var addPackageJsonExports = /* @__PURE__ */ __name(async (sourceRoot, packageJson) => {
|
|
745
|
-
packageJson.exports ??= {};
|
|
746
|
-
const files = await new Glob("**/*.{ts,tsx}", {
|
|
747
|
-
absolute: false,
|
|
748
|
-
cwd: sourceRoot,
|
|
749
|
-
root: sourceRoot
|
|
750
|
-
}).walk();
|
|
751
|
-
files.forEach((file) => {
|
|
752
|
-
addPackageJsonExport(file, packageJson.type, sourceRoot);
|
|
753
|
-
const split = file.split(".");
|
|
754
|
-
split.pop();
|
|
755
|
-
const entry = split.join(".").replaceAll("\\", "/");
|
|
756
|
-
packageJson.exports[`./${entry}`] ??= addPackageJsonExport(entry, packageJson.type, sourceRoot);
|
|
757
|
-
});
|
|
758
|
-
packageJson.main = packageJson.type === "commonjs" ? "./dist/index.js" : "./dist/index.cjs";
|
|
759
|
-
packageJson.module = packageJson.type === "module" ? "./dist/index.js" : "./dist/index.mjs";
|
|
760
|
-
packageJson.types = "./dist/index.d.ts";
|
|
761
|
-
packageJson.exports ??= {};
|
|
762
|
-
packageJson.exports = Object.keys(packageJson.exports).reduce((ret, key) => {
|
|
763
|
-
if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
|
|
764
|
-
ret[key.replace("/index", "")] = packageJson.exports[key];
|
|
765
|
-
}
|
|
766
|
-
return ret;
|
|
767
|
-
}, packageJson.exports);
|
|
768
|
-
packageJson.exports["./package.json"] ??= "./package.json";
|
|
769
|
-
packageJson.exports["."] = packageJson.exports["."] ?? addPackageJsonExport("index", packageJson.type, sourceRoot);
|
|
770
|
-
return packageJson;
|
|
771
|
-
}, "addPackageJsonExports");
|
|
772
720
|
|
|
773
721
|
// ../build-tools/src/utilities/get-entry-points.ts
|
|
774
722
|
import { glob as glob2 } from "glob";
|
|
@@ -778,6 +726,7 @@ import { createTaskGraph, mapTargetDefaultsToDependencies } from "nx/src/tasks-r
|
|
|
778
726
|
|
|
779
727
|
// src/build.ts
|
|
780
728
|
import defu4 from "defu";
|
|
729
|
+
import { Glob as Glob2 } from "glob";
|
|
781
730
|
import { existsSync as existsSync4 } from "node:fs";
|
|
782
731
|
import { readFile as readFile4 } from "node:fs/promises";
|
|
783
732
|
import { relative as relative3 } from "node:path";
|
|
@@ -2260,6 +2209,9 @@ async function resolveOptions(options, config) {
|
|
|
2260
2209
|
dependencies = dependencies.filter((deps) => deps.name !== tsLibDependency.name);
|
|
2261
2210
|
dependencies.push(tsLibDependency);
|
|
2262
2211
|
}
|
|
2212
|
+
const entries = options.entry ?? [
|
|
2213
|
+
sourceRoot
|
|
2214
|
+
];
|
|
2263
2215
|
const resolvedOptions = {
|
|
2264
2216
|
name: projectName,
|
|
2265
2217
|
config,
|
|
@@ -2268,23 +2220,24 @@ async function resolveOptions(options, config) {
|
|
|
2268
2220
|
projectName,
|
|
2269
2221
|
tsconfig,
|
|
2270
2222
|
clean: false,
|
|
2271
|
-
entries:
|
|
2272
|
-
{
|
|
2223
|
+
entries: entries.reduce((ret, entry) => {
|
|
2224
|
+
ret.push({
|
|
2273
2225
|
builder: "mkdist",
|
|
2274
|
-
input: `.${
|
|
2226
|
+
input: `.${entry.replace(options.projectRoot, "")}`,
|
|
2275
2227
|
outDir: joinPaths(relative3(joinPaths(config.workspaceRoot, options.projectRoot), config.workspaceRoot), outputPath, "dist"),
|
|
2276
|
-
declaration: options.emitTypes !== false,
|
|
2228
|
+
declaration: options.emitTypes !== false ? "compatible" : false,
|
|
2277
2229
|
format: "esm"
|
|
2278
|
-
}
|
|
2279
|
-
{
|
|
2230
|
+
});
|
|
2231
|
+
ret.push({
|
|
2280
2232
|
builder: "mkdist",
|
|
2281
|
-
input: `.${
|
|
2233
|
+
input: `.${entry.replace(options.projectRoot, "")}`,
|
|
2282
2234
|
outDir: joinPaths(relative3(joinPaths(config.workspaceRoot, options.projectRoot), config.workspaceRoot), outputPath, "dist"),
|
|
2283
|
-
declaration: options.emitTypes !== false,
|
|
2235
|
+
declaration: options.emitTypes !== false ? "compatible" : false,
|
|
2284
2236
|
format: "cjs",
|
|
2285
2237
|
ext: "cjs"
|
|
2286
|
-
}
|
|
2287
|
-
|
|
2238
|
+
});
|
|
2239
|
+
return ret;
|
|
2240
|
+
}, []),
|
|
2288
2241
|
declaration: options.emitTypes !== false ? "compatible" : false,
|
|
2289
2242
|
failOnWarn: false,
|
|
2290
2243
|
sourcemap: options.sourcemap ?? !!options.debug,
|
|
@@ -2333,7 +2286,8 @@ async function resolveOptions(options, config) {
|
|
|
2333
2286
|
]
|
|
2334
2287
|
},
|
|
2335
2288
|
esbuild: {
|
|
2336
|
-
minify: options.minify
|
|
2289
|
+
minify: options.minify || !options.debug,
|
|
2290
|
+
sourceMap: options.sourcemap || !!options.debug,
|
|
2337
2291
|
splitting: options.splitting !== false,
|
|
2338
2292
|
treeShaking: options.treeShaking !== false,
|
|
2339
2293
|
color: true,
|
|
@@ -2372,6 +2326,26 @@ async function resolveOptions(options, config) {
|
|
|
2372
2326
|
return resolvedOptions;
|
|
2373
2327
|
}
|
|
2374
2328
|
__name(resolveOptions, "resolveOptions");
|
|
2329
|
+
var addPackageJsonExport = /* @__PURE__ */ __name((file, type = "module", sourceRoot) => {
|
|
2330
|
+
let entry = file.replaceAll("\\", "/");
|
|
2331
|
+
if (sourceRoot) {
|
|
2332
|
+
entry = entry.replace(sourceRoot, "");
|
|
2333
|
+
}
|
|
2334
|
+
return {
|
|
2335
|
+
"import": {
|
|
2336
|
+
"types": `./dist/${entry}.d.ts`,
|
|
2337
|
+
"default": `./dist/${entry}.mjs`
|
|
2338
|
+
},
|
|
2339
|
+
"require": {
|
|
2340
|
+
"types": `./dist/${entry}.d.ts`,
|
|
2341
|
+
"default": `./dist/${entry}.cjs`
|
|
2342
|
+
},
|
|
2343
|
+
"default": {
|
|
2344
|
+
"types": `./dist/${entry}.d.ts`,
|
|
2345
|
+
"default": type === "commonjs" ? `./dist/${entry}.cjs` : `./dist/${entry}.mjs`
|
|
2346
|
+
}
|
|
2347
|
+
};
|
|
2348
|
+
}, "addPackageJsonExport");
|
|
2375
2349
|
async function generatePackageJson(options) {
|
|
2376
2350
|
if (options.generatePackageJson !== false && existsSync4(joinPaths(options.projectRoot, "package.json"))) {
|
|
2377
2351
|
writeDebug(" \u270D\uFE0F Writing package.json file", options.config);
|
|
@@ -2387,7 +2361,32 @@ async function generatePackageJson(options) {
|
|
|
2387
2361
|
let packageJson = JSON.parse(packageJsonContent);
|
|
2388
2362
|
packageJson = await addPackageDependencies(options.config.workspaceRoot, options.projectRoot, options.projectName, packageJson);
|
|
2389
2363
|
packageJson = await addWorkspacePackageJsonFields(options.config, options.projectRoot, options.sourceRoot, options.projectName, false, packageJson);
|
|
2390
|
-
|
|
2364
|
+
packageJson.exports ??= {};
|
|
2365
|
+
const files = await new Glob2("**/*.{ts,tsx}", {
|
|
2366
|
+
absolute: false,
|
|
2367
|
+
cwd: options.sourceRoot,
|
|
2368
|
+
root: options.sourceRoot
|
|
2369
|
+
}).walk();
|
|
2370
|
+
files.forEach((file) => {
|
|
2371
|
+
addPackageJsonExport(file, packageJson.type, options.sourceRoot);
|
|
2372
|
+
const split = file.split(".");
|
|
2373
|
+
split.pop();
|
|
2374
|
+
const entry = split.join(".").replaceAll("\\", "/");
|
|
2375
|
+
packageJson.exports[`./${entry}`] ??= addPackageJsonExport(entry, packageJson.type, options.sourceRoot);
|
|
2376
|
+
});
|
|
2377
|
+
packageJson.main ??= "./dist/index.cjs";
|
|
2378
|
+
packageJson.module ??= "./dist/index.mjs";
|
|
2379
|
+
packageJson.types ??= "./dist/index.d.ts";
|
|
2380
|
+
packageJson.exports ??= {};
|
|
2381
|
+
packageJson.exports = Object.keys(packageJson.exports).reduce((ret, key) => {
|
|
2382
|
+
if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
|
|
2383
|
+
ret[key.replace("/index", "")] = packageJson.exports[key];
|
|
2384
|
+
}
|
|
2385
|
+
return ret;
|
|
2386
|
+
}, packageJson.exports);
|
|
2387
|
+
packageJson.exports["./package.json"] ??= "./package.json";
|
|
2388
|
+
packageJson.exports["."] ??= addPackageJsonExport("index", packageJson.type, options.sourceRoot);
|
|
2389
|
+
await writeJsonFile(joinPaths(options.outDir, "package.json"), packageJson);
|
|
2391
2390
|
stopwatch();
|
|
2392
2391
|
}
|
|
2393
2392
|
return options;
|
|
@@ -2400,7 +2399,7 @@ async function executeUnbuild(options) {
|
|
|
2400
2399
|
const config = {
|
|
2401
2400
|
...options,
|
|
2402
2401
|
config: null,
|
|
2403
|
-
rootDir: options.projectRoot
|
|
2402
|
+
rootDir: joinPaths(options.config.workspaceRoot, options.projectRoot)
|
|
2404
2403
|
};
|
|
2405
2404
|
writeTrace(`Running with unbuild configuration:
|
|
2406
2405
|
${formatLogMessage(config)}
|
|
@@ -2460,5 +2459,10 @@ async function build2(options) {
|
|
|
2460
2459
|
__name(build2, "build");
|
|
2461
2460
|
|
|
2462
2461
|
export {
|
|
2462
|
+
resolveOptions,
|
|
2463
|
+
generatePackageJson,
|
|
2464
|
+
executeUnbuild,
|
|
2465
|
+
copyBuildAssets,
|
|
2466
|
+
cleanOutputPath,
|
|
2463
2467
|
build2 as build
|
|
2464
2468
|
};
|
|
@@ -556,27 +556,23 @@ var readNxConfig = /* @__PURE__ */ _chunkYDYGZTJKcjs.__name.call(void 0, async (
|
|
|
556
556
|
// ../build-tools/src/utilities/copy-assets.ts
|
|
557
557
|
var copyAssets = /* @__PURE__ */ _chunkYDYGZTJKcjs.__name.call(void 0, async (config, assets, outputPath, projectRoot, projectName, sourceRoot, generatePackageJson2 = true, includeSrc = false, banner, footer) => {
|
|
558
558
|
const pendingAssets = Array.from(_nullishCoalesce(assets, () => ( [])));
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
559
|
+
pendingAssets.push({
|
|
560
|
+
input: projectRoot,
|
|
561
|
+
glob: "*.md",
|
|
562
|
+
output: "."
|
|
563
|
+
});
|
|
564
|
+
pendingAssets.push({
|
|
565
|
+
input: config.workspaceRoot,
|
|
566
|
+
glob: "LICENSE",
|
|
567
|
+
output: "."
|
|
568
|
+
});
|
|
566
569
|
if (generatePackageJson2 === false) {
|
|
567
570
|
pendingAssets.push({
|
|
568
|
-
input:
|
|
571
|
+
input: projectRoot,
|
|
569
572
|
glob: "package.json",
|
|
570
573
|
output: "."
|
|
571
574
|
});
|
|
572
575
|
}
|
|
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
576
|
if (includeSrc === true) {
|
|
581
577
|
pendingAssets.push({
|
|
582
578
|
input: sourceRoot,
|
|
@@ -587,10 +583,10 @@ var copyAssets = /* @__PURE__ */ _chunkYDYGZTJKcjs.__name.call(void 0, async (co
|
|
|
587
583
|
const nxJson = readNxConfig(config.workspaceRoot);
|
|
588
584
|
const projectGraph = _devkit.readCachedProjectGraph.call(void 0, );
|
|
589
585
|
const projectsConfigurations = _devkit.readProjectsConfigurationFromProjectGraph.call(void 0, projectGraph);
|
|
590
|
-
if (!_optionalChain([projectsConfigurations, 'optionalAccess',
|
|
586
|
+
if (!_optionalChain([projectsConfigurations, 'optionalAccess', _32 => _32.projects, 'optionalAccess', _33 => _33[projectName]])) {
|
|
591
587
|
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
588
|
}
|
|
593
|
-
const buildTarget = _optionalChain([projectsConfigurations, 'access',
|
|
589
|
+
const buildTarget = _optionalChain([projectsConfigurations, 'access', _34 => _34.projects, 'access', _35 => _35[projectName], 'access', _36 => _36.targets, 'optionalAccess', _37 => _37.build]);
|
|
594
590
|
if (!buildTarget) {
|
|
595
591
|
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 ${_chunkFG6XQ26Mcjs.joinPaths.call(void 0, projectRoot, "project.json")}`);
|
|
596
592
|
}
|
|
@@ -722,54 +718,6 @@ var addWorkspacePackageJsonFields = /* @__PURE__ */ _chunkYDYGZTJKcjs.__name.cal
|
|
|
722
718
|
packageJson.repository.directory ??= projectRoot ? projectRoot : _chunkFG6XQ26Mcjs.joinPaths.call(void 0, "packages", projectName);
|
|
723
719
|
return packageJson;
|
|
724
720
|
}, "addWorkspacePackageJsonFields");
|
|
725
|
-
var addPackageJsonExport = /* @__PURE__ */ _chunkYDYGZTJKcjs.__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__ */ _chunkYDYGZTJKcjs.__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
721
|
|
|
774
722
|
// ../build-tools/src/utilities/get-entry-points.ts
|
|
775
723
|
|
|
@@ -782,6 +730,7 @@ var _createtaskgraph = require('nx/src/tasks-runner/create-task-graph');
|
|
|
782
730
|
|
|
783
731
|
|
|
784
732
|
|
|
733
|
+
|
|
785
734
|
var _findworkspaceroot = require('nx/src/utils/find-workspace-root');
|
|
786
735
|
|
|
787
736
|
// ../../node_modules/.pnpm/unbuild@3.3.1_sass@1.83.4_typescript@5.7.3/node_modules/unbuild/dist/shared/unbuild.B2_7OVir.mjs
|
|
@@ -900,7 +849,7 @@ function inferEntries(pkg, sourceFiles, rootDir) {
|
|
|
900
849
|
const SOURCE_RE = new RegExp(
|
|
901
850
|
`(?<=/|$)${d}${isDir ? "" : String.raw`\.\w+`}$`
|
|
902
851
|
);
|
|
903
|
-
return _optionalChain([sourceFiles, 'access',
|
|
852
|
+
return _optionalChain([sourceFiles, 'access', _38 => _38.find, 'call', _39 => _39((i) => SOURCE_RE.test(i)), 'optionalAccess', _40 => _40.replace, 'call', _41 => _41(/(\.d\.(m|c)?ts|\.\w+)$/, "")]);
|
|
904
853
|
}, void 0);
|
|
905
854
|
if (!input) {
|
|
906
855
|
if (!_fs.existsSync.call(void 0, _pathe.resolve.call(void 0, rootDir || ".", output.file))) {
|
|
@@ -1160,7 +1109,7 @@ function shebangPlugin() {
|
|
|
1160
1109
|
if (output.type !== "chunk") {
|
|
1161
1110
|
continue;
|
|
1162
1111
|
}
|
|
1163
|
-
if (_optionalChain([output, 'access',
|
|
1112
|
+
if (_optionalChain([output, 'access', _42 => _42.code, 'optionalAccess', _43 => _43.match, 'call', _44 => _44(SHEBANG_RE)])) {
|
|
1164
1113
|
const outFile = _pathe.resolve.call(void 0, options.dir, fileName);
|
|
1165
1114
|
await makeExecutable(outFile);
|
|
1166
1115
|
}
|
|
@@ -1334,7 +1283,7 @@ function fixCJSExportTypePlugin() {
|
|
|
1334
1283
|
return {
|
|
1335
1284
|
name: "unbuild-fix-cjs-export-type",
|
|
1336
1285
|
renderChunk(code, info, opts) {
|
|
1337
|
-
if (info.type !== "chunk" || !info.fileName.endsWith(".d.cts") || !info.isEntry || _optionalChain([info, 'access',
|
|
1286
|
+
if (info.type !== "chunk" || !info.fileName.endsWith(".d.cts") || !info.isEntry || _optionalChain([info, 'access', _45 => _45.exports, 'optionalAccess', _46 => _46.length]) !== 1 || info.exports[0] !== "default") {
|
|
1338
1287
|
return;
|
|
1339
1288
|
}
|
|
1340
1289
|
return code.replace(
|
|
@@ -1451,7 +1400,7 @@ function getRollupOptions(ctx) {
|
|
|
1451
1400
|
].filter(Boolean),
|
|
1452
1401
|
external(originalId) {
|
|
1453
1402
|
const resolvedId = _utils3.resolveAlias.call(void 0, originalId, _aliases);
|
|
1454
|
-
const pkgName = _optionalChain([_mlly.parseNodeModulePath.call(void 0, resolvedId), 'optionalAccess',
|
|
1403
|
+
const pkgName = _optionalChain([_mlly.parseNodeModulePath.call(void 0, resolvedId), 'optionalAccess', _47 => _47.name]) || _optionalChain([_mlly.parseNodeModulePath.call(void 0, originalId), 'optionalAccess', _48 => _48.name]) || getpkg(originalId);
|
|
1455
1404
|
if (arrayIncludes(ctx.options.externals, pkgName) || arrayIncludes(ctx.options.externals, originalId) || arrayIncludes(ctx.options.externals, resolvedId)) {
|
|
1456
1405
|
return true;
|
|
1457
1406
|
}
|
|
@@ -1512,7 +1461,7 @@ function getRollupOptions(ctx) {
|
|
|
1512
1461
|
}
|
|
1513
1462
|
_chunkYDYGZTJKcjs.__name.call(void 0, getRollupOptions, "getRollupOptions");
|
|
1514
1463
|
async function rollupStub(ctx) {
|
|
1515
|
-
const babelPlugins = _optionalChain([ctx, 'access',
|
|
1464
|
+
const babelPlugins = _optionalChain([ctx, 'access', _49 => _49.options, 'access', _50 => _50.stubOptions, 'access', _51 => _51.jiti, 'access', _52 => _52.transformOptions, 'optionalAccess', _53 => _53.babel, 'optionalAccess', _54 => _54.plugins]);
|
|
1516
1465
|
const importedBabelPlugins = [];
|
|
1517
1466
|
const serializedJitiOptions = JSON.stringify(
|
|
1518
1467
|
{
|
|
@@ -1524,7 +1473,7 @@ async function rollupStub(ctx) {
|
|
|
1524
1473
|
transformOptions: {
|
|
1525
1474
|
...ctx.options.stubOptions.jiti.transformOptions,
|
|
1526
1475
|
babel: {
|
|
1527
|
-
..._optionalChain([ctx, 'access',
|
|
1476
|
+
..._optionalChain([ctx, 'access', _55 => _55.options, 'access', _56 => _56.stubOptions, 'access', _57 => _57.jiti, 'access', _58 => _58.transformOptions, 'optionalAccess', _59 => _59.babel]),
|
|
1528
1477
|
plugins: "__$BABEL_PLUGINS"
|
|
1529
1478
|
}
|
|
1530
1479
|
}
|
|
@@ -1919,7 +1868,7 @@ _chunkYDYGZTJKcjs.__name.call(void 0, copyBuild, "copyBuild");
|
|
|
1919
1868
|
async function build(rootDir, stub, inputConfig = {}) {
|
|
1920
1869
|
rootDir = _pathe.resolve.call(void 0, process.cwd(), rootDir || ".");
|
|
1921
1870
|
const jiti = _jiti.createJiti.call(void 0, rootDir);
|
|
1922
|
-
const _buildConfig = await jiti.import(_optionalChain([inputConfig, 'optionalAccess',
|
|
1871
|
+
const _buildConfig = await jiti.import(_optionalChain([inputConfig, 'optionalAccess', _60 => _60.config]) || "./build.config", {
|
|
1923
1872
|
try: !inputConfig.config,
|
|
1924
1873
|
default: true
|
|
1925
1874
|
}) || {};
|
|
@@ -1946,7 +1895,7 @@ async function build(rootDir, stub, inputConfig = {}) {
|
|
|
1946
1895
|
_chunkYDYGZTJKcjs.__name.call(void 0, build, "build");
|
|
1947
1896
|
async function _build(rootDir, inputConfig = {}, buildConfig, pkg, cleanedDirs, _stubMode, _watchMode) {
|
|
1948
1897
|
const preset = await resolvePreset(
|
|
1949
|
-
buildConfig.preset || _optionalChain([pkg, 'access',
|
|
1898
|
+
buildConfig.preset || _optionalChain([pkg, 'access', _61 => _61.unbuild, 'optionalAccess', _62 => _62.preset]) || _optionalChain([pkg, 'access', _63 => _63.build, 'optionalAccess', _64 => _64.preset]) || inputConfig.preset || "auto",
|
|
1950
1899
|
rootDir
|
|
1951
1900
|
);
|
|
1952
1901
|
const options = _defu.defu.call(void 0,
|
|
@@ -1955,7 +1904,7 @@ async function _build(rootDir, inputConfig = {}, buildConfig, pkg, cleanedDirs,
|
|
|
1955
1904
|
inputConfig,
|
|
1956
1905
|
preset,
|
|
1957
1906
|
{
|
|
1958
|
-
name: (_optionalChain([pkg, 'optionalAccess',
|
|
1907
|
+
name: (_optionalChain([pkg, 'optionalAccess', _65 => _65.name]) || "").split("/").pop() || "default",
|
|
1959
1908
|
rootDir,
|
|
1960
1909
|
entries: [],
|
|
1961
1910
|
clean: true,
|
|
@@ -2136,24 +2085,24 @@ async function _build(rootDir, inputConfig = {}, buildConfig, pkg, cleanedDirs,
|
|
|
2136
2085
|
for (const entry of ctx.buildEntries.filter((e) => !e.chunk)) {
|
|
2137
2086
|
let totalBytes = entry.bytes || 0;
|
|
2138
2087
|
for (const chunk of entry.chunks || []) {
|
|
2139
|
-
totalBytes += _optionalChain([ctx, 'access',
|
|
2088
|
+
totalBytes += _optionalChain([ctx, 'access', _66 => _66.buildEntries, 'access', _67 => _67.find, 'call', _68 => _68((e) => e.path === chunk), 'optionalAccess', _69 => _69.bytes]) || 0;
|
|
2140
2089
|
}
|
|
2141
2090
|
let line = ` ${_utils.colors.bold(rPath(entry.path))} (` + [
|
|
2142
2091
|
totalBytes && `total size: ${_utils.colors.cyan(_prettybytes2.default.call(void 0, totalBytes))}`,
|
|
2143
2092
|
entry.bytes && `chunk size: ${_utils.colors.cyan(_prettybytes2.default.call(void 0, entry.bytes))}`,
|
|
2144
|
-
_optionalChain([entry, 'access',
|
|
2093
|
+
_optionalChain([entry, 'access', _70 => _70.exports, 'optionalAccess', _71 => _71.length]) && `exports: ${_utils.colors.gray(entry.exports.join(", "))}`
|
|
2145
2094
|
].filter(Boolean).join(", ") + ")";
|
|
2146
|
-
if (_optionalChain([entry, 'access',
|
|
2095
|
+
if (_optionalChain([entry, 'access', _72 => _72.chunks, 'optionalAccess', _73 => _73.length])) {
|
|
2147
2096
|
line += "\n" + entry.chunks.map((p) => {
|
|
2148
2097
|
const chunk = ctx.buildEntries.find((e) => e.path === p) || {};
|
|
2149
2098
|
return _utils.colors.gray(
|
|
2150
2099
|
" \u2514\u2500 " + rPath(p) + _utils.colors.bold(
|
|
2151
|
-
chunk.bytes ? ` (${_prettybytes2.default.call(void 0, _optionalChain([chunk, 'optionalAccess',
|
|
2100
|
+
chunk.bytes ? ` (${_prettybytes2.default.call(void 0, _optionalChain([chunk, 'optionalAccess', _74 => _74.bytes]))})` : ""
|
|
2152
2101
|
)
|
|
2153
2102
|
);
|
|
2154
2103
|
}).join("\n");
|
|
2155
2104
|
}
|
|
2156
|
-
if (_optionalChain([entry, 'access',
|
|
2105
|
+
if (_optionalChain([entry, 'access', _75 => _75.modules, 'optionalAccess', _76 => _76.length])) {
|
|
2157
2106
|
line += "\n" + entry.modules.filter((m) => m.id.includes("node_modules")).sort((a, b) => (b.bytes || 0) - (a.bytes || 0)).map((m) => {
|
|
2158
2107
|
return _utils.colors.gray(
|
|
2159
2108
|
" \u{1F4E6} " + rPath(m.id) + _utils.colors.bold(m.bytes ? ` (${_prettybytes2.default.call(void 0, m.bytes)})` : "")
|
|
@@ -2261,6 +2210,9 @@ async function resolveOptions(options, config) {
|
|
|
2261
2210
|
dependencies = dependencies.filter((deps) => deps.name !== tsLibDependency.name);
|
|
2262
2211
|
dependencies.push(tsLibDependency);
|
|
2263
2212
|
}
|
|
2213
|
+
const entries = _nullishCoalesce(options.entry, () => ( [
|
|
2214
|
+
sourceRoot
|
|
2215
|
+
]));
|
|
2264
2216
|
const resolvedOptions = {
|
|
2265
2217
|
name: projectName,
|
|
2266
2218
|
config,
|
|
@@ -2269,23 +2221,24 @@ async function resolveOptions(options, config) {
|
|
|
2269
2221
|
projectName,
|
|
2270
2222
|
tsconfig,
|
|
2271
2223
|
clean: false,
|
|
2272
|
-
entries:
|
|
2273
|
-
{
|
|
2224
|
+
entries: entries.reduce((ret, entry) => {
|
|
2225
|
+
ret.push({
|
|
2274
2226
|
builder: "mkdist",
|
|
2275
|
-
input: `.${
|
|
2227
|
+
input: `.${entry.replace(options.projectRoot, "")}`,
|
|
2276
2228
|
outDir: _chunkFG6XQ26Mcjs.joinPaths.call(void 0, _path.relative.call(void 0, _chunkFG6XQ26Mcjs.joinPaths.call(void 0, config.workspaceRoot, options.projectRoot), config.workspaceRoot), outputPath, "dist"),
|
|
2277
|
-
declaration: options.emitTypes !== false,
|
|
2229
|
+
declaration: options.emitTypes !== false ? "compatible" : false,
|
|
2278
2230
|
format: "esm"
|
|
2279
|
-
}
|
|
2280
|
-
{
|
|
2231
|
+
});
|
|
2232
|
+
ret.push({
|
|
2281
2233
|
builder: "mkdist",
|
|
2282
|
-
input: `.${
|
|
2234
|
+
input: `.${entry.replace(options.projectRoot, "")}`,
|
|
2283
2235
|
outDir: _chunkFG6XQ26Mcjs.joinPaths.call(void 0, _path.relative.call(void 0, _chunkFG6XQ26Mcjs.joinPaths.call(void 0, config.workspaceRoot, options.projectRoot), config.workspaceRoot), outputPath, "dist"),
|
|
2284
|
-
declaration: options.emitTypes !== false,
|
|
2236
|
+
declaration: options.emitTypes !== false ? "compatible" : false,
|
|
2285
2237
|
format: "cjs",
|
|
2286
2238
|
ext: "cjs"
|
|
2287
|
-
}
|
|
2288
|
-
|
|
2239
|
+
});
|
|
2240
|
+
return ret;
|
|
2241
|
+
}, []),
|
|
2289
2242
|
declaration: options.emitTypes !== false ? "compatible" : false,
|
|
2290
2243
|
failOnWarn: false,
|
|
2291
2244
|
sourcemap: _nullishCoalesce(options.sourcemap, () => ( !!options.debug)),
|
|
@@ -2334,7 +2287,8 @@ async function resolveOptions(options, config) {
|
|
|
2334
2287
|
]
|
|
2335
2288
|
},
|
|
2336
2289
|
esbuild: {
|
|
2337
|
-
minify: options.minify
|
|
2290
|
+
minify: options.minify || !options.debug,
|
|
2291
|
+
sourceMap: options.sourcemap || !!options.debug,
|
|
2338
2292
|
splitting: options.splitting !== false,
|
|
2339
2293
|
treeShaking: options.treeShaking !== false,
|
|
2340
2294
|
color: true,
|
|
@@ -2373,6 +2327,26 @@ async function resolveOptions(options, config) {
|
|
|
2373
2327
|
return resolvedOptions;
|
|
2374
2328
|
}
|
|
2375
2329
|
_chunkYDYGZTJKcjs.__name.call(void 0, resolveOptions, "resolveOptions");
|
|
2330
|
+
var addPackageJsonExport = /* @__PURE__ */ _chunkYDYGZTJKcjs.__name.call(void 0, (file, type = "module", sourceRoot) => {
|
|
2331
|
+
let entry = file.replaceAll("\\", "/");
|
|
2332
|
+
if (sourceRoot) {
|
|
2333
|
+
entry = entry.replace(sourceRoot, "");
|
|
2334
|
+
}
|
|
2335
|
+
return {
|
|
2336
|
+
"import": {
|
|
2337
|
+
"types": `./dist/${entry}.d.ts`,
|
|
2338
|
+
"default": `./dist/${entry}.mjs`
|
|
2339
|
+
},
|
|
2340
|
+
"require": {
|
|
2341
|
+
"types": `./dist/${entry}.d.ts`,
|
|
2342
|
+
"default": `./dist/${entry}.cjs`
|
|
2343
|
+
},
|
|
2344
|
+
"default": {
|
|
2345
|
+
"types": `./dist/${entry}.d.ts`,
|
|
2346
|
+
"default": type === "commonjs" ? `./dist/${entry}.cjs` : `./dist/${entry}.mjs`
|
|
2347
|
+
}
|
|
2348
|
+
};
|
|
2349
|
+
}, "addPackageJsonExport");
|
|
2376
2350
|
async function generatePackageJson(options) {
|
|
2377
2351
|
if (options.generatePackageJson !== false && _fs.existsSync.call(void 0, _chunkFG6XQ26Mcjs.joinPaths.call(void 0, options.projectRoot, "package.json"))) {
|
|
2378
2352
|
_chunkFG6XQ26Mcjs.writeDebug.call(void 0, " \u270D\uFE0F Writing package.json file", options.config);
|
|
@@ -2388,7 +2362,32 @@ async function generatePackageJson(options) {
|
|
|
2388
2362
|
let packageJson = JSON.parse(packageJsonContent);
|
|
2389
2363
|
packageJson = await addPackageDependencies(options.config.workspaceRoot, options.projectRoot, options.projectName, packageJson);
|
|
2390
2364
|
packageJson = await addWorkspacePackageJsonFields(options.config, options.projectRoot, options.sourceRoot, options.projectName, false, packageJson);
|
|
2391
|
-
|
|
2365
|
+
packageJson.exports ??= {};
|
|
2366
|
+
const files = await new (0, _glob.Glob)("**/*.{ts,tsx}", {
|
|
2367
|
+
absolute: false,
|
|
2368
|
+
cwd: options.sourceRoot,
|
|
2369
|
+
root: options.sourceRoot
|
|
2370
|
+
}).walk();
|
|
2371
|
+
files.forEach((file) => {
|
|
2372
|
+
addPackageJsonExport(file, packageJson.type, options.sourceRoot);
|
|
2373
|
+
const split = file.split(".");
|
|
2374
|
+
split.pop();
|
|
2375
|
+
const entry = split.join(".").replaceAll("\\", "/");
|
|
2376
|
+
packageJson.exports[`./${entry}`] ??= addPackageJsonExport(entry, packageJson.type, options.sourceRoot);
|
|
2377
|
+
});
|
|
2378
|
+
packageJson.main ??= "./dist/index.cjs";
|
|
2379
|
+
packageJson.module ??= "./dist/index.mjs";
|
|
2380
|
+
packageJson.types ??= "./dist/index.d.ts";
|
|
2381
|
+
packageJson.exports ??= {};
|
|
2382
|
+
packageJson.exports = Object.keys(packageJson.exports).reduce((ret, key) => {
|
|
2383
|
+
if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
|
|
2384
|
+
ret[key.replace("/index", "")] = packageJson.exports[key];
|
|
2385
|
+
}
|
|
2386
|
+
return ret;
|
|
2387
|
+
}, packageJson.exports);
|
|
2388
|
+
packageJson.exports["./package.json"] ??= "./package.json";
|
|
2389
|
+
packageJson.exports["."] ??= addPackageJsonExport("index", packageJson.type, options.sourceRoot);
|
|
2390
|
+
await _devkit.writeJsonFile.call(void 0, _chunkFG6XQ26Mcjs.joinPaths.call(void 0, options.outDir, "package.json"), packageJson);
|
|
2392
2391
|
stopwatch();
|
|
2393
2392
|
}
|
|
2394
2393
|
return options;
|
|
@@ -2401,7 +2400,7 @@ async function executeUnbuild(options) {
|
|
|
2401
2400
|
const config = {
|
|
2402
2401
|
...options,
|
|
2403
2402
|
config: null,
|
|
2404
|
-
rootDir: options.projectRoot
|
|
2403
|
+
rootDir: _chunkFG6XQ26Mcjs.joinPaths.call(void 0, options.config.workspaceRoot, options.projectRoot)
|
|
2405
2404
|
};
|
|
2406
2405
|
_chunkFG6XQ26Mcjs.writeTrace.call(void 0, `Running with unbuild configuration:
|
|
2407
2406
|
${_chunkFG6XQ26Mcjs.formatLogMessage.call(void 0, config)}
|
|
@@ -2462,4 +2461,9 @@ _chunkYDYGZTJKcjs.__name.call(void 0, build2, "build");
|
|
|
2462
2461
|
|
|
2463
2462
|
|
|
2464
2463
|
|
|
2465
|
-
|
|
2464
|
+
|
|
2465
|
+
|
|
2466
|
+
|
|
2467
|
+
|
|
2468
|
+
|
|
2469
|
+
exports.resolveOptions = resolveOptions; exports.generatePackageJson = generatePackageJson; exports.executeUnbuild = executeUnbuild; exports.copyBuildAssets = copyBuildAssets; exports.cleanOutputPath = cleanOutputPath; exports.build = build2;
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _chunkSN3G5SIPcjs = require('./chunk-SN3G5SIP.cjs');
|
|
4
9
|
|
|
5
10
|
|
|
6
11
|
|
|
@@ -25,4 +30,9 @@ require('./chunk-YDYGZTJK.cjs');
|
|
|
25
30
|
|
|
26
31
|
|
|
27
32
|
|
|
28
|
-
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
exports.build = _chunkSN3G5SIPcjs.build; exports.clean = _chunk5E3NJ26Lcjs.clean; exports.cleanDirectories = _chunk5E3NJ26Lcjs.cleanDirectories; exports.cleanOutputPath = _chunkSN3G5SIPcjs.cleanOutputPath; exports.copyBuildAssets = _chunkSN3G5SIPcjs.copyBuildAssets; exports.createTsCompilerOptions = _chunkV627S7QUcjs.createTsCompilerOptions; exports.executeUnbuild = _chunkSN3G5SIPcjs.executeUnbuild; exports.generatePackageJson = _chunkSN3G5SIPcjs.generatePackageJson; exports.getDefaultBuildPlugins = _chunkY2DOCJBEcjs.getDefaultBuildPlugins; exports.loadConfig = _chunkV627S7QUcjs.loadConfig; exports.resolveOptions = _chunkSN3G5SIPcjs.resolveOptions;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { build } from './build.cjs';
|
|
1
|
+
export { build, cleanOutputPath, copyBuildAssets, executeUnbuild, generatePackageJson, resolveOptions } from './build.cjs';
|
|
2
2
|
export { clean, cleanDirectories } from './clean.cjs';
|
|
3
3
|
export { getDefaultBuildPlugins } from './config.cjs';
|
|
4
4
|
export { DeepPartial, UnbuildCLIOptions, UnbuildOptions, UnbuildResolvedOptions } from './types.cjs';
|
|
@@ -6,6 +6,7 @@ import { DependentBuildableProjectNode } from '@nx/js/src/utils/buildable-libs-u
|
|
|
6
6
|
import { StormConfig } from '@storm-software/config';
|
|
7
7
|
import ts from 'typescript';
|
|
8
8
|
import { RollupBuildOptions } from 'unbuild';
|
|
9
|
+
import '@storm-software/config/types';
|
|
9
10
|
import 'rollup';
|
|
10
11
|
import '@storm-software/build-tools';
|
|
11
12
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { build } from './build.js';
|
|
1
|
+
export { build, cleanOutputPath, copyBuildAssets, executeUnbuild, generatePackageJson, resolveOptions } from './build.js';
|
|
2
2
|
export { clean, cleanDirectories } from './clean.js';
|
|
3
3
|
export { getDefaultBuildPlugins } from './config.js';
|
|
4
4
|
export { DeepPartial, UnbuildCLIOptions, UnbuildOptions, UnbuildResolvedOptions } from './types.js';
|
|
@@ -6,6 +6,7 @@ import { DependentBuildableProjectNode } from '@nx/js/src/utils/buildable-libs-u
|
|
|
6
6
|
import { StormConfig } from '@storm-software/config';
|
|
7
7
|
import ts from 'typescript';
|
|
8
8
|
import { RollupBuildOptions } from 'unbuild';
|
|
9
|
+
import '@storm-software/config/types';
|
|
9
10
|
import 'rollup';
|
|
10
11
|
import '@storm-software/build-tools';
|
|
11
12
|
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
build
|
|
3
|
-
|
|
2
|
+
build,
|
|
3
|
+
cleanOutputPath,
|
|
4
|
+
copyBuildAssets,
|
|
5
|
+
executeUnbuild,
|
|
6
|
+
generatePackageJson,
|
|
7
|
+
resolveOptions
|
|
8
|
+
} from "./chunk-DORAESSZ.js";
|
|
4
9
|
import {
|
|
5
10
|
clean,
|
|
6
11
|
cleanDirectories
|
|
@@ -22,7 +27,12 @@ export {
|
|
|
22
27
|
build,
|
|
23
28
|
clean,
|
|
24
29
|
cleanDirectories,
|
|
30
|
+
cleanOutputPath,
|
|
31
|
+
copyBuildAssets,
|
|
25
32
|
createTsCompilerOptions,
|
|
33
|
+
executeUnbuild,
|
|
34
|
+
generatePackageJson,
|
|
26
35
|
getDefaultBuildPlugins,
|
|
27
|
-
loadConfig
|
|
36
|
+
loadConfig,
|
|
37
|
+
resolveOptions
|
|
28
38
|
};
|
package/dist/types.d.cts
CHANGED
|
@@ -5,6 +5,12 @@ type DeepPartial<T> = T extends object ? {
|
|
|
5
5
|
[P in keyof T]?: DeepPartial<T[P]>;
|
|
6
6
|
} : T;
|
|
7
7
|
type UnbuildOptions = Omit<TypeScriptBuildOptions, "entry" | "format"> & Omit<BuildOptions, "entries" | "rootDir" | "externals" | "rollupConfig" | "outDir" | "declaration" | "format" | "parallel"> & {
|
|
8
|
+
/**
|
|
9
|
+
* The directories to run the build process out of
|
|
10
|
+
*
|
|
11
|
+
* @defaultValue ["{sourceRoot}"]
|
|
12
|
+
*/
|
|
13
|
+
entry?: string[];
|
|
8
14
|
/**
|
|
9
15
|
* Path to a rollup configuration file relative to the project root
|
|
10
16
|
*/
|
package/dist/types.d.ts
CHANGED
|
@@ -5,6 +5,12 @@ type DeepPartial<T> = T extends object ? {
|
|
|
5
5
|
[P in keyof T]?: DeepPartial<T[P]>;
|
|
6
6
|
} : T;
|
|
7
7
|
type UnbuildOptions = Omit<TypeScriptBuildOptions, "entry" | "format"> & Omit<BuildOptions, "entries" | "rootDir" | "externals" | "rollupConfig" | "outDir" | "declaration" | "format" | "parallel"> & {
|
|
8
|
+
/**
|
|
9
|
+
* The directories to run the build process out of
|
|
10
|
+
*
|
|
11
|
+
* @defaultValue ["{sourceRoot}"]
|
|
12
|
+
*/
|
|
13
|
+
entry?: string[];
|
|
8
14
|
/**
|
|
9
15
|
* Path to a rollup configuration file relative to the project root
|
|
10
16
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storm-software/unbuild",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing `unbuild` utilities for building Storm Software libraries and applications",
|
|
6
6
|
"repository": {
|
|
@@ -161,6 +161,7 @@
|
|
|
161
161
|
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
162
162
|
"@rollup/plugin-replace": "^6.0.2",
|
|
163
163
|
"defu": "6.1.4",
|
|
164
|
+
"glob": "^11.0.1",
|
|
164
165
|
"jiti": "^2.4.2",
|
|
165
166
|
"rollup": "^4.29.1",
|
|
166
167
|
"rollup-plugin-typescript2": "0.36.0",
|
|
@@ -172,7 +173,7 @@
|
|
|
172
173
|
"@rollup/pluginutils": "^5.1.4",
|
|
173
174
|
"@storm-software/build-tools": "0.132.0",
|
|
174
175
|
"@storm-software/config": "1.97.4",
|
|
175
|
-
"@storm-software/config-tools": "1.
|
|
176
|
+
"@storm-software/config-tools": "1.140.0",
|
|
176
177
|
"@swc/core": "1.7.26",
|
|
177
178
|
"@types/node": "^22.10.2",
|
|
178
179
|
"commander": "^12.1.0",
|