bunup 0.11.24 → 0.11.25
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 +66 -12
- package/dist/plugins.js +100 -30
- package/dist/shared/{bunup-a55nf4gz.js → bunup-ed9pv5cz.js} +2 -44
- package/dist/shared/{bunup-ff28zhd9.d.ts → bunup-r5ahaj5s.d.ts} +12 -0
- package/dist/shared/{bunup-rqk1dnq1.js → bunup-yaq8w9a4.js} +81 -7
- package/package.json +5 -8
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-yaq8w9a4.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-ed9pv5cz.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.25";
|
|
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-r5ahaj5s";
|
|
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-yaq8w9a4.js";
|
|
5
|
+
import"./shared/bunup-ed9pv5cz.js";
|
|
6
6
|
// packages/bunup/src/define.ts
|
|
7
7
|
function defineConfig(options) {
|
|
8
8
|
return options;
|
package/dist/plugins.d.ts
CHANGED
|
@@ -1,12 +1,27 @@
|
|
|
1
|
-
import { BuildContext, BunupPlugin, MaybePromise } from "./shared/bunup-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
declare
|
|
1
|
+
import { BuildContext, BunupPlugin, MaybePromise } from "./shared/bunup-r5ahaj5s";
|
|
2
|
+
type CopyOptions = {
|
|
3
|
+
/** Whether to follow symbolic links when copying files. */
|
|
4
|
+
followSymlinks?: boolean
|
|
5
|
+
/** Whether to exclude dotfiles (files starting with a dot) from being copied. */
|
|
6
|
+
excludeDotfiles?: boolean
|
|
7
|
+
};
|
|
8
|
+
declare function copy(pattern: string | string[]): BunupPlugin & CopyBuilder;
|
|
9
|
+
declare class CopyBuilder {
|
|
10
|
+
private _patterns;
|
|
11
|
+
private _destination?;
|
|
12
|
+
private _options?;
|
|
13
|
+
constructor(pattern: string | string[]);
|
|
14
|
+
/**
|
|
15
|
+
* Sets the destination directory where files will be copied.
|
|
16
|
+
*/
|
|
17
|
+
to(destination: string): this;
|
|
18
|
+
/**
|
|
19
|
+
* Sets additional options for the copy operation.
|
|
20
|
+
*/
|
|
21
|
+
with(options: CopyOptions): this;
|
|
22
|
+
get name(): string;
|
|
23
|
+
get hooks(): BunupPlugin["hooks"];
|
|
24
|
+
}
|
|
10
25
|
type CustomExports = Record<string, string | Record<string, string | Record<string, string>>>;
|
|
11
26
|
type Exclude = ((ctx: BuildContext) => string[] | undefined) | string[];
|
|
12
27
|
interface ExportsPluginOptions {
|
|
@@ -35,6 +50,16 @@ interface ExportsPluginOptions {
|
|
|
35
50
|
* @see https://bunup.dev/docs/plugins/exports#includepackagejson
|
|
36
51
|
*/
|
|
37
52
|
includePackageJson?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Whether to add a wildcard export that allows deep imports
|
|
55
|
+
*
|
|
56
|
+
* When true, adds "./*": "./*" to exports, making all files accessible
|
|
57
|
+
* When false (default), only explicit exports are accessible
|
|
58
|
+
*
|
|
59
|
+
* @default false
|
|
60
|
+
* @see https://bunup.dev/docs/plugins/exports#all
|
|
61
|
+
*/
|
|
62
|
+
all?: boolean;
|
|
38
63
|
}
|
|
39
64
|
/**
|
|
40
65
|
* A plugin that generates the exports field in the package.json file automatically.
|
|
@@ -43,15 +68,44 @@ interface ExportsPluginOptions {
|
|
|
43
68
|
*/
|
|
44
69
|
declare function exports(options?: ExportsPluginOptions): BunupPlugin;
|
|
45
70
|
import { BunPlugin } from "bun";
|
|
46
|
-
type InjectStylesPluginOptions =
|
|
71
|
+
type InjectStylesPluginOptions = {
|
|
72
|
+
/**
|
|
73
|
+
* Custom function to inject CSS into the document head.
|
|
74
|
+
*
|
|
75
|
+
* By default, bunup uses its own `injectStyle` function that creates a `<style>`
|
|
76
|
+
* tag and appends it to the document head. You can provide your own injection
|
|
77
|
+
* logic to customize how styles are applied to the document.
|
|
78
|
+
*
|
|
79
|
+
* @param css - The processed CSS string (already JSON stringified)
|
|
80
|
+
* @param filePath - The original file path of the CSS file being processed
|
|
81
|
+
* @returns JavaScript code that will inject the styles when executed
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* injectStyles({
|
|
86
|
+
* inject: (css, filePath) => {
|
|
87
|
+
* return `
|
|
88
|
+
* const style = document.createElement('style');
|
|
89
|
+
* style.setAttribute('data-source', '${filePath}');
|
|
90
|
+
* style.textContent = ${css};
|
|
91
|
+
* document.head.appendChild(style);
|
|
92
|
+
* `;
|
|
93
|
+
* }
|
|
94
|
+
* })
|
|
95
|
+
* ```
|
|
96
|
+
*
|
|
97
|
+
* The default injection handles cases like when `document` is undefined (e.g., server-side rendering) and compatibility with older browsers. Consider these when implementing custom injection logic.
|
|
98
|
+
*/
|
|
47
99
|
inject?: (css: string, filePath: string) => MaybePromise<string>
|
|
48
|
-
/**
|
|
100
|
+
/**
|
|
101
|
+
* Whether to minify the styles being injected.
|
|
102
|
+
*
|
|
49
103
|
* @default true
|
|
50
104
|
*/
|
|
51
105
|
minify?: boolean
|
|
52
106
|
};
|
|
53
107
|
/**
|
|
54
|
-
* A plugin that injects styles into the document head.
|
|
108
|
+
* A plugin that injects styles into the document head at runtime instead of bundling them to the build output.
|
|
55
109
|
*
|
|
56
110
|
* @see https://bunup.dev/docs/plugins/inject-styles
|
|
57
111
|
*/
|
package/dist/plugins.js
CHANGED
|
@@ -7,32 +7,91 @@ import {
|
|
|
7
7
|
detectFileFormatting,
|
|
8
8
|
ensureArray,
|
|
9
9
|
formatListWithAnd,
|
|
10
|
-
getPackageForPlugin,
|
|
11
|
-
isDirectoryPath,
|
|
12
10
|
logger
|
|
13
|
-
} from "./shared/bunup-
|
|
11
|
+
} from "./shared/bunup-ed9pv5cz.js";
|
|
14
12
|
|
|
15
13
|
// packages/bunup/src/plugins/built-in/copy.ts
|
|
16
|
-
import { basename, join } from "path";
|
|
17
|
-
function copy(pattern
|
|
18
|
-
return
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
14
|
+
import { basename, extname, join } from "path";
|
|
15
|
+
function copy(pattern) {
|
|
16
|
+
return new CopyBuilder(pattern);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
class CopyBuilder {
|
|
20
|
+
_patterns;
|
|
21
|
+
_destination;
|
|
22
|
+
_options;
|
|
23
|
+
constructor(pattern) {
|
|
24
|
+
this._patterns = ensureArray(pattern);
|
|
25
|
+
}
|
|
26
|
+
to(destination) {
|
|
27
|
+
this._destination = destination;
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
with(options) {
|
|
31
|
+
this._options = options;
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
get name() {
|
|
35
|
+
return "copy";
|
|
36
|
+
}
|
|
37
|
+
get hooks() {
|
|
38
|
+
return {
|
|
39
|
+
onBuildDone: async ({ options: buildOptions, meta }) => {
|
|
40
|
+
let destinationPath = "";
|
|
41
|
+
if (this._destination) {
|
|
42
|
+
if (this._destination.startsWith(buildOptions.outDir)) {
|
|
43
|
+
logger.warn("You don't need to include the output directory in the destination path for the copy plugin. Files are copied to the output directory by default.", {
|
|
44
|
+
verticalSpace: true
|
|
45
|
+
});
|
|
46
|
+
destinationPath = this._destination;
|
|
47
|
+
} else {
|
|
48
|
+
destinationPath = join(buildOptions.outDir, this._destination);
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
destinationPath = buildOptions.outDir;
|
|
52
|
+
}
|
|
53
|
+
for (const pattern of this._patterns) {
|
|
54
|
+
const glob = new Bun.Glob(pattern);
|
|
55
|
+
for await (const scannedPath of glob.scan({
|
|
26
56
|
cwd: meta.rootDir,
|
|
27
|
-
dot:
|
|
57
|
+
dot: !this._options?.excludeDotfiles,
|
|
58
|
+
onlyFiles: !isPatternFolder(pattern),
|
|
59
|
+
followSymlinks: this._options?.followSymlinks
|
|
28
60
|
})) {
|
|
29
|
-
const
|
|
30
|
-
|
|
61
|
+
const sourcePath = join(meta.rootDir, scannedPath);
|
|
62
|
+
const destinationDir = resolveDestinationPath(destinationPath, scannedPath, meta.rootDir);
|
|
63
|
+
if (isPathDir(sourcePath)) {
|
|
64
|
+
await copyDirectory(sourcePath, destinationDir);
|
|
65
|
+
} else {
|
|
66
|
+
await copyFile(sourcePath, destinationDir);
|
|
67
|
+
}
|
|
31
68
|
}
|
|
32
69
|
}
|
|
33
70
|
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function resolveDestinationPath(destinationPath, scannedPath, rootDir) {
|
|
75
|
+
const fullDestinationPath = join(rootDir, destinationPath);
|
|
76
|
+
const isScannedPathDir = isPathDir(scannedPath);
|
|
77
|
+
const isDestinationDir = isPathDir(fullDestinationPath);
|
|
78
|
+
if (isDestinationDir && !isScannedPathDir) {
|
|
79
|
+
return join(fullDestinationPath, basename(scannedPath));
|
|
80
|
+
}
|
|
81
|
+
return fullDestinationPath;
|
|
82
|
+
}
|
|
83
|
+
function isPatternFolder(pattern) {
|
|
84
|
+
return !pattern.includes("/");
|
|
85
|
+
}
|
|
86
|
+
function isPathDir(filePath) {
|
|
87
|
+
return extname(filePath) === "";
|
|
88
|
+
}
|
|
89
|
+
async function copyDirectory(sourcePath, destinationPath) {
|
|
90
|
+
await Bun.$`cp -r ${sourcePath} ${destinationPath}`;
|
|
91
|
+
}
|
|
92
|
+
async function copyFile(sourcePath, destinationPath) {
|
|
93
|
+
const sourceFile = Bun.file(sourcePath);
|
|
94
|
+
await Bun.write(destinationPath, sourceFile);
|
|
36
95
|
}
|
|
37
96
|
// packages/bunup/src/plugins/built-in/exports.ts
|
|
38
97
|
import path from "path";
|
|
@@ -55,7 +114,7 @@ async function processPackageJsonExports(ctx, options) {
|
|
|
55
114
|
const { exportsField, entryPoints } = generateExportsFields(output.files, options.exclude, options.excludeCss, ctx);
|
|
56
115
|
const updatedFiles = createUpdatedFilesArray(meta.packageJson.data, buildOptions.outDir);
|
|
57
116
|
const mergedExports = mergeCustomExportsWithGenerated(exportsField, options.customExports, ctx);
|
|
58
|
-
const finalExports =
|
|
117
|
+
const finalExports = addPackageJsonOrWildcardExport(mergedExports, options.includePackageJson, options.all);
|
|
59
118
|
const newPackageJson = createUpdatedPackageJson(meta.packageJson.data, entryPoints, finalExports, updatedFiles);
|
|
60
119
|
if (Bun.deepEquals(newPackageJson, meta.packageJson.data)) {
|
|
61
120
|
return;
|
|
@@ -291,13 +350,14 @@ function getCssExportKey(pathRelativeToOutdir) {
|
|
|
291
350
|
return `./${pathSegments.join("/")}.css`;
|
|
292
351
|
}
|
|
293
352
|
}
|
|
294
|
-
function
|
|
295
|
-
if (includePackageJson === false) {
|
|
296
|
-
return exports2;
|
|
297
|
-
}
|
|
353
|
+
function addPackageJsonOrWildcardExport(exports2, includePackageJson, all) {
|
|
298
354
|
const finalExports = { ...exports2 };
|
|
299
|
-
if (
|
|
300
|
-
finalExports["
|
|
355
|
+
if (all) {
|
|
356
|
+
finalExports["./*"] = "./*";
|
|
357
|
+
} else if (includePackageJson !== false) {
|
|
358
|
+
if (!finalExports["./package.json"]) {
|
|
359
|
+
finalExports["./package.json"] = "./package.json";
|
|
360
|
+
}
|
|
301
361
|
}
|
|
302
362
|
return finalExports;
|
|
303
363
|
}
|
|
@@ -313,12 +373,22 @@ function exportFieldToEntryPoint(exportField) {
|
|
|
313
373
|
}
|
|
314
374
|
// packages/bunup/src/plugins/built-in/inject-styles.ts
|
|
315
375
|
import path2 from "path";
|
|
376
|
+
import { transform } from "lightningcss";
|
|
377
|
+
|
|
378
|
+
// packages/bunup/src/constants/css.ts
|
|
379
|
+
var DEFAULT_CSS_TARGETS = {
|
|
380
|
+
chrome: 87 << 16,
|
|
381
|
+
firefox: 78 << 16,
|
|
382
|
+
safari: 14 << 16,
|
|
383
|
+
edge: 88 << 16
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
// packages/bunup/src/plugins/built-in/inject-styles.ts
|
|
316
387
|
function injectStyles(options) {
|
|
317
|
-
const { inject,
|
|
388
|
+
const { inject, minify = true } = options ?? {};
|
|
318
389
|
return {
|
|
319
390
|
name: "bunup:inject-styles",
|
|
320
391
|
async setup(build) {
|
|
321
|
-
const lightningcss = await getPackageForPlugin("lightningcss", "inject-styles");
|
|
322
392
|
build.onResolve({ filter: /^__inject-style$/ }, () => {
|
|
323
393
|
return {
|
|
324
394
|
path: "__inject-style",
|
|
@@ -347,11 +417,11 @@ function injectStyles(options) {
|
|
|
347
417
|
});
|
|
348
418
|
build.onLoad({ filter: CSS_RE }, async (args) => {
|
|
349
419
|
const source = await Bun.file(args.path).text();
|
|
350
|
-
const { code, warnings } =
|
|
351
|
-
...transformOptions,
|
|
420
|
+
const { code, warnings } = transform({
|
|
352
421
|
filename: path2.basename(args.path),
|
|
353
422
|
code: Buffer.from(source),
|
|
354
|
-
minify
|
|
423
|
+
minify,
|
|
424
|
+
targets: DEFAULT_CSS_TARGETS
|
|
355
425
|
});
|
|
356
426
|
for (const warning of warnings) {
|
|
357
427
|
logger.warn(warning.message);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __getProtoOf = Object.getPrototypeOf;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
@@ -381,9 +382,6 @@ function cleanPath(path2) {
|
|
|
381
382
|
cleaned = cleaned.replace(/\/+/g, "/");
|
|
382
383
|
return cleaned;
|
|
383
384
|
}
|
|
384
|
-
function isDirectoryPath(filePath) {
|
|
385
|
-
return path.extname(filePath) === "";
|
|
386
|
-
}
|
|
387
385
|
function formatListWithAnd(arr) {
|
|
388
386
|
return new Intl.ListFormat("en", {
|
|
389
387
|
style: "long",
|
|
@@ -458,44 +456,4 @@ async function detectFileFormatting(filePath) {
|
|
|
458
456
|
}
|
|
459
457
|
}
|
|
460
458
|
|
|
461
|
-
|
|
462
|
-
import pc3 from "picocolors";
|
|
463
|
-
function filterBunPlugins(plugins) {
|
|
464
|
-
if (!plugins)
|
|
465
|
-
return [];
|
|
466
|
-
return plugins.filter((p) => ("setup" in p));
|
|
467
|
-
}
|
|
468
|
-
function filterBunupPlugins(plugins) {
|
|
469
|
-
if (!plugins)
|
|
470
|
-
return [];
|
|
471
|
-
return plugins.filter((p) => ("hooks" in p));
|
|
472
|
-
}
|
|
473
|
-
async function runPluginBuildStartHooks(bunupPlugins, options) {
|
|
474
|
-
if (!bunupPlugins)
|
|
475
|
-
return;
|
|
476
|
-
for (const plugin of bunupPlugins) {
|
|
477
|
-
if (plugin.hooks.onBuildStart) {
|
|
478
|
-
await plugin.hooks.onBuildStart(options);
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
async function runPluginBuildDoneHooks(bunupPlugins, options, output, meta) {
|
|
483
|
-
if (!bunupPlugins)
|
|
484
|
-
return;
|
|
485
|
-
for (const plugin of bunupPlugins) {
|
|
486
|
-
if (plugin.hooks.onBuildDone) {
|
|
487
|
-
await plugin.hooks.onBuildDone({ options, output, meta });
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
async function getPackageForPlugin(name, pluginName) {
|
|
492
|
-
let pkg;
|
|
493
|
-
try {
|
|
494
|
-
pkg = await import(name);
|
|
495
|
-
} catch {
|
|
496
|
-
throw new BunupPluginError(`[${pc3.cyan(name)}] is required for the ${pluginName} plugin. Please install it with: ${pc3.blue(`bun add ${name} --dev`)}`);
|
|
497
|
-
}
|
|
498
|
-
return pkg;
|
|
499
|
-
}
|
|
500
|
-
|
|
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 };
|
|
459
|
+
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, formatListWithAnd, getFilesFromGlobs, isTypeScriptFile, isJavascriptFile, replaceExtension, detectFileFormatting };
|
|
@@ -84,6 +84,14 @@ type Format = "esm" | "cjs" | "iife";
|
|
|
84
84
|
type Target = "bun" | "node" | "browser";
|
|
85
85
|
type External = (string | RegExp)[];
|
|
86
86
|
type Env = "inline" | "disable" | `${string}*` | Record<string, string>;
|
|
87
|
+
type CSSOptions = {
|
|
88
|
+
/**
|
|
89
|
+
* Generate TypeScript definitions for CSS modules.
|
|
90
|
+
*
|
|
91
|
+
* @see https://bunup.dev/docs/guide/css#css-modules-and-typescript
|
|
92
|
+
*/
|
|
93
|
+
typedModules?: boolean
|
|
94
|
+
};
|
|
87
95
|
type OnSuccess = ((options: Partial<BuildOptions>) => MaybePromise<void> | (() => void)) | string | {
|
|
88
96
|
/**
|
|
89
97
|
* The shell command to execute after a successful build
|
|
@@ -404,6 +412,10 @@ interface BuildOptions {
|
|
|
404
412
|
* ]
|
|
405
413
|
*/
|
|
406
414
|
plugins?: (BunupPlugin | BunPlugin)[];
|
|
415
|
+
/**
|
|
416
|
+
* Options for CSS handling in the build process.
|
|
417
|
+
*/
|
|
418
|
+
css?: CSSOptions;
|
|
407
419
|
}
|
|
408
420
|
type MaybePromise<T> = Promise<T> | T;
|
|
409
421
|
type WithOptional<
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
// @bun
|
|
1
2
|
import {
|
|
2
3
|
BunupBuildError,
|
|
3
4
|
BunupDTSBuildError,
|
|
4
5
|
cleanOutDir,
|
|
5
6
|
cleanPath,
|
|
6
7
|
ensureArray,
|
|
7
|
-
filterBunPlugins,
|
|
8
|
-
filterBunupPlugins,
|
|
9
8
|
formatFileSize,
|
|
10
9
|
getDefaultDtsOutputExtention,
|
|
11
10
|
getDefaultJsOutputExtension,
|
|
@@ -18,11 +17,9 @@ import {
|
|
|
18
17
|
logger,
|
|
19
18
|
parseErrorMessage,
|
|
20
19
|
replaceExtension,
|
|
21
|
-
runPluginBuildDoneHooks,
|
|
22
|
-
runPluginBuildStartHooks,
|
|
23
20
|
setSilent,
|
|
24
21
|
silent
|
|
25
|
-
} from "./bunup-
|
|
22
|
+
} from "./bunup-ed9pv5cz.js";
|
|
26
23
|
|
|
27
24
|
// packages/bunup/src/loaders.ts
|
|
28
25
|
import path from "path";
|
|
@@ -97,6 +94,47 @@ async function executeOnSuccess(onSuccess, options, signal) {
|
|
|
97
94
|
}
|
|
98
95
|
}
|
|
99
96
|
|
|
97
|
+
// packages/bunup/src/plugins/internal/css-typed-modules.ts
|
|
98
|
+
import { transform } from "lightningcss";
|
|
99
|
+
function cssTypedModulesPlugin() {
|
|
100
|
+
return {
|
|
101
|
+
name: "bunup:css-typed-modules",
|
|
102
|
+
setup(build) {
|
|
103
|
+
build.onLoad({ filter: /\.module\.css$/ }, async (args) => {
|
|
104
|
+
const uc = new Set;
|
|
105
|
+
const source = await Bun.file(args.path).text();
|
|
106
|
+
transform({
|
|
107
|
+
filename: args.path,
|
|
108
|
+
code: Buffer.from(source),
|
|
109
|
+
visitor: {
|
|
110
|
+
Rule: {
|
|
111
|
+
style(rule) {
|
|
112
|
+
rule.value.selectors.forEach((selector) => {
|
|
113
|
+
selector.forEach((component) => {
|
|
114
|
+
if (component.type === "class") {
|
|
115
|
+
uc.add(component.name);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
const classes = Array.from(uc);
|
|
124
|
+
const destination = `${args.path}.d.ts`;
|
|
125
|
+
const dts = `// This file is automatically generated. Do not edit.
|
|
126
|
+
declare const classes: {
|
|
127
|
+
${classes.map((className) => ` readonly "${className}": string;`).join(`
|
|
128
|
+
`)}
|
|
129
|
+
};
|
|
130
|
+
export default classes;
|
|
131
|
+
`;
|
|
132
|
+
await Bun.write(destination, dts);
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
100
138
|
// packages/bunup/src/plugins/internal/report.ts
|
|
101
139
|
import pc from "picocolors";
|
|
102
140
|
function report() {
|
|
@@ -191,9 +229,15 @@ function createBuildOptions(partialOptions) {
|
|
|
191
229
|
...DEFAULT_OPTIONS,
|
|
192
230
|
...partialOptions
|
|
193
231
|
};
|
|
232
|
+
const typedModulesEnabled = options.css?.typedModules !== false;
|
|
194
233
|
return {
|
|
195
234
|
...options,
|
|
196
|
-
plugins: [
|
|
235
|
+
plugins: [
|
|
236
|
+
...options.plugins ?? [],
|
|
237
|
+
...typedModulesEnabled ? [cssTypedModulesPlugin()] : [],
|
|
238
|
+
useClient(),
|
|
239
|
+
report()
|
|
240
|
+
]
|
|
197
241
|
};
|
|
198
242
|
}
|
|
199
243
|
function getResolvedMinify(options) {
|
|
@@ -252,7 +296,7 @@ function isExternal(path2, options, packageJson) {
|
|
|
252
296
|
// packages/bunup/src/plugins/internal/external-option.ts
|
|
253
297
|
function externalOptionPlugin(options, packageJson) {
|
|
254
298
|
return {
|
|
255
|
-
name: "bunup:external-option
|
|
299
|
+
name: "bunup:external-option",
|
|
256
300
|
setup(build) {
|
|
257
301
|
build.onResolve({ filter: /.*/ }, (args) => {
|
|
258
302
|
const importPath = args.path;
|
|
@@ -268,6 +312,36 @@ function externalOptionPlugin(options, packageJson) {
|
|
|
268
312
|
};
|
|
269
313
|
}
|
|
270
314
|
|
|
315
|
+
// packages/bunup/src/plugins/utils.ts
|
|
316
|
+
function filterBunPlugins(plugins) {
|
|
317
|
+
if (!plugins)
|
|
318
|
+
return [];
|
|
319
|
+
return plugins.filter((p) => ("setup" in p));
|
|
320
|
+
}
|
|
321
|
+
function filterBunupPlugins(plugins) {
|
|
322
|
+
if (!plugins)
|
|
323
|
+
return [];
|
|
324
|
+
return plugins.filter((p) => ("hooks" in p));
|
|
325
|
+
}
|
|
326
|
+
async function runPluginBuildStartHooks(bunupPlugins, options) {
|
|
327
|
+
if (!bunupPlugins)
|
|
328
|
+
return;
|
|
329
|
+
for (const plugin of bunupPlugins) {
|
|
330
|
+
if (plugin.hooks.onBuildStart) {
|
|
331
|
+
await plugin.hooks.onBuildStart(options);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
async function runPluginBuildDoneHooks(bunupPlugins, options, output, meta) {
|
|
336
|
+
if (!bunupPlugins)
|
|
337
|
+
return;
|
|
338
|
+
for (const plugin of bunupPlugins) {
|
|
339
|
+
if (plugin.hooks.onBuildDone) {
|
|
340
|
+
await plugin.hooks.onBuildDone({ options, output, meta });
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
271
345
|
// packages/bunup/src/build.ts
|
|
272
346
|
var ac = null;
|
|
273
347
|
async function build(partialOptions, rootDir = process.cwd()) {
|
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.25",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
@@ -47,23 +47,20 @@
|
|
|
47
47
|
"bunup": "dist/cli/index.js"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
+
"@bunup/dts": "0.11.25",
|
|
50
51
|
"chokidar": "^4.0.3",
|
|
51
52
|
"coffi": "^0.1.35",
|
|
53
|
+
"lightningcss": "^1.30.1",
|
|
52
54
|
"picocolors": "^1.1.1",
|
|
53
55
|
"tinyexec": "^1.0.1",
|
|
54
|
-
"tree-kill": "^1.2.2"
|
|
55
|
-
"@bunup/dts": "0.11.18"
|
|
56
|
+
"tree-kill": "^1.2.2"
|
|
56
57
|
},
|
|
57
58
|
"peerDependencies": {
|
|
58
|
-
"typescript": ">=4.5.0"
|
|
59
|
-
"lightningcss": ">=1.17.0"
|
|
59
|
+
"typescript": ">=4.5.0"
|
|
60
60
|
},
|
|
61
61
|
"peerDependenciesMeta": {
|
|
62
62
|
"typescript": {
|
|
63
63
|
"optional": true
|
|
64
|
-
},
|
|
65
|
-
"lightningcss": {
|
|
66
|
-
"optional": true
|
|
67
64
|
}
|
|
68
65
|
},
|
|
69
66
|
"devDependencies": {
|