bunup 0.11.22 → 0.11.24
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 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/plugins.d.ts +8 -1
- package/dist/plugins.js +21 -6
- package/dist/shared/{bunup-jber4h9a.js → bunup-a55nf4gz.js} +23 -1
- package/dist/shared/{bunup-7rvhqvrm.d.ts → bunup-ff28zhd9.d.ts} +2 -7
- package/dist/shared/{bunup-6vfygtwp.js → bunup-rqk1dnq1.js} +1 -3
- package/package.json +3 -2
package/dist/cli/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
build,
|
|
5
5
|
createBuildOptions,
|
|
6
6
|
processLoadedConfigs
|
|
7
|
-
} from "../shared/bunup-
|
|
7
|
+
} from "../shared/bunup-rqk1dnq1.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/bunup-
|
|
21
|
+
} from "../shared/bunup-a55nf4gz.js";
|
|
22
22
|
|
|
23
23
|
// packages/bunup/src/cli/index.ts
|
|
24
24
|
import { loadConfig } from "coffi";
|
|
25
25
|
import pc3 from "picocolors";
|
|
26
26
|
// packages/bunup/package.json
|
|
27
|
-
var version = "0.11.
|
|
27
|
+
var version = "0.11.24";
|
|
28
28
|
|
|
29
29
|
// packages/bunup/src/watch.ts
|
|
30
30
|
import path from "path";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Arrayable, BuildContext, BuildMeta, BuildOptions, BuildOutput, BuildOutputFile, BunupPlugin, DefineConfigItem, DefineWorkspaceItem, WithOptional } from "./shared/bunup-
|
|
1
|
+
import { Arrayable, BuildContext, BuildMeta, BuildOptions, BuildOutput, BuildOutputFile, BunupPlugin, DefineConfigItem, DefineWorkspaceItem, WithOptional } from "./shared/bunup-ff28zhd9";
|
|
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[];
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
build
|
|
4
|
-
} from "./shared/bunup-
|
|
5
|
-
import"./shared/bunup-
|
|
4
|
+
} from "./shared/bunup-rqk1dnq1.js";
|
|
5
|
+
import"./shared/bunup-a55nf4gz.js";
|
|
6
6
|
// packages/bunup/src/define.ts
|
|
7
7
|
function defineConfig(options) {
|
|
8
8
|
return options;
|
package/dist/plugins.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BuildContext, BunupPlugin, MaybePromise } from "./shared/bunup-
|
|
1
|
+
import { BuildContext, BunupPlugin, MaybePromise } from "./shared/bunup-ff28zhd9";
|
|
2
2
|
/**
|
|
3
3
|
* A plugin that copies files and directories to the output directory.
|
|
4
4
|
*
|
|
@@ -28,6 +28,13 @@ interface ExportsPluginOptions {
|
|
|
28
28
|
* @default false
|
|
29
29
|
*/
|
|
30
30
|
excludeCss?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Whether to include "./package.json": "./package.json" in the exports field
|
|
33
|
+
*
|
|
34
|
+
* @default true
|
|
35
|
+
* @see https://bunup.dev/docs/plugins/exports#includepackagejson
|
|
36
|
+
*/
|
|
37
|
+
includePackageJson?: boolean;
|
|
31
38
|
}
|
|
32
39
|
/**
|
|
33
40
|
* A plugin that generates the exports field in the package.json file automatically.
|
package/dist/plugins.js
CHANGED
|
@@ -4,18 +4,18 @@ import {
|
|
|
4
4
|
JS_DTS_RE,
|
|
5
5
|
JS_TS_RE,
|
|
6
6
|
cleanPath,
|
|
7
|
+
detectFileFormatting,
|
|
7
8
|
ensureArray,
|
|
8
9
|
formatListWithAnd,
|
|
9
10
|
getPackageForPlugin,
|
|
10
11
|
isDirectoryPath,
|
|
11
12
|
logger
|
|
12
|
-
} from "./shared/bunup-
|
|
13
|
+
} from "./shared/bunup-a55nf4gz.js";
|
|
13
14
|
|
|
14
15
|
// packages/bunup/src/plugins/built-in/copy.ts
|
|
15
16
|
import { basename, join } from "path";
|
|
16
17
|
function copy(pattern, outPath) {
|
|
17
18
|
return {
|
|
18
|
-
type: "bunup",
|
|
19
19
|
name: "copy",
|
|
20
20
|
hooks: {
|
|
21
21
|
onBuildDone: async ({ options, meta }) => {
|
|
@@ -38,7 +38,6 @@ function copy(pattern, outPath) {
|
|
|
38
38
|
import path from "path";
|
|
39
39
|
function exports(options = {}) {
|
|
40
40
|
return {
|
|
41
|
-
type: "bunup",
|
|
42
41
|
name: "exports",
|
|
43
42
|
hooks: {
|
|
44
43
|
onBuildDone: async (ctx) => {
|
|
@@ -56,11 +55,18 @@ async function processPackageJsonExports(ctx, options) {
|
|
|
56
55
|
const { exportsField, entryPoints } = generateExportsFields(output.files, options.exclude, options.excludeCss, ctx);
|
|
57
56
|
const updatedFiles = createUpdatedFilesArray(meta.packageJson.data, buildOptions.outDir);
|
|
58
57
|
const mergedExports = mergeCustomExportsWithGenerated(exportsField, options.customExports, ctx);
|
|
59
|
-
const
|
|
58
|
+
const finalExports = addPackageJsonExport(mergedExports, options.includePackageJson);
|
|
59
|
+
const newPackageJson = createUpdatedPackageJson(meta.packageJson.data, entryPoints, finalExports, updatedFiles);
|
|
60
60
|
if (Bun.deepEquals(newPackageJson, meta.packageJson.data)) {
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
|
-
await
|
|
63
|
+
const formatting = await detectFileFormatting(meta.packageJson.path);
|
|
64
|
+
let jsonContent = JSON.stringify(newPackageJson, null, formatting.indentation);
|
|
65
|
+
if (formatting.hasTrailingNewline) {
|
|
66
|
+
jsonContent += `
|
|
67
|
+
`;
|
|
68
|
+
}
|
|
69
|
+
await Bun.write(meta.packageJson.path, jsonContent);
|
|
64
70
|
} catch {
|
|
65
71
|
logger.error("Failed to update package.json");
|
|
66
72
|
}
|
|
@@ -285,6 +291,16 @@ function getCssExportKey(pathRelativeToOutdir) {
|
|
|
285
291
|
return `./${pathSegments.join("/")}.css`;
|
|
286
292
|
}
|
|
287
293
|
}
|
|
294
|
+
function addPackageJsonExport(exports2, includePackageJson) {
|
|
295
|
+
if (includePackageJson === false) {
|
|
296
|
+
return exports2;
|
|
297
|
+
}
|
|
298
|
+
const finalExports = { ...exports2 };
|
|
299
|
+
if (!finalExports["./package.json"]) {
|
|
300
|
+
finalExports["./package.json"] = "./package.json";
|
|
301
|
+
}
|
|
302
|
+
return finalExports;
|
|
303
|
+
}
|
|
288
304
|
function exportFieldToEntryPoint(exportField) {
|
|
289
305
|
switch (exportField) {
|
|
290
306
|
case "types":
|
|
@@ -405,7 +421,6 @@ import pc from "picocolors";
|
|
|
405
421
|
function unused(options = {}) {
|
|
406
422
|
const { level = "warn", ignore = [] } = options;
|
|
407
423
|
return {
|
|
408
|
-
type: "bunup",
|
|
409
424
|
name: "unused",
|
|
410
425
|
hooks: {
|
|
411
426
|
onBuildDone: async (ctx) => {
|
|
@@ -435,6 +435,28 @@ function replaceExtension(filePath, newExtension) {
|
|
|
435
435
|
const nameWithoutExtension = filename.substring(0, lastDotIndex);
|
|
436
436
|
return directory + nameWithoutExtension + normalizedExtension;
|
|
437
437
|
}
|
|
438
|
+
async function detectFileFormatting(filePath) {
|
|
439
|
+
try {
|
|
440
|
+
const content = await Bun.file(filePath).text();
|
|
441
|
+
const hasTrailingNewline = content.endsWith(`
|
|
442
|
+
`);
|
|
443
|
+
const lines = content.split(`
|
|
444
|
+
`);
|
|
445
|
+
for (const line of lines) {
|
|
446
|
+
const match = line.match(/^(\s+)/);
|
|
447
|
+
if (match) {
|
|
448
|
+
const indent = match[1];
|
|
449
|
+
if (indent.startsWith("\t")) {
|
|
450
|
+
return { indentation: "\t", hasTrailingNewline };
|
|
451
|
+
}
|
|
452
|
+
return { indentation: indent, hasTrailingNewline };
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
return { indentation: " ", hasTrailingNewline };
|
|
456
|
+
} catch {
|
|
457
|
+
return { indentation: " ", hasTrailingNewline: true };
|
|
458
|
+
}
|
|
459
|
+
}
|
|
438
460
|
|
|
439
461
|
// packages/bunup/src/plugins/utils.ts
|
|
440
462
|
import pc3 from "picocolors";
|
|
@@ -476,4 +498,4 @@ async function getPackageForPlugin(name, pluginName) {
|
|
|
476
498
|
return pkg;
|
|
477
499
|
}
|
|
478
500
|
|
|
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 };
|
|
501
|
+
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, detectFileFormatting, filterBunPlugins, filterBunupPlugins, runPluginBuildStartHooks, runPluginBuildDoneHooks, getPackageForPlugin };
|
|
@@ -72,8 +72,6 @@ type BunupPluginHooks = {
|
|
|
72
72
|
* Represents a Bunup-specific plugin
|
|
73
73
|
*/
|
|
74
74
|
type BunupPlugin = {
|
|
75
|
-
/** Identifies this as a Bunup-specific plugin */
|
|
76
|
-
type: "bunup"
|
|
77
75
|
/** Optional name for the plugin */
|
|
78
76
|
name?: string
|
|
79
77
|
/** The hooks implemented by this plugin */
|
|
@@ -391,12 +389,9 @@ interface BuildOptions {
|
|
|
391
389
|
*
|
|
392
390
|
* @example
|
|
393
391
|
* plugins: [
|
|
392
|
+
* myBunPlugin(),
|
|
394
393
|
* {
|
|
395
|
-
*
|
|
396
|
-
* plugin: myBunPlugin()
|
|
397
|
-
* },
|
|
398
|
-
* {
|
|
399
|
-
* type: "bunup",
|
|
394
|
+
* name: "my-bunup-plugin",
|
|
400
395
|
* hooks: {
|
|
401
396
|
* onBuildStart: (options) => {
|
|
402
397
|
* console.log('Build started with options:', options)
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
runPluginBuildStartHooks,
|
|
23
23
|
setSilent,
|
|
24
24
|
silent
|
|
25
|
-
} from "./bunup-
|
|
25
|
+
} from "./bunup-a55nf4gz.js";
|
|
26
26
|
|
|
27
27
|
// packages/bunup/src/loaders.ts
|
|
28
28
|
import path from "path";
|
|
@@ -101,7 +101,6 @@ async function executeOnSuccess(onSuccess, options, signal) {
|
|
|
101
101
|
import pc from "picocolors";
|
|
102
102
|
function report() {
|
|
103
103
|
return {
|
|
104
|
-
type: "bunup",
|
|
105
104
|
name: "report",
|
|
106
105
|
hooks: {
|
|
107
106
|
onBuildDone: async ({ options, output }) => {
|
|
@@ -160,7 +159,6 @@ function report() {
|
|
|
160
159
|
// packages/bunup/src/plugins/internal/use-client.ts
|
|
161
160
|
function useClient() {
|
|
162
161
|
return {
|
|
163
|
-
type: "bunup",
|
|
164
162
|
name: "use-client",
|
|
165
163
|
hooks: {
|
|
166
164
|
onBuildDone: async ({ output }) => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bunup",
|
|
3
3
|
"description": "⚡ A blazing-fast build tool for your libraries built with Bun.",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.24",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
"types": "./dist/plugins.d.ts",
|
|
21
21
|
"default": "./dist/plugins.js"
|
|
22
22
|
}
|
|
23
|
-
}
|
|
23
|
+
},
|
|
24
|
+
"./package.json": "./package.json"
|
|
24
25
|
},
|
|
25
26
|
"license": "MIT",
|
|
26
27
|
"author": "Arshad Yaseen <m@arshadyaseen.com> (https://arshadyaseen.com)",
|