bunup 0.11.13 → 0.11.14
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/cli/index.js +3 -11
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/plugins.d.ts +12 -4
- package/dist/plugins.js +108 -82
- package/dist/shared/{bunup-knmb0tyv.js → chunk-6rymy2z1.js} +4 -4
- package/dist/shared/{bunup-rvdh0cgz.js → chunk-ca1dh9de.js} +3 -7
- package/dist/shared/{bunup-2hbptr8j.d.ts → chunk-gzzvjwk2.d.ts} +5 -32
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
build,
|
|
5
5
|
createBuildOptions,
|
|
6
6
|
processLoadedConfigs
|
|
7
|
-
} from "../shared/
|
|
7
|
+
} from "../shared/chunk-ca1dh9de.js";
|
|
8
8
|
import {
|
|
9
9
|
BunupCLIError,
|
|
10
10
|
BunupWatchError,
|
|
@@ -18,13 +18,13 @@ import {
|
|
|
18
18
|
logger,
|
|
19
19
|
parseErrorMessage,
|
|
20
20
|
setSilent
|
|
21
|
-
} from "../shared/
|
|
21
|
+
} from "../shared/chunk-6rymy2z1.js";
|
|
22
22
|
|
|
23
23
|
// src/cli/index.ts
|
|
24
24
|
import { loadConfig } from "coffi";
|
|
25
25
|
import pc3 from "picocolors";
|
|
26
26
|
// package.json
|
|
27
|
-
var version = "0.11.
|
|
27
|
+
var version = "0.11.14";
|
|
28
28
|
|
|
29
29
|
// src/watch.ts
|
|
30
30
|
import path from "path";
|
|
@@ -285,14 +285,6 @@ var OPTION_DEFINITIONS = {
|
|
|
285
285
|
type: "string",
|
|
286
286
|
category: "development"
|
|
287
287
|
},
|
|
288
|
-
bytecode: {
|
|
289
|
-
flags: ["bc", "bytecode"],
|
|
290
|
-
handler: handlers.boolean("bytecode"),
|
|
291
|
-
description: "Generate bytecode for the output (CJS only)",
|
|
292
|
-
type: "boolean",
|
|
293
|
-
default: "false",
|
|
294
|
-
category: "output"
|
|
295
|
-
},
|
|
296
288
|
silent: {
|
|
297
289
|
flags: ["silent"],
|
|
298
290
|
handler: handlers.boolean("silent"),
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Arrayable, BuildOptions, DefineConfigItem, DefineWorkspaceItem,
|
|
1
|
+
import { Arrayable, BuildContext, BuildMeta, BuildOptions, BuildOutput, BuildOutputFile, BunupPlugin, DefineConfigItem, DefineWorkspaceItem, WithOptional } from "./shared/chunk-gzzvjwk2";
|
|
2
2
|
declare function build(partialOptions: Partial<BuildOptions>, rootDir?: string): Promise<void>;
|
|
3
3
|
declare function defineConfig(options: Arrayable<DefineConfigItem>): Arrayable<DefineConfigItem>;
|
|
4
4
|
declare function defineWorkspace(options: WithOptional<DefineWorkspaceItem, "config">[], sharedOptions?: Partial<DefineConfigItem>): DefineWorkspaceItem[];
|
|
5
|
-
export { defineWorkspace, defineConfig, build,
|
|
5
|
+
export { defineWorkspace, defineConfig, build, DefineWorkspaceItem, DefineConfigItem, BunupPlugin, BuildOutputFile, BuildOutput, BuildOptions, BuildMeta, BuildContext };
|
package/dist/index.js
CHANGED
package/dist/plugins.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BuildContext, BunupPlugin, MaybePromise
|
|
1
|
+
import { BuildContext, BunupPlugin, MaybePromise } from "./shared/chunk-gzzvjwk2";
|
|
2
2
|
/**
|
|
3
3
|
* A plugin that copies files and directories to the output directory.
|
|
4
4
|
*
|
|
@@ -22,6 +22,12 @@ interface ExportsPluginOptions {
|
|
|
22
22
|
* @see https://bunup.dev/docs/plugins/exports#exclude
|
|
23
23
|
*/
|
|
24
24
|
exclude?: Exclude;
|
|
25
|
+
/**
|
|
26
|
+
* Whether to exclude CSS files from being added to the exports field
|
|
27
|
+
*
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
excludeCss?: boolean;
|
|
25
31
|
}
|
|
26
32
|
/**
|
|
27
33
|
* A plugin that generates the exports field in the package.json file automatically.
|
|
@@ -29,6 +35,7 @@ interface ExportsPluginOptions {
|
|
|
29
35
|
* @see https://bunup.dev/docs/plugins/exports
|
|
30
36
|
*/
|
|
31
37
|
declare function exports(options?: ExportsPluginOptions): BunupPlugin;
|
|
38
|
+
import { BunPlugin } from "bun";
|
|
32
39
|
type InjectStylesPluginOptions = Pick<import("lightningcss").TransformOptions<import("lightningcss").CustomAtRules>, "targets" | "nonStandard" | "pseudoClasses" | "unusedSymbols" | "errorRecovery" | "visitor" | "customAtRules" | "include" | "exclude" | "drafts"> & {
|
|
33
40
|
inject?: (css: string, filePath: string) => MaybePromise<string>
|
|
34
41
|
/** Whether to minify the CSS.
|
|
@@ -41,13 +48,14 @@ type InjectStylesPluginOptions = Pick<import("lightningcss").TransformOptions<im
|
|
|
41
48
|
*
|
|
42
49
|
* @see https://bunup.dev/docs/plugins/inject-styles
|
|
43
50
|
*/
|
|
44
|
-
declare function injectStyles(options?: InjectStylesPluginOptions):
|
|
51
|
+
declare function injectStyles(options?: InjectStylesPluginOptions): BunPlugin;
|
|
52
|
+
import { BunPlugin as BunPlugin2 } from "bun";
|
|
45
53
|
/**
|
|
46
54
|
* A plugin that provides shims for Node.js globals and ESM/CJS interoperability.
|
|
47
55
|
*
|
|
48
56
|
* @see https://bunup.dev/docs/plugins/shims
|
|
49
57
|
*/
|
|
50
|
-
declare function shims():
|
|
58
|
+
declare function shims(): BunPlugin2;
|
|
51
59
|
interface UnusedOptions {
|
|
52
60
|
/**
|
|
53
61
|
* The level of reporting for unused dependencies
|
|
@@ -65,5 +73,5 @@ interface UnusedOptions {
|
|
|
65
73
|
*
|
|
66
74
|
* @see https://bunup.dev/docs/plugins/unused
|
|
67
75
|
*/
|
|
68
|
-
declare function unused(options?: UnusedOptions):
|
|
76
|
+
declare function unused(options?: UnusedOptions): BunupPlugin;
|
|
69
77
|
export { unused, shims, injectStyles, exports, copy };
|
package/dist/plugins.js
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
getPackageForPlugin,
|
|
10
10
|
isDirectoryPath,
|
|
11
11
|
logger
|
|
12
|
-
} from "./shared/
|
|
12
|
+
} from "./shared/chunk-6rymy2z1.js";
|
|
13
13
|
|
|
14
14
|
// src/plugins/built-in/copy.ts
|
|
15
15
|
import { basename, join } from "path";
|
|
@@ -53,7 +53,7 @@ async function processPackageJsonExports(ctx, options) {
|
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
55
|
try {
|
|
56
|
-
const { exportsField, entryPoints } = generateExportsFields(output.files, options.exclude, ctx);
|
|
56
|
+
const { exportsField, entryPoints } = generateExportsFields(output.files, options.exclude, options.excludeCss, ctx);
|
|
57
57
|
const updatedFiles = createUpdatedFilesArray(meta.packageJson.data, buildOptions.outDir);
|
|
58
58
|
const mergedExports = mergeCustomExportsWithGenerated(exportsField, options.customExports, ctx);
|
|
59
59
|
const newPackageJson = createUpdatedPackageJson(meta.packageJson.data, entryPoints, mergedExports, updatedFiles);
|
|
@@ -65,18 +65,26 @@ async function processPackageJsonExports(ctx, options) {
|
|
|
65
65
|
logger.error("Failed to update package.json");
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
function generateExportsFields(files, exclude, ctx) {
|
|
68
|
+
function generateExportsFields(files, exclude, excludeCss, ctx) {
|
|
69
69
|
const filteredFiles = filterFiles(files, exclude, ctx);
|
|
70
|
-
const { filesByExportKey, allDtsFiles } = groupFilesByExportKey(filteredFiles);
|
|
70
|
+
const { filesByExportKey, allDtsFiles, cssFiles } = groupFilesByExportKey(filteredFiles);
|
|
71
71
|
const exportsField = createExportEntries(filesByExportKey);
|
|
72
|
+
if (!excludeCss) {
|
|
73
|
+
addCssToExports(exportsField, cssFiles);
|
|
74
|
+
}
|
|
72
75
|
const entryPoints = extractEntryPoints(exportsField, allDtsFiles);
|
|
73
76
|
return { exportsField, entryPoints };
|
|
74
77
|
}
|
|
75
78
|
function groupFilesByExportKey(files) {
|
|
76
79
|
const filesByExportKey = new Map;
|
|
77
80
|
const allDtsFiles = new Map;
|
|
81
|
+
const cssFiles = [];
|
|
78
82
|
for (const file of files) {
|
|
79
83
|
const exportKey = getExportKey(cleanPath(file.pathRelativeToOutdir));
|
|
84
|
+
if (CSS_RE.test(file.fullPath)) {
|
|
85
|
+
cssFiles.push(file);
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
80
88
|
const format = file.format === "esm" ? "import" : "require";
|
|
81
89
|
if (!filesByExportKey.has(exportKey)) {
|
|
82
90
|
filesByExportKey.set(exportKey, new Map);
|
|
@@ -99,7 +107,7 @@ function groupFilesByExportKey(files) {
|
|
|
99
107
|
}
|
|
100
108
|
}
|
|
101
109
|
}
|
|
102
|
-
return { filesByExportKey, allDtsFiles };
|
|
110
|
+
return { filesByExportKey, allDtsFiles, cssFiles };
|
|
103
111
|
}
|
|
104
112
|
function createExportEntries(filesByExportKey) {
|
|
105
113
|
const exportsField = {};
|
|
@@ -136,7 +144,7 @@ function createExportEntries(filesByExportKey) {
|
|
|
136
144
|
function extractEntryPoints(exportsField, allDtsFiles) {
|
|
137
145
|
const entryPoints = {};
|
|
138
146
|
const dotExport = exportsField["."];
|
|
139
|
-
if (!dotExport) {
|
|
147
|
+
if (!dotExport || typeof dotExport === "string") {
|
|
140
148
|
return entryPoints;
|
|
141
149
|
}
|
|
142
150
|
for (const [field, value] of Object.entries(dotExport)) {
|
|
@@ -226,13 +234,18 @@ function createUpdatedPackageJson(originalData, entryPoints, exports2, files) {
|
|
|
226
234
|
return newPackageJson;
|
|
227
235
|
}
|
|
228
236
|
function filterFiles(files, exclude, ctx) {
|
|
229
|
-
return files.filter((file) => JS_DTS_RE.test(file.fullPath) && file.kind === "entry-point"
|
|
237
|
+
return files.filter((file) => (JS_DTS_RE.test(file.fullPath) || CSS_RE.test(file.fullPath)) && (file.kind === "entry-point" || file.kind === "asset") && (file.format === "esm" || file.format === "cjs" || CSS_RE.test(file.fullPath)) && (!file.entrypoint || !isExcluded(file.entrypoint, exclude, ctx)));
|
|
230
238
|
}
|
|
239
|
+
var DEFAULT_CLI_EXCLUSIONS = [
|
|
240
|
+
"cli.ts",
|
|
241
|
+
"cli/index.ts",
|
|
242
|
+
"src/cli.ts",
|
|
243
|
+
"src/cli/index.ts"
|
|
244
|
+
];
|
|
231
245
|
function isExcluded(entrypoint, exclude, ctx) {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
return patterns?.some((pattern) => new Bun.Glob(pattern).match(entrypoint)) ?? false;
|
|
246
|
+
const userPatterns = typeof exclude === "function" ? exclude(ctx) : exclude;
|
|
247
|
+
const allPatterns = [...DEFAULT_CLI_EXCLUSIONS, ...userPatterns ?? []];
|
|
248
|
+
return allPatterns.some((pattern) => new Bun.Glob(pattern).match(entrypoint));
|
|
236
249
|
}
|
|
237
250
|
function getExportKey(pathRelativeToOutdir) {
|
|
238
251
|
const pathSegments = cleanPath(removeExtension(pathRelativeToOutdir)).split("/");
|
|
@@ -251,6 +264,27 @@ function removeExtension(filePath) {
|
|
|
251
264
|
const directory = path.dirname(filePath);
|
|
252
265
|
return directory === "." ? nameWithoutExtensions : path.join(directory, nameWithoutExtensions);
|
|
253
266
|
}
|
|
267
|
+
function addCssToExports(exportsField, cssFiles) {
|
|
268
|
+
if (cssFiles.length === 0)
|
|
269
|
+
return;
|
|
270
|
+
for (const cssFile of cssFiles) {
|
|
271
|
+
const exportKey = getCssExportKey(cleanPath(cssFile.pathRelativeToOutdir));
|
|
272
|
+
exportsField[exportKey] = `./${cleanPath(cssFile.pathRelativeToRootDir)}`;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
function getCssExportKey(pathRelativeToOutdir) {
|
|
276
|
+
const pathSegments = cleanPath(removeExtension(pathRelativeToOutdir)).split("/");
|
|
277
|
+
const fileName = pathSegments[pathSegments.length - 1];
|
|
278
|
+
if (fileName === "index") {
|
|
279
|
+
if (pathSegments.length === 1) {
|
|
280
|
+
return "./styles.css";
|
|
281
|
+
} else {
|
|
282
|
+
return `./${pathSegments.slice(0, -1).join("/")}.css`;
|
|
283
|
+
}
|
|
284
|
+
} else {
|
|
285
|
+
return `./${pathSegments.join("/")}.css`;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
254
288
|
function exportFieldToEntryPoint(exportField) {
|
|
255
289
|
switch (exportField) {
|
|
256
290
|
case "types":
|
|
@@ -266,21 +300,18 @@ import path2 from "path";
|
|
|
266
300
|
function injectStyles(options) {
|
|
267
301
|
const { inject, ...transformOptions } = options ?? {};
|
|
268
302
|
return {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
build.onLoad({ filter: /^__inject-style$/, namespace: "__inject-style" }, () => {
|
|
282
|
-
return {
|
|
283
|
-
contents: `
|
|
303
|
+
name: "bunup:inject-styles",
|
|
304
|
+
async setup(build) {
|
|
305
|
+
const lightningcss = await getPackageForPlugin("lightningcss", "inject-styles");
|
|
306
|
+
build.onResolve({ filter: /^__inject-style$/ }, () => {
|
|
307
|
+
return {
|
|
308
|
+
path: "__inject-style",
|
|
309
|
+
namespace: "__inject-style"
|
|
310
|
+
};
|
|
311
|
+
});
|
|
312
|
+
build.onLoad({ filter: /^__inject-style$/, namespace: "__inject-style" }, () => {
|
|
313
|
+
return {
|
|
314
|
+
contents: `
|
|
284
315
|
export default function injectStyle(css) {
|
|
285
316
|
if (!css || typeof document === 'undefined') return
|
|
286
317
|
|
|
@@ -295,82 +326,77 @@ function injectStyles(options) {
|
|
|
295
326
|
}
|
|
296
327
|
}
|
|
297
328
|
`,
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
});
|
|
309
|
-
for (const warning of warnings) {
|
|
310
|
-
logger.warn(warning.message);
|
|
311
|
-
}
|
|
312
|
-
const stringifiedCode = JSON.stringify(code.toString());
|
|
313
|
-
const js = inject ? await inject(stringifiedCode, args.path) : `import injectStyle from '__inject-style';injectStyle(${stringifiedCode})`;
|
|
314
|
-
return {
|
|
315
|
-
contents: js,
|
|
316
|
-
loader: "js"
|
|
317
|
-
};
|
|
329
|
+
loader: "js"
|
|
330
|
+
};
|
|
331
|
+
});
|
|
332
|
+
build.onLoad({ filter: CSS_RE }, async (args) => {
|
|
333
|
+
const source = await Bun.file(args.path).text();
|
|
334
|
+
const { code, warnings } = lightningcss.transform({
|
|
335
|
+
...transformOptions,
|
|
336
|
+
filename: path2.basename(args.path),
|
|
337
|
+
code: Buffer.from(source),
|
|
338
|
+
minify: transformOptions.minify ?? true
|
|
318
339
|
});
|
|
319
|
-
|
|
340
|
+
for (const warning of warnings) {
|
|
341
|
+
logger.warn(warning.message);
|
|
342
|
+
}
|
|
343
|
+
const stringifiedCode = JSON.stringify(code.toString());
|
|
344
|
+
const js = inject ? await inject(stringifiedCode, args.path) : `import injectStyle from '__inject-style';injectStyle(${stringifiedCode})`;
|
|
345
|
+
return {
|
|
346
|
+
contents: js,
|
|
347
|
+
loader: "js"
|
|
348
|
+
};
|
|
349
|
+
});
|
|
320
350
|
}
|
|
321
351
|
};
|
|
322
352
|
}
|
|
323
353
|
// src/plugins/built-in/shims.ts
|
|
324
354
|
function shims() {
|
|
325
355
|
return {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
356
|
+
name: "bunup:shims",
|
|
357
|
+
setup(build) {
|
|
358
|
+
const isNodeCompatibleTarget = build.config.target === "node" || build.config.target === "bun";
|
|
359
|
+
const isEsm = build.config.format === "esm";
|
|
360
|
+
const isCjs = build.config.format === "cjs";
|
|
361
|
+
if (!isNodeCompatibleTarget || !isEsm && !isCjs) {
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
build.config.define = {
|
|
365
|
+
...build.config.define,
|
|
366
|
+
...isCjs && {
|
|
367
|
+
"import.meta.url": "importMetaUrl"
|
|
336
368
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
build.onLoad({ filter: JS_TS_RE }, async ({ path: path3 }) => {
|
|
344
|
-
const content = await Bun.file(path3).text();
|
|
345
|
-
let shimCode = "";
|
|
346
|
-
if (isEsm && (/\b__dirname\b/.test(content) || /\b__filename\b/.test(content))) {
|
|
347
|
-
shimCode = `import { fileURLToPath } from 'url';
|
|
369
|
+
};
|
|
370
|
+
build.onLoad({ filter: JS_TS_RE }, async ({ path: path3 }) => {
|
|
371
|
+
const content = await Bun.file(path3).text();
|
|
372
|
+
let shimCode = "";
|
|
373
|
+
if (isEsm && (/\b__dirname\b/.test(content) || /\b__filename\b/.test(content))) {
|
|
374
|
+
shimCode = `import { fileURLToPath } from 'url';
|
|
348
375
|
import { dirname } from 'path';
|
|
349
376
|
|
|
350
377
|
const __filename = fileURLToPath(import.meta.url);
|
|
351
378
|
const __dirname = dirname(__filename);
|
|
352
379
|
|
|
353
380
|
`;
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
381
|
+
}
|
|
382
|
+
if (isCjs && /\bimport\.meta\.url\b/.test(content)) {
|
|
383
|
+
shimCode = `import { pathToFileURL } from 'url';
|
|
357
384
|
|
|
358
385
|
const importMetaUrl = pathToFileURL(__filename).href;
|
|
359
386
|
|
|
360
387
|
`;
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
388
|
+
}
|
|
389
|
+
if (!shimCode)
|
|
390
|
+
return;
|
|
391
|
+
const lines = content.split(`
|
|
365
392
|
`);
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
393
|
+
const firstLine = lines[0];
|
|
394
|
+
const restLines = lines.slice(1);
|
|
395
|
+
return {
|
|
396
|
+
contents: [firstLine, shimCode, ...restLines].join(`
|
|
370
397
|
`)
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
}
|
|
398
|
+
};
|
|
399
|
+
});
|
|
374
400
|
}
|
|
375
401
|
};
|
|
376
402
|
}
|
|
@@ -438,15 +438,15 @@ function replaceExtension(filePath, newExtension) {
|
|
|
438
438
|
|
|
439
439
|
// src/plugins/utils.ts
|
|
440
440
|
import pc3 from "picocolors";
|
|
441
|
-
function
|
|
441
|
+
function filterBunPlugins(plugins) {
|
|
442
442
|
if (!plugins)
|
|
443
443
|
return [];
|
|
444
|
-
return plugins.filter((p) =>
|
|
444
|
+
return plugins.filter((p) => ("setup" in p));
|
|
445
445
|
}
|
|
446
446
|
function filterBunupPlugins(plugins) {
|
|
447
447
|
if (!plugins)
|
|
448
448
|
return [];
|
|
449
|
-
return plugins.filter((p) =>
|
|
449
|
+
return plugins.filter((p) => ("hooks" in p));
|
|
450
450
|
}
|
|
451
451
|
async function runPluginBuildStartHooks(bunupPlugins, options) {
|
|
452
452
|
if (!bunupPlugins)
|
|
@@ -476,4 +476,4 @@ async function getPackageForPlugin(name, pluginName) {
|
|
|
476
476
|
return pkg;
|
|
477
477
|
}
|
|
478
478
|
|
|
479
|
-
export { __toESM, __require, silent, setSilent, logTable, logTime, logger, BunupBuildError, BunupDTSBuildError, BunupCLIError, BunupWatchError, parseErrorMessage, handleError, handleErrorAndExit, JS_TS_RE, JS_DTS_RE, CSS_RE, ensureArray, getDefaultJsOutputExtension, getDefaultDtsOutputExtention, getPackageDeps, formatFileSize, getShortFilePath, cleanOutDir, cleanPath, isDirectoryPath, formatListWithAnd, getFilesFromGlobs, isTypeScriptFile, isJavascriptFile, replaceExtension,
|
|
479
|
+
export { __toESM, __require, silent, setSilent, logTable, logTime, logger, BunupBuildError, BunupDTSBuildError, BunupCLIError, BunupWatchError, parseErrorMessage, handleError, handleErrorAndExit, JS_TS_RE, JS_DTS_RE, CSS_RE, ensureArray, getDefaultJsOutputExtension, getDefaultDtsOutputExtention, getPackageDeps, formatFileSize, getShortFilePath, cleanOutDir, cleanPath, isDirectoryPath, formatListWithAnd, getFilesFromGlobs, isTypeScriptFile, isJavascriptFile, replaceExtension, filterBunPlugins, filterBunupPlugins, runPluginBuildStartHooks, runPluginBuildDoneHooks, getPackageForPlugin };
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
cleanOutDir,
|
|
5
5
|
cleanPath,
|
|
6
6
|
ensureArray,
|
|
7
|
-
|
|
7
|
+
filterBunPlugins,
|
|
8
8
|
filterBunupPlugins,
|
|
9
9
|
formatFileSize,
|
|
10
10
|
getDefaultDtsOutputExtention,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
runPluginBuildStartHooks,
|
|
23
23
|
setSilent,
|
|
24
24
|
silent
|
|
25
|
-
} from "./
|
|
25
|
+
} from "./chunk-6rymy2z1.js";
|
|
26
26
|
|
|
27
27
|
// src/loaders.ts
|
|
28
28
|
import path from "path";
|
|
@@ -207,9 +207,6 @@ function getResolvedMinify(options) {
|
|
|
207
207
|
syntax: minifySyntax ?? defaultValue
|
|
208
208
|
};
|
|
209
209
|
}
|
|
210
|
-
function getResolvedBytecode(bytecode, format) {
|
|
211
|
-
return format === "cjs" ? bytecode : undefined;
|
|
212
|
-
}
|
|
213
210
|
function getResolvedSourcemap(sourcemap) {
|
|
214
211
|
if (sourcemap === true) {
|
|
215
212
|
return "inline";
|
|
@@ -304,7 +301,7 @@ async function build(partialOptions, rootDir = process.cwd()) {
|
|
|
304
301
|
const packageType = packageJson.data?.type;
|
|
305
302
|
const plugins = [
|
|
306
303
|
externalOptionPlugin(options, packageJson.data),
|
|
307
|
-
...
|
|
304
|
+
...filterBunPlugins(options.plugins)
|
|
308
305
|
];
|
|
309
306
|
const entrypoints = await getFilesFromGlobs(ensureArray(options.entry), rootDir);
|
|
310
307
|
if (!entrypoints.length) {
|
|
@@ -315,7 +312,6 @@ async function build(partialOptions, rootDir = process.cwd()) {
|
|
|
315
312
|
entrypoints: entrypoints.map((file) => `${rootDir}/${file}`),
|
|
316
313
|
format: fmt,
|
|
317
314
|
splitting: getResolvedSplitting(options.splitting, fmt),
|
|
318
|
-
bytecode: getResolvedBytecode(options.bytecode, fmt),
|
|
319
315
|
define: getResolvedDefine(options.define, options.env),
|
|
320
316
|
minify: getResolvedMinify(options),
|
|
321
317
|
target: options.target,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { GenerateDtsOptions } from "typeroll";
|
|
2
1
|
import { BunPlugin } from "bun";
|
|
2
|
+
import { GenerateDtsOptions } from "typeroll";
|
|
3
3
|
type PackageJson = {
|
|
4
4
|
/** The parsed content of the package.json file */
|
|
5
5
|
data: Record<string, any> | null
|
|
@@ -7,17 +7,6 @@ type PackageJson = {
|
|
|
7
7
|
path: string | null
|
|
8
8
|
};
|
|
9
9
|
/**
|
|
10
|
-
* Represents a Bun plugin that can be used with Bunup
|
|
11
|
-
*/
|
|
12
|
-
type BunupBunPlugin = {
|
|
13
|
-
/** Identifies this as a native Bun plugin */
|
|
14
|
-
type: "bun"
|
|
15
|
-
/** Optional name for the plugin */
|
|
16
|
-
name?: string
|
|
17
|
-
/** The actual Bun plugin implementation */
|
|
18
|
-
plugin: BunPlugin
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
10
|
* Represents the meta data of the build
|
|
22
11
|
*/
|
|
23
12
|
type BuildMeta = {
|
|
@@ -35,7 +24,7 @@ type BuildOutputFile = {
|
|
|
35
24
|
entrypoint: string | undefined
|
|
36
25
|
/** The kind of the file */
|
|
37
26
|
kind: "entry-point" | "chunk" | "asset" | "sourcemap" | "bytecode"
|
|
38
|
-
/**
|
|
27
|
+
/** Absolute path to the generated file */
|
|
39
28
|
fullPath: string
|
|
40
29
|
/** Path to the generated file relative to the root directory */
|
|
41
30
|
pathRelativeToRootDir: string
|
|
@@ -44,7 +33,7 @@ type BuildOutputFile = {
|
|
|
44
33
|
/** Whether the file is a dts file */
|
|
45
34
|
dts: boolean
|
|
46
35
|
/** The format of the output file */
|
|
47
|
-
format: Format
|
|
36
|
+
format: Format
|
|
48
37
|
};
|
|
49
38
|
/**
|
|
50
39
|
* Represents the output of a build operation
|
|
@@ -90,10 +79,6 @@ type BunupPlugin = {
|
|
|
90
79
|
/** The hooks implemented by this plugin */
|
|
91
80
|
hooks: BunupPluginHooks
|
|
92
81
|
};
|
|
93
|
-
/**
|
|
94
|
-
* Union type representing all supported plugin types
|
|
95
|
-
*/
|
|
96
|
-
type Plugin = BunupBunPlugin | BunupPlugin;
|
|
97
82
|
type Loader = "js" | "jsx" | "ts" | "tsx" | "json" | "toml" | "file" | "napi" | "wasm" | "text" | "css" | "html";
|
|
98
83
|
type Define = Record<string, string>;
|
|
99
84
|
type Sourcemap = "none" | "linked" | "inline" | "external" | "linked" | boolean;
|
|
@@ -333,18 +318,6 @@ interface BuildOptions {
|
|
|
333
318
|
*/
|
|
334
319
|
loader?: { [k in string] : Loader };
|
|
335
320
|
/**
|
|
336
|
-
* Generate bytecode for the output. This can dramatically improve cold start times, but will make the final output larger and slightly increase memory usage.
|
|
337
|
-
*
|
|
338
|
-
* Bytecode is currently only supported for CommonJS (format: "cjs").
|
|
339
|
-
*
|
|
340
|
-
* Must be target: "bun"
|
|
341
|
-
*
|
|
342
|
-
* @see https://bun.sh/docs/bundler#bytecode
|
|
343
|
-
*
|
|
344
|
-
* @default false
|
|
345
|
-
*/
|
|
346
|
-
bytecode?: boolean;
|
|
347
|
-
/**
|
|
348
321
|
* Disable logging during the build process. When set to true, no logs will be printed to the console.
|
|
349
322
|
*
|
|
350
323
|
* @default false
|
|
@@ -435,7 +408,7 @@ interface BuildOptions {
|
|
|
435
408
|
* }
|
|
436
409
|
* ]
|
|
437
410
|
*/
|
|
438
|
-
plugins?:
|
|
411
|
+
plugins?: (BunupPlugin | BunPlugin)[];
|
|
439
412
|
}
|
|
440
413
|
type MaybePromise<T> = Promise<T> | T;
|
|
441
414
|
type WithOptional<
|
|
@@ -449,4 +422,4 @@ type DefineWorkspaceItem = {
|
|
|
449
422
|
root: string
|
|
450
423
|
config: DefineConfigItem | DefineConfigItem[]
|
|
451
424
|
};
|
|
452
|
-
export { MaybePromise, WithOptional, Arrayable, DefineConfigItem, DefineWorkspaceItem, BuildContext, BunupPlugin,
|
|
425
|
+
export { MaybePromise, WithOptional, Arrayable, DefineConfigItem, DefineWorkspaceItem, BuildMeta, BuildOutputFile, BuildOutput, BuildContext, BunupPlugin, BuildOptions };
|