bunup 0.8.35 → 0.8.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-vfvfb7pv.js → chunk-4y0hvzcd.js} +17 -14
- package/dist/{chunk-gdnf8ebe.js → chunk-ct0a7gyb.js} +2 -2
- package/dist/{chunk-h9jzw5qq.js → chunk-g3b9h2ys.js} +9 -9
- package/dist/{chunk-8z361mhm.js → chunk-ka4kbkdd.js} +64 -109
- package/dist/{chunk-by2b1r3m.js → chunk-phd7cn7e.js} +53 -59
- package/dist/{chunk-0r7kktgh.js → chunk-w13gdbvp.js} +15 -6
- package/dist/cli/index.js +345 -166
- package/dist/index.d.ts +324 -1
- package/dist/index.js +3 -3
- package/dist/plugins.d.ts +313 -1
- package/dist/plugins.js +2 -2
- package/package.json +101 -92
- package/bin/bunup.mjs +0 -3
- package/dist/chunk-8sqm3fje.d.ts +0 -359
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
displayBunupGradientArt
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-ct0a7gyb.js";
|
|
5
5
|
import {
|
|
6
6
|
pathExistsSync
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ka4kbkdd.js";
|
|
8
8
|
|
|
9
9
|
// src/cli/new.ts
|
|
10
10
|
import { renameSync } from "fs";
|
|
@@ -29,12 +29,14 @@ var MONOREPO_FIRST_PACKAGE_NAME_PLACEHOLDER = "package-1";
|
|
|
29
29
|
var MONOREPO_PACKAGES_DIR = "packages";
|
|
30
30
|
var TEMPLATES = [
|
|
31
31
|
{
|
|
32
|
+
type: "typescript",
|
|
32
33
|
defaultName: "my-ts-lib",
|
|
33
34
|
name: "Typescript Library",
|
|
34
35
|
dir: "ts-lib",
|
|
35
36
|
monorepoDir: "ts-lib-monorepo"
|
|
36
37
|
},
|
|
37
38
|
{
|
|
39
|
+
type: "react",
|
|
38
40
|
defaultName: "my-react-lib",
|
|
39
41
|
name: "React Library",
|
|
40
42
|
dir: "react-lib"
|
|
@@ -96,7 +98,7 @@ async function newProject() {
|
|
|
96
98
|
const [githubUsername, githubRepoName] = githubRepoInfo.split("/");
|
|
97
99
|
await tasks([
|
|
98
100
|
{
|
|
99
|
-
title: "
|
|
101
|
+
title: "Downloading template",
|
|
100
102
|
task: async () => {
|
|
101
103
|
const templatePath = useMonorepo ? template.monorepoDir : template.dir;
|
|
102
104
|
await downloadTemplate(`github:${TEMPLATE_OWNER}/${TEMPLATE_REPO}/${templatePath}`, {
|
|
@@ -131,17 +133,18 @@ async function newProject() {
|
|
|
131
133
|
}
|
|
132
134
|
]);
|
|
133
135
|
outro(`
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
136
|
+
${pc.green("\u2728 Project scaffolded successfully! \u2728")}
|
|
137
|
+
|
|
138
|
+
${pc.bold("Ready to launch your awesome new project?")}
|
|
139
|
+
|
|
140
|
+
${pc.cyan("cd")} ${projectName}
|
|
141
|
+
${pc.cyan("bun install")}
|
|
142
|
+
${pc.cyan("bun run dev")}${pc.dim(" (watch mode for development)")}${template.type === "react" ? `
|
|
143
|
+
${pc.cyan("bun run dev:test")} ${pc.dim("(preview components in a test Next.js app)")} ` : ""}
|
|
144
|
+
|
|
145
|
+
${pc.dim("Learn more:")} ${pc.underline("https://bunup.dev/docs")}
|
|
146
|
+
|
|
147
|
+
${pc.yellow("Happy coding!")} \uD83D\uDE80
|
|
145
148
|
`);
|
|
146
149
|
}
|
|
147
150
|
function getProjectPath(projectName) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
logger
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ka4kbkdd.js";
|
|
4
4
|
|
|
5
5
|
// src/cli/utils.ts
|
|
6
6
|
import pc from "picocolors";
|
|
@@ -17,7 +17,7 @@ function displayBunupGradientArt() {
|
|
|
17
17
|
`);
|
|
18
18
|
logger.space();
|
|
19
19
|
for (const line of lines) {
|
|
20
|
-
|
|
20
|
+
console.log(pc.cyan(line));
|
|
21
21
|
}
|
|
22
22
|
logger.space();
|
|
23
23
|
}
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
} from "./chunk-gh7z7s46.js";
|
|
5
5
|
import {
|
|
6
6
|
displayBunupGradientArt
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ct0a7gyb.js";
|
|
8
8
|
import {
|
|
9
9
|
formatListWithAnd
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-ka4kbkdd.js";
|
|
11
11
|
|
|
12
12
|
// src/cli/init.ts
|
|
13
13
|
import fs from "fs";
|
|
@@ -334,15 +334,15 @@ function showSuccessOutro(isWorkspace) {
|
|
|
334
334
|
const devCommand = isWorkspace ? `${pc.cyan("bun run dev")} - Start development mode (watches all packages)` : `${pc.cyan("bun run dev")} - Start development mode`;
|
|
335
335
|
const filterCommand = isWorkspace ? `${pc.cyan("bunup --filter core,utils")} - Build specific packages` : "";
|
|
336
336
|
outro(`
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
337
|
+
${pc.green("\u2728 Bunup initialized successfully! \u2728")}
|
|
338
|
+
|
|
339
|
+
${buildCommand}
|
|
340
|
+
${devCommand}${isWorkspace ? `
|
|
341
|
+
${filterCommand}` : ""}
|
|
342
342
|
|
|
343
|
-
|
|
343
|
+
${pc.dim("Learn more:")} ${pc.underline("https://bunup.dev/docs")}
|
|
344
344
|
|
|
345
|
-
|
|
345
|
+
${pc.yellow("Happy building!")} \uD83D\uDE80
|
|
346
346
|
`);
|
|
347
347
|
}
|
|
348
348
|
async function installBunup() {
|
|
@@ -26,31 +26,6 @@ function setSilent(value) {
|
|
|
26
26
|
class Logger {
|
|
27
27
|
static instance;
|
|
28
28
|
loggedOnceMessages = new Set;
|
|
29
|
-
MAX_LABEL_LENGTH = 3;
|
|
30
|
-
cliColor = pc.blue;
|
|
31
|
-
mutedColor = pc.dim;
|
|
32
|
-
infoColor = pc.cyan;
|
|
33
|
-
warnColor = pc.yellow;
|
|
34
|
-
errorColor = pc.red;
|
|
35
|
-
defaultColor = pc.white;
|
|
36
|
-
progressFgColorMap = {
|
|
37
|
-
ESM: pc.yellow,
|
|
38
|
-
CJS: pc.green,
|
|
39
|
-
IIFE: pc.magenta,
|
|
40
|
-
DTS: pc.blue
|
|
41
|
-
};
|
|
42
|
-
progressIdentifierBgColorMap = {
|
|
43
|
-
ESM: pc.bgYellow,
|
|
44
|
-
CJS: pc.bgGreen,
|
|
45
|
-
IIFE: pc.bgMagenta,
|
|
46
|
-
DTS: pc.bgBlue
|
|
47
|
-
};
|
|
48
|
-
labels = {
|
|
49
|
-
cli: "CLI",
|
|
50
|
-
info: "INFO",
|
|
51
|
-
warn: "WARN",
|
|
52
|
-
error: "ERROR"
|
|
53
|
-
};
|
|
54
29
|
constructor() {}
|
|
55
30
|
static getInstance() {
|
|
56
31
|
if (!Logger.instance) {
|
|
@@ -62,111 +37,91 @@ class Logger {
|
|
|
62
37
|
this.loggedOnceMessages.clear();
|
|
63
38
|
}
|
|
64
39
|
shouldLog(options) {
|
|
65
|
-
if (!options?.once)
|
|
40
|
+
if (!options?.once) {
|
|
66
41
|
return true;
|
|
67
|
-
|
|
42
|
+
}
|
|
43
|
+
if (this.loggedOnceMessages.has(options.once)) {
|
|
68
44
|
return false;
|
|
45
|
+
}
|
|
69
46
|
this.loggedOnceMessages.add(options.once);
|
|
70
47
|
return true;
|
|
71
48
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
49
|
+
getIcon(type, tick) {
|
|
50
|
+
if (tick) {
|
|
51
|
+
return pc.green("\u2713");
|
|
52
|
+
}
|
|
53
|
+
const iconMap = {
|
|
54
|
+
info: pc.blue("i"),
|
|
55
|
+
warn: pc.yellow("!"),
|
|
56
|
+
error: pc.red("\u2715")
|
|
57
|
+
};
|
|
58
|
+
return iconMap[type];
|
|
59
|
+
}
|
|
60
|
+
formatIdentifier(identifier) {
|
|
61
|
+
return identifier ? ` ${pc.bgBlue(pc.black(` ${identifier} `))}` : "";
|
|
62
|
+
}
|
|
63
|
+
formatMessage(options) {
|
|
64
|
+
const {
|
|
65
|
+
message,
|
|
66
|
+
identifier,
|
|
67
|
+
muted = false,
|
|
68
|
+
tick = false,
|
|
69
|
+
type = "info"
|
|
70
|
+
} = options;
|
|
71
|
+
const icon = this.getIcon(type, tick);
|
|
72
|
+
const styledMessage = muted ? pc.dim(message) : message;
|
|
73
|
+
const identifierPart = this.formatIdentifier(identifier);
|
|
74
|
+
return `${icon} ${styledMessage}${identifierPart}`;
|
|
84
75
|
}
|
|
85
76
|
output(message, options = {}, logFn = console.log) {
|
|
86
|
-
if (silent || !this.shouldLog(options))
|
|
77
|
+
if (silent || !this.shouldLog(options)) {
|
|
87
78
|
return;
|
|
88
|
-
|
|
79
|
+
}
|
|
80
|
+
if (options.verticalSpace) {
|
|
89
81
|
logFn("");
|
|
82
|
+
}
|
|
90
83
|
logFn(message);
|
|
91
|
-
if (options.verticalSpace)
|
|
84
|
+
if (options.verticalSpace) {
|
|
92
85
|
logFn("");
|
|
93
|
-
|
|
94
|
-
cli(message, options = {}) {
|
|
95
|
-
const formattedMessage = this.formatMessage({
|
|
96
|
-
fgColor: this.cliColor,
|
|
97
|
-
bgColor: pc.bgBlue,
|
|
98
|
-
label: this.labels.cli,
|
|
99
|
-
message,
|
|
100
|
-
identifier: options.identifier,
|
|
101
|
-
muted: options.muted
|
|
102
|
-
});
|
|
103
|
-
this.output(formattedMessage, options);
|
|
86
|
+
}
|
|
104
87
|
}
|
|
105
88
|
info(message, options = {}) {
|
|
106
89
|
const formattedMessage = this.formatMessage({
|
|
107
|
-
|
|
108
|
-
bgColor: pc.bgCyan,
|
|
109
|
-
label: this.labels.info,
|
|
90
|
+
...options,
|
|
110
91
|
message,
|
|
111
|
-
|
|
112
|
-
muted: options.muted
|
|
92
|
+
type: "info"
|
|
113
93
|
});
|
|
114
94
|
this.output(formattedMessage, options);
|
|
115
95
|
}
|
|
116
96
|
warn(message, options = {}) {
|
|
117
97
|
const formattedMessage = this.formatMessage({
|
|
118
|
-
|
|
119
|
-
bgColor: pc.bgYellow,
|
|
120
|
-
label: this.labels.warn,
|
|
98
|
+
...options,
|
|
121
99
|
message,
|
|
122
|
-
|
|
123
|
-
muted: options.muted
|
|
100
|
+
type: "warn"
|
|
124
101
|
});
|
|
125
|
-
this.output(formattedMessage, options
|
|
102
|
+
this.output(formattedMessage, options);
|
|
126
103
|
}
|
|
127
104
|
error(message, options = {}) {
|
|
128
105
|
const formattedMessage = this.formatMessage({
|
|
129
|
-
|
|
130
|
-
bgColor: pc.bgRed,
|
|
131
|
-
label: this.labels.error,
|
|
106
|
+
...options,
|
|
132
107
|
message,
|
|
133
|
-
|
|
134
|
-
muted: options.muted
|
|
108
|
+
type: "error"
|
|
135
109
|
});
|
|
136
|
-
this.output(formattedMessage, options
|
|
137
|
-
}
|
|
138
|
-
space() {
|
|
139
|
-
if (silent)
|
|
140
|
-
return;
|
|
141
|
-
console.log("");
|
|
142
|
-
}
|
|
143
|
-
getProgressFgColor(label) {
|
|
144
|
-
for (const [key, colorFn] of Object.entries(this.progressFgColorMap)) {
|
|
145
|
-
if (label.includes(key))
|
|
146
|
-
return colorFn;
|
|
147
|
-
}
|
|
148
|
-
return this.defaultColor;
|
|
149
|
-
}
|
|
150
|
-
getProgressBgColor(label) {
|
|
151
|
-
for (const [key, colorFn] of Object.entries(this.progressIdentifierBgColorMap)) {
|
|
152
|
-
if (label.includes(key))
|
|
153
|
-
return colorFn;
|
|
154
|
-
}
|
|
155
|
-
return pc.bgWhite;
|
|
110
|
+
this.output(formattedMessage, options);
|
|
156
111
|
}
|
|
157
|
-
|
|
158
|
-
const fgColor = this.getProgressFgColor(label);
|
|
159
|
-
const bgColor = this.getProgressBgColor(label);
|
|
112
|
+
success(message, options = {}) {
|
|
160
113
|
const formattedMessage = this.formatMessage({
|
|
161
|
-
|
|
162
|
-
bgColor,
|
|
163
|
-
label,
|
|
114
|
+
...options,
|
|
164
115
|
message,
|
|
165
|
-
|
|
166
|
-
muted: options.muted
|
|
116
|
+
tick: true
|
|
167
117
|
});
|
|
168
118
|
this.output(formattedMessage, options);
|
|
169
119
|
}
|
|
120
|
+
space() {
|
|
121
|
+
if (!silent) {
|
|
122
|
+
console.log("");
|
|
123
|
+
}
|
|
124
|
+
}
|
|
170
125
|
}
|
|
171
126
|
function logTable(columns, data, footer) {
|
|
172
127
|
if (silent)
|
|
@@ -259,7 +214,7 @@ var KNOWN_ERRORS = [
|
|
|
259
214
|
pattern: /Could not resolve: "bun"/i,
|
|
260
215
|
errorType: "BUILD ERROR",
|
|
261
216
|
logSolution: () => {
|
|
262
|
-
logger.
|
|
217
|
+
logger.info(pc2.white("You're trying to build a project that uses Bun. ") + pc2.white("Please set the target option to ") + pc2.cyan("`bun`") + pc2.white(`.
|
|
263
218
|
`) + pc2.white("Example: ") + pc2.green("`bunup --target bun`") + pc2.white(" or in config: ") + pc2.green("{ target: 'bun' }"));
|
|
264
219
|
}
|
|
265
220
|
}
|
|
@@ -307,7 +262,7 @@ import path, { normalize } from "path";
|
|
|
307
262
|
function ensureArray(value) {
|
|
308
263
|
return Array.isArray(value) ? value : [value];
|
|
309
264
|
}
|
|
310
|
-
function
|
|
265
|
+
function getDefaultOutputExtension(format, packageType) {
|
|
311
266
|
switch (format) {
|
|
312
267
|
case "esm":
|
|
313
268
|
return isModulePackage(packageType) ? ".js" : ".mjs";
|
|
@@ -317,15 +272,15 @@ function getDefaultJsOutputExtension(format, packageType) {
|
|
|
317
272
|
return ".global.js";
|
|
318
273
|
}
|
|
319
274
|
}
|
|
320
|
-
function
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
275
|
+
function getDefaultDtsExtention(format, packageType) {
|
|
276
|
+
switch (format) {
|
|
277
|
+
case "esm":
|
|
278
|
+
return isModulePackage(packageType) ? ".d.ts" : ".d.mts";
|
|
279
|
+
case "cjs":
|
|
280
|
+
return isModulePackage(packageType) ? ".d.cts" : ".d.ts";
|
|
281
|
+
case "iife":
|
|
282
|
+
return ".global.d.ts";
|
|
283
|
+
}
|
|
329
284
|
}
|
|
330
285
|
function isModulePackage(packageType) {
|
|
331
286
|
return packageType === "module";
|
|
@@ -409,4 +364,4 @@ async function getFilesFromGlobs(patterns, cwd) {
|
|
|
409
364
|
return Array.from(includedFiles);
|
|
410
365
|
}
|
|
411
366
|
|
|
412
|
-
export { __toESM, __require, setSilent, logTable, logger, BunupBuildError,
|
|
367
|
+
export { __toESM, __require, setSilent, logTable, logger, BunupBuildError, BunupCLIError, BunupWatchError, BunupPluginError, parseErrorMessage, handleError, handleErrorAndExit, ensureArray, getDefaultOutputExtension, getDefaultDtsExtention, formatTime, getPackageDeps, formatFileSize, getShortFilePath, cleanOutDir, cleanPath, isDirectoryPath, pathExistsSync, formatListWithAnd, getFilesFromGlobs };
|
|
@@ -4,27 +4,28 @@ import {
|
|
|
4
4
|
report,
|
|
5
5
|
runPluginBuildDoneHooks,
|
|
6
6
|
runPluginBuildStartHooks
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-w13gdbvp.js";
|
|
8
8
|
import {
|
|
9
9
|
loadPackageJson
|
|
10
10
|
} from "./chunk-gh7z7s46.js";
|
|
11
11
|
import {
|
|
12
12
|
BunupBuildError,
|
|
13
|
-
BunupDTSBuildError,
|
|
14
13
|
cleanOutDir,
|
|
15
14
|
cleanPath,
|
|
16
15
|
ensureArray,
|
|
17
|
-
|
|
16
|
+
getDefaultDtsExtention,
|
|
17
|
+
getDefaultOutputExtension,
|
|
18
18
|
getFilesFromGlobs,
|
|
19
19
|
getPackageDeps,
|
|
20
20
|
getShortFilePath,
|
|
21
21
|
logger,
|
|
22
22
|
setSilent
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-ka4kbkdd.js";
|
|
24
24
|
|
|
25
25
|
// src/build.ts
|
|
26
26
|
import path from "path";
|
|
27
|
-
import {
|
|
27
|
+
import { generateDts, logIsolatedDeclarationErrors } from "bun-dts";
|
|
28
|
+
import pc from "picocolors";
|
|
28
29
|
|
|
29
30
|
// src/plugins/internal/use-client.ts
|
|
30
31
|
function useClient() {
|
|
@@ -103,17 +104,13 @@ function getResolvedDefine(define, env) {
|
|
|
103
104
|
function getResolvedSplitting(splitting, format) {
|
|
104
105
|
return splitting === undefined ? format === "esm" : splitting;
|
|
105
106
|
}
|
|
107
|
+
function getResolvedDtsSplitting(splitting) {
|
|
108
|
+
return splitting ?? true;
|
|
109
|
+
}
|
|
106
110
|
var DEFAULT_ENTRY_NAMING = "[dir]/[name].[ext]";
|
|
107
|
-
function getResolvedNaming(
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
if (typeof resolvedNaming === "string") {
|
|
111
|
-
return replaceExt(resolvedNaming);
|
|
112
|
-
}
|
|
113
|
-
return {
|
|
114
|
-
...resolvedNaming,
|
|
115
|
-
entry: replaceExt(resolvedNaming.entry)
|
|
116
|
-
};
|
|
111
|
+
function getResolvedNaming(fmt, packageType) {
|
|
112
|
+
const replaceExt = (pattern) => pattern.replace(".[ext]", getDefaultOutputExtension(fmt, packageType));
|
|
113
|
+
return replaceExt(DEFAULT_ENTRY_NAMING);
|
|
117
114
|
}
|
|
118
115
|
function getResolvedEnv(env) {
|
|
119
116
|
return typeof env === "string" ? env : undefined;
|
|
@@ -167,7 +164,7 @@ async function build(partialOptions, rootDir = process.cwd()) {
|
|
|
167
164
|
setSilent(options.silent);
|
|
168
165
|
const packageJson = await loadPackageJson(rootDir);
|
|
169
166
|
if (packageJson.data && packageJson.path) {
|
|
170
|
-
logger.
|
|
167
|
+
logger.info(`Using ${getShortFilePath(packageJson.path, 2)}`, {
|
|
171
168
|
muted: true,
|
|
172
169
|
identifier: options.name,
|
|
173
170
|
once: `${packageJson.path}:${options.name}`
|
|
@@ -180,43 +177,6 @@ async function build(partialOptions, rootDir = process.cwd()) {
|
|
|
180
177
|
externalOptionPlugin(options, packageJson.data),
|
|
181
178
|
...filterBunupBunPlugins(options.plugins).map((p) => p.plugin)
|
|
182
179
|
];
|
|
183
|
-
let hasBuiltAnyFormat = false;
|
|
184
|
-
if (options.dts) {
|
|
185
|
-
const { resolve, entry, splitting } = typeof options.dts === "object" ? options.dts : {};
|
|
186
|
-
let entrypoints2;
|
|
187
|
-
if (entry) {
|
|
188
|
-
entrypoints2 = await getFilesFromGlobs(ensureArray(entry), rootDir);
|
|
189
|
-
}
|
|
190
|
-
if (Array.isArray(entrypoints2) && !entrypoints2.length) {
|
|
191
|
-
throw new BunupDTSBuildError("The dts entrypoints you provided do not exist. Please make sure the entrypoints point to valid files.");
|
|
192
|
-
}
|
|
193
|
-
plugins.push(dts({
|
|
194
|
-
resolve,
|
|
195
|
-
preferredTsConfigPath: options.preferredTsconfigPath,
|
|
196
|
-
entry: entrypoints2,
|
|
197
|
-
cwd: rootDir,
|
|
198
|
-
splitting,
|
|
199
|
-
silent: () => !hasBuiltAnyFormat,
|
|
200
|
-
onDeclarationsGenerated({ result, buildConfig }) {
|
|
201
|
-
for (const file of result.files) {
|
|
202
|
-
logger.progress("DTS", `${options.outDir}/${file.outputPath}`, {
|
|
203
|
-
identifier: options.name
|
|
204
|
-
});
|
|
205
|
-
const fullPath = path.join(rootDir, options.outDir, file.outputPath);
|
|
206
|
-
if (buildConfig.format) {
|
|
207
|
-
buildOutput.files.push({
|
|
208
|
-
fullPath,
|
|
209
|
-
relativePathToRootDir: getRelativePathToRootDir(fullPath, rootDir),
|
|
210
|
-
relativePathToOutputDir: file.outputPath,
|
|
211
|
-
dts: true,
|
|
212
|
-
format: buildConfig.format,
|
|
213
|
-
kind: file.kind
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}));
|
|
219
|
-
}
|
|
220
180
|
const entrypoints = await getFilesFromGlobs(ensureArray(options.entry), rootDir);
|
|
221
181
|
if (!entrypoints.length) {
|
|
222
182
|
throw new BunupBuildError("The entrypoints you provided do not exist. Please make sure the entrypoints point to valid files.");
|
|
@@ -225,7 +185,7 @@ async function build(partialOptions, rootDir = process.cwd()) {
|
|
|
225
185
|
const result = await Bun.build({
|
|
226
186
|
entrypoints: entrypoints.map((file) => `${rootDir}/${file}`),
|
|
227
187
|
format: fmt,
|
|
228
|
-
naming: getResolvedNaming(
|
|
188
|
+
naming: getResolvedNaming(fmt, packageType),
|
|
229
189
|
splitting: getResolvedSplitting(options.splitting, fmt),
|
|
230
190
|
bytecode: getResolvedBytecode(options.bytecode, fmt),
|
|
231
191
|
define: getResolvedDefine(options.define, options.env),
|
|
@@ -239,10 +199,9 @@ async function build(partialOptions, rootDir = process.cwd()) {
|
|
|
239
199
|
footer: options.footer,
|
|
240
200
|
publicPath: options.publicPath,
|
|
241
201
|
env: getResolvedEnv(options.env),
|
|
242
|
-
|
|
243
|
-
|
|
202
|
+
throw: false,
|
|
203
|
+
plugins
|
|
244
204
|
});
|
|
245
|
-
hasBuiltAnyFormat = true;
|
|
246
205
|
for (const log of result.logs) {
|
|
247
206
|
if (log.level === "error") {
|
|
248
207
|
throw new BunupBuildError(log.message);
|
|
@@ -254,15 +213,16 @@ async function build(partialOptions, rootDir = process.cwd()) {
|
|
|
254
213
|
}
|
|
255
214
|
for (const file of result.outputs) {
|
|
256
215
|
const relativePathToRootDir = getRelativePathToRootDir(file.path, rootDir);
|
|
216
|
+
const relativePathToOutputDir = getRelativePathToOutputDir(relativePathToRootDir, options.outDir);
|
|
257
217
|
if (file.kind === "entry-point") {
|
|
258
|
-
logger.
|
|
218
|
+
logger.success(`${pc.dim(options.outDir)}/${relativePathToOutputDir}`, {
|
|
259
219
|
identifier: options.name
|
|
260
220
|
});
|
|
261
221
|
}
|
|
262
222
|
buildOutput.files.push({
|
|
263
223
|
fullPath: file.path,
|
|
264
224
|
relativePathToRootDir,
|
|
265
|
-
relativePathToOutputDir
|
|
225
|
+
relativePathToOutputDir,
|
|
266
226
|
dts: false,
|
|
267
227
|
format: fmt,
|
|
268
228
|
kind: file.kind
|
|
@@ -270,6 +230,40 @@ async function build(partialOptions, rootDir = process.cwd()) {
|
|
|
270
230
|
}
|
|
271
231
|
});
|
|
272
232
|
await Promise.all(buildPromises);
|
|
233
|
+
if (options.dts) {
|
|
234
|
+
const { entry, splitting, ...dtsOptions } = typeof options.dts === "object" ? options.dts : {};
|
|
235
|
+
const dtsResult = await generateDts(ensureArray(entry ?? entrypoints), {
|
|
236
|
+
cwd: rootDir,
|
|
237
|
+
preferredTsConfigPath: options.preferredTsconfigPath,
|
|
238
|
+
splitting: getResolvedDtsSplitting(splitting),
|
|
239
|
+
...dtsOptions
|
|
240
|
+
});
|
|
241
|
+
if (dtsResult.errors.length) {
|
|
242
|
+
logIsolatedDeclarationErrors(dtsResult.errors, {
|
|
243
|
+
shouldExit: true
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
for (const fmt of options.format) {
|
|
247
|
+
for (const file of dtsResult.files) {
|
|
248
|
+
const dtsExtension = getDefaultDtsExtention(fmt, packageType);
|
|
249
|
+
const relativePathToOutputDir = cleanPath(`${file.pathInfo.outputPathWithoutExtension}${dtsExtension}`);
|
|
250
|
+
const relativePathToRootDir = cleanPath(`${options.outDir}/${relativePathToOutputDir}`);
|
|
251
|
+
logger.success(`${pc.dim(options.outDir)}/${relativePathToOutputDir}`, {
|
|
252
|
+
identifier: options.name
|
|
253
|
+
});
|
|
254
|
+
const fullPath = path.join(rootDir, relativePathToRootDir);
|
|
255
|
+
await Bun.write(fullPath, file.dts);
|
|
256
|
+
buildOutput.files.push({
|
|
257
|
+
fullPath,
|
|
258
|
+
relativePathToRootDir,
|
|
259
|
+
relativePathToOutputDir,
|
|
260
|
+
dts: true,
|
|
261
|
+
format: fmt,
|
|
262
|
+
kind: file.kind
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
273
267
|
await runPluginBuildDoneHooks(bunupPlugins, options, buildOutput, {
|
|
274
268
|
packageJson,
|
|
275
269
|
rootDir
|
|
@@ -4,9 +4,8 @@ import {
|
|
|
4
4
|
formatFileSize,
|
|
5
5
|
isDirectoryPath,
|
|
6
6
|
logTable,
|
|
7
|
-
logger
|
|
8
|
-
|
|
9
|
-
} from "./chunk-8z361mhm.js";
|
|
7
|
+
logger
|
|
8
|
+
} from "./chunk-ka4kbkdd.js";
|
|
10
9
|
|
|
11
10
|
// src/constants/re.ts
|
|
12
11
|
var JS_RE = /\.(js|jsx|cjs|mjs)$/;
|
|
@@ -72,6 +71,7 @@ const importMetaUrl = pathToFileURL(__filename).href;
|
|
|
72
71
|
}
|
|
73
72
|
|
|
74
73
|
// src/plugins/built-in/productivity/exports.ts
|
|
74
|
+
import path from "path";
|
|
75
75
|
function exports(options = {}) {
|
|
76
76
|
return {
|
|
77
77
|
type: "bunup",
|
|
@@ -123,7 +123,6 @@ function exports(options = {}) {
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
await Bun.write(meta.packageJson.path, JSON.stringify(newPackageJson, null, 2));
|
|
126
|
-
logger.cli("Updated package.json with exports");
|
|
127
126
|
} catch {
|
|
128
127
|
logger.error("Failed to update package.json");
|
|
129
128
|
}
|
|
@@ -166,9 +165,19 @@ function exportFieldToEntryPoint(exportField) {
|
|
|
166
165
|
function formatToExportField(format, dts) {
|
|
167
166
|
return dts ? "types" : format === "esm" ? "import" : "require";
|
|
168
167
|
}
|
|
168
|
+
function removeExtension(filePath) {
|
|
169
|
+
const basename = path.basename(filePath);
|
|
170
|
+
const firstDotIndex = basename.indexOf(".");
|
|
171
|
+
if (firstDotIndex === -1) {
|
|
172
|
+
return filePath;
|
|
173
|
+
}
|
|
174
|
+
const nameWithoutExtensions = basename.slice(0, firstDotIndex);
|
|
175
|
+
const directory = path.dirname(filePath);
|
|
176
|
+
return directory === "." ? nameWithoutExtensions : path.join(directory, nameWithoutExtensions);
|
|
177
|
+
}
|
|
169
178
|
|
|
170
179
|
// src/plugins/built-in/css/inject-styles.ts
|
|
171
|
-
import
|
|
180
|
+
import path2 from "path";
|
|
172
181
|
|
|
173
182
|
// src/plugins/utils.ts
|
|
174
183
|
import pc from "picocolors";
|
|
@@ -250,7 +259,7 @@ function injectStyles(options) {
|
|
|
250
259
|
const source = await Bun.file(args.path).text();
|
|
251
260
|
const { code, warnings } = lightningcss.transform({
|
|
252
261
|
...transformOptions,
|
|
253
|
-
filename:
|
|
262
|
+
filename: path2.basename(args.path),
|
|
254
263
|
code: Buffer.from(source),
|
|
255
264
|
minify: transformOptions.minify ?? (build.config.minify === true || typeof build.config.minify === "object" && build.config.minify.whitespace)
|
|
256
265
|
});
|