@reliverse/build 2.2.7

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.
Files changed (75) hide show
  1. package/dist/impl/assets.d.ts +28 -0
  2. package/dist/impl/assets.js +188 -0
  3. package/dist/impl/cache.d.ts +25 -0
  4. package/dist/impl/cache.js +209 -0
  5. package/dist/impl/constants.d.ts +44 -0
  6. package/dist/impl/constants.js +45 -0
  7. package/dist/impl/debug.d.ts +30 -0
  8. package/dist/impl/debug.js +150 -0
  9. package/dist/impl/dependency-tracker.d.ts +23 -0
  10. package/dist/impl/dependency-tracker.js +113 -0
  11. package/dist/impl/dev-server.d.ts +24 -0
  12. package/dist/impl/dev-server.js +360 -0
  13. package/dist/impl/dts-generator.d.ts +26 -0
  14. package/dist/impl/dts-generator.js +514 -0
  15. package/dist/impl/go-build.d.ts +10 -0
  16. package/dist/impl/go-build.js +350 -0
  17. package/dist/impl/html-processor.d.ts +21 -0
  18. package/dist/impl/html-processor.js +167 -0
  19. package/dist/impl/impl.d.ts +0 -0
  20. package/dist/impl/impl.js +0 -0
  21. package/dist/impl/plugins/asset-optimization.d.ts +2 -0
  22. package/dist/impl/plugins/asset-optimization.js +114 -0
  23. package/dist/impl/plugins/bundle-analyzer.d.ts +2 -0
  24. package/dist/impl/plugins/bundle-analyzer.js +156 -0
  25. package/dist/impl/plugins/css-modules.d.ts +2 -0
  26. package/dist/impl/plugins/css-modules.js +19 -0
  27. package/dist/impl/plugins/index.d.ts +21 -0
  28. package/dist/impl/plugins/index.js +65 -0
  29. package/dist/impl/plugins/performance.d.ts +2 -0
  30. package/dist/impl/plugins/performance.js +62 -0
  31. package/dist/impl/plugins/react-refresh.d.ts +2 -0
  32. package/dist/impl/plugins/react-refresh.js +33 -0
  33. package/dist/impl/plugins/svg-as-react.d.ts +2 -0
  34. package/dist/impl/plugins/svg-as-react.js +18 -0
  35. package/dist/impl/plugins/typescript-declarations.d.ts +2 -0
  36. package/dist/impl/plugins/typescript-declarations.js +48 -0
  37. package/dist/impl/plugins/worker.d.ts +2 -0
  38. package/dist/impl/plugins/worker.js +20 -0
  39. package/dist/impl/presets.d.ts +10 -0
  40. package/dist/impl/presets.js +196 -0
  41. package/dist/impl/providers/mkdist/loader.d.ts +4 -0
  42. package/dist/impl/providers/mkdist/loader.js +26 -0
  43. package/dist/impl/providers/mkdist/loaders/js.d.ts +2 -0
  44. package/dist/impl/providers/mkdist/loaders/js.js +50 -0
  45. package/dist/impl/providers/mkdist/loaders/loaders-mod.d.ts +9 -0
  46. package/dist/impl/providers/mkdist/loaders/loaders-mod.js +22 -0
  47. package/dist/impl/providers/mkdist/make.d.ts +11 -0
  48. package/dist/impl/providers/mkdist/make.js +230 -0
  49. package/dist/impl/providers/mkdist/utils/dts.d.ts +11 -0
  50. package/dist/impl/providers/mkdist/utils/dts.js +117 -0
  51. package/dist/impl/providers/mkdist/utils/fs.d.ts +1 -0
  52. package/dist/impl/providers/mkdist/utils/fs.js +15 -0
  53. package/dist/impl/providers/mkdist-dts.d.ts +24 -0
  54. package/dist/impl/providers/mkdist-dts.js +8 -0
  55. package/dist/impl/tsconfig-validator.d.ts +35 -0
  56. package/dist/impl/tsconfig-validator.js +184 -0
  57. package/dist/impl/type-guards.d.ts +20 -0
  58. package/dist/impl/type-guards.js +147 -0
  59. package/dist/impl/types.d.ts +322 -0
  60. package/dist/impl/types.js +0 -0
  61. package/dist/impl/utils/go-build-handler.d.ts +12 -0
  62. package/dist/impl/utils/go-build-handler.js +83 -0
  63. package/dist/impl/utils/log-extraction.d.ts +25 -0
  64. package/dist/impl/utils/log-extraction.js +24 -0
  65. package/dist/impl/utils/package-filtering.d.ts +5 -0
  66. package/dist/impl/utils/package-filtering.js +22 -0
  67. package/dist/impl/utils/rebuild-queue.d.ts +38 -0
  68. package/dist/impl/utils/rebuild-queue.js +110 -0
  69. package/dist/impl/validation.d.ts +9 -0
  70. package/dist/impl/validation.js +332 -0
  71. package/dist/impl/watch.d.ts +21 -0
  72. package/dist/impl/watch.js +144 -0
  73. package/dist/mod.d.ts +17 -0
  74. package/dist/mod.js +1390 -0
  75. package/package.json +42 -0
@@ -0,0 +1,184 @@
1
+ import { existsSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { logger } from "@reliverse/relinka";
4
+ import { readTSConfig } from "@reliverse/typerso";
5
+ export async function validateTSConfig(pkg, options = {}) {
6
+ const {
7
+ strict = false,
8
+ checkDeclarations = true,
9
+ checkBuildOutput = true
10
+ } = options;
11
+ const warnings = [];
12
+ const errors = [];
13
+ try {
14
+ const tsconfigPath = join(pkg.path, "tsconfig.json");
15
+ if (!existsSync(tsconfigPath)) {
16
+ if (pkg.hasTsConfig) {
17
+ warnings.push("tsconfig.json referenced but not found");
18
+ }
19
+ return { valid: true, warnings, errors };
20
+ }
21
+ const tsconfig = await readTSConfig(pkg.path);
22
+ if (!tsconfig) {
23
+ errors.push("Could not parse tsconfig.json");
24
+ return { valid: false, warnings, errors };
25
+ }
26
+ const compilerOptions = tsconfig.compilerOptions || {};
27
+ if (!tsconfig.compilerOptions) {
28
+ warnings.push("No compilerOptions found in tsconfig.json");
29
+ }
30
+ if (checkDeclarations) {
31
+ if (compilerOptions.declaration === false) {
32
+ warnings.push(
33
+ "declaration: false - TypeScript declaration files will not be generated"
34
+ );
35
+ } else if (compilerOptions.declaration === void 0) {
36
+ warnings.push(
37
+ "declaration not set - consider adding 'declaration: true' for library packages"
38
+ );
39
+ }
40
+ if (compilerOptions.emitDeclarationOnly === true && !compilerOptions.declaration) {
41
+ errors.push("emitDeclarationOnly: true requires declaration: true");
42
+ }
43
+ if (compilerOptions.declaration && !compilerOptions.outDir && !compilerOptions.declarationDir) {
44
+ warnings.push(
45
+ "declaration: true but no outDir or declarationDir specified - declarations will be emitted alongside source files"
46
+ );
47
+ }
48
+ }
49
+ if (checkBuildOutput) {
50
+ if (compilerOptions.outDir) {
51
+ const outDir = compilerOptions.outDir;
52
+ if (outDir.includes("src") || outDir.includes("source")) {
53
+ warnings.push(
54
+ `outDir '${outDir}' contains 'src' or 'source' - consider using 'dist' or 'build' for output directory`
55
+ );
56
+ }
57
+ } else {
58
+ warnings.push(
59
+ `No outDir specified - consider adding 'outDir: "dist"' for cleaner output structure`
60
+ );
61
+ }
62
+ if (compilerOptions.noEmit === true) {
63
+ warnings.push(
64
+ "noEmit: true - TypeScript will not emit any files (use for type checking only)"
65
+ );
66
+ }
67
+ if (compilerOptions.emitDeclarationOnly === true && compilerOptions.noEmit === true) {
68
+ errors.push("emitDeclarationOnly: true conflicts with noEmit: true");
69
+ }
70
+ }
71
+ if (compilerOptions.target && ![
72
+ "es2015",
73
+ "es2016",
74
+ "es2017",
75
+ "es2018",
76
+ "es2019",
77
+ "es2020",
78
+ "es2021",
79
+ "es2022",
80
+ "esnext"
81
+ ].includes(compilerOptions.target)) {
82
+ warnings.push(
83
+ `Unusual target '${compilerOptions.target}' - consider using a standard ES target`
84
+ );
85
+ }
86
+ if (compilerOptions.module && ![
87
+ "commonjs",
88
+ "amd",
89
+ "system",
90
+ "umd",
91
+ "es6",
92
+ "es2015",
93
+ "esnext",
94
+ "es2020",
95
+ "es2022",
96
+ "node16",
97
+ "nodenext"
98
+ ].includes(compilerOptions.module)) {
99
+ warnings.push(
100
+ `Unusual module '${compilerOptions.module}' - consider using 'esnext' or 'commonjs'`
101
+ );
102
+ }
103
+ if (!compilerOptions.strict) {
104
+ warnings.push(
105
+ "strict mode not enabled - consider adding 'strict: true' for better type safety"
106
+ );
107
+ }
108
+ if (!compilerOptions.skipLibCheck) {
109
+ warnings.push(
110
+ "skipLibCheck not set - consider adding 'skipLibCheck: true' for faster builds"
111
+ );
112
+ }
113
+ if (compilerOptions.allowJs === true && !compilerOptions.checkJs) {
114
+ warnings.push(
115
+ "allowJs: true without checkJs: true - JavaScript files will not be type-checked"
116
+ );
117
+ }
118
+ if (compilerOptions.experimentalDecorators === true && !compilerOptions.emitDecoratorMetadata) {
119
+ warnings.push(
120
+ "experimentalDecorators: true without emitDecoratorMetadata - decorator metadata will not be emitted"
121
+ );
122
+ }
123
+ if (pkg.isFrontendApp) {
124
+ if (compilerOptions.moduleResolution && !["node", "bundler"].includes(compilerOptions.moduleResolution)) {
125
+ warnings.push(
126
+ `Frontend app using moduleResolution '${compilerOptions.moduleResolution}' - consider using 'bundler' for modern bundlers`
127
+ );
128
+ }
129
+ if (compilerOptions.target && ["es5", "es2015"].includes(compilerOptions.target)) {
130
+ warnings.push(
131
+ `Frontend app using old target '${compilerOptions.target}' - consider using 'es2020' or newer for better performance`
132
+ );
133
+ }
134
+ }
135
+ if (!pkg.isFrontendApp) {
136
+ if (compilerOptions.moduleResolution && compilerOptions.moduleResolution === "bundler") {
137
+ warnings.push(
138
+ "Library using moduleResolution 'bundler' - consider using 'node' for better compatibility"
139
+ );
140
+ }
141
+ if (!compilerOptions.declaration) {
142
+ warnings.push(
143
+ "Library package without declaration: true - consider enabling for better type support"
144
+ );
145
+ }
146
+ }
147
+ const hasErrors = errors.length > 0;
148
+ const isValid = !hasErrors || !strict;
149
+ return { valid: isValid, warnings, errors };
150
+ } catch (error) {
151
+ const errorMessage = error instanceof Error ? error.message : String(error);
152
+ errors.push(`Failed to validate tsconfig.json: ${errorMessage}`);
153
+ return { valid: false, warnings, errors };
154
+ }
155
+ }
156
+ export async function validateAllTSConfigs(packages, options = {}) {
157
+ const results = [];
158
+ let allValid = true;
159
+ for (const pkg of packages) {
160
+ const result = await validateTSConfig(pkg, options);
161
+ results.push({ package: pkg.name, result });
162
+ if (!result.valid) {
163
+ allValid = false;
164
+ }
165
+ }
166
+ return { valid: allValid, results };
167
+ }
168
+ export function logValidationResults(results, verbose = false) {
169
+ for (const { package: packageName, result } of results) {
170
+ if (result.errors.length > 0) {
171
+ logger.error(`\u274C ${packageName}: TSConfig validation failed`);
172
+ for (const error of result.errors) {
173
+ logger.error(` ${error}`);
174
+ }
175
+ } else if (result.warnings.length > 0) {
176
+ logger.warn(`\u26A0\uFE0F ${packageName}: TSConfig validation warnings`);
177
+ for (const warning of result.warnings) {
178
+ logger.warn(` ${warning}`);
179
+ }
180
+ } else if (verbose) {
181
+ logger.success(`\u2705 ${packageName}: TSConfig validation passed`);
182
+ }
183
+ }
184
+ }
@@ -0,0 +1,20 @@
1
+ import type { PackageBuildConfig } from "@reliverse/config/impl/build";
2
+ import type { BuildOptions, JSXOptions, MinifyOptions, NamingOptions } from "./types.js";
3
+ export declare function isBuildOptions(obj: unknown): obj is BuildOptions;
4
+ export declare function isPackageBuildConfig(obj: unknown): obj is PackageBuildConfig;
5
+ export declare function isMinifyOptions(obj: unknown): obj is MinifyOptions;
6
+ export declare function isJSXOptions(obj: unknown): obj is JSXOptions;
7
+ export declare function isNamingOptions(obj: unknown): obj is NamingOptions;
8
+ export declare function isValidTarget(target: unknown): target is "browser" | "bun" | "node";
9
+ export declare function isValidFormat(format: unknown): format is "esm" | "cjs" | "iife";
10
+ export declare function isValidSourcemap(sourcemap: unknown): sourcemap is "none" | "linked" | "inline" | "external";
11
+ export declare function isValidLoader(loader: unknown): loader is "js";
12
+ export declare function isValidEnv(env: unknown): env is "inline" | "disable" | `${string}*`;
13
+ export declare function isValidPackages(packages: unknown): packages is "bundle" | "external";
14
+ export declare function isStringArray(arr: unknown): arr is string[];
15
+ export declare function isStringOrStringArray(value: unknown): value is string | string[];
16
+ export declare function validateBuildConfig(config: unknown): {
17
+ valid: boolean;
18
+ errors: string[];
19
+ };
20
+ export declare function sanitizeBuildConfig(config: unknown): BuildOptions;
@@ -0,0 +1,147 @@
1
+ export function isBuildOptions(obj) {
2
+ return typeof obj === "object" && obj !== null;
3
+ }
4
+ export function isPackageBuildConfig(obj) {
5
+ return typeof obj === "object" && obj !== null;
6
+ }
7
+ export function isMinifyOptions(obj) {
8
+ if (typeof obj === "boolean") return true;
9
+ if (!obj || typeof obj !== "object") return false;
10
+ const opts = obj;
11
+ return opts.whitespace === void 0 || typeof opts.whitespace === "boolean" && opts.syntax === void 0 || typeof opts.syntax === "boolean" && opts.identifiers === void 0 || typeof opts.identifiers === "boolean";
12
+ }
13
+ export function isJSXOptions(obj) {
14
+ if (!obj || typeof obj !== "object") return false;
15
+ const opts = obj;
16
+ return opts.runtime === void 0 || (opts.runtime === "automatic" || opts.runtime === "classic") && opts.importSource === void 0 || typeof opts.importSource === "string";
17
+ }
18
+ export function isNamingOptions(obj) {
19
+ if (!obj || typeof obj !== "object") return false;
20
+ const opts = obj;
21
+ return opts.chunk === void 0 || typeof opts.chunk === "string" && opts.entry === void 0 || typeof opts.entry === "string" && opts.asset === void 0 || typeof opts.asset === "string";
22
+ }
23
+ export function isValidTarget(target) {
24
+ return target === "browser" || target === "bun" || target === "node";
25
+ }
26
+ export function isValidFormat(format) {
27
+ return format === "esm" || format === "cjs" || format === "iife";
28
+ }
29
+ export function isValidSourcemap(sourcemap) {
30
+ return sourcemap === "none" || sourcemap === "linked" || sourcemap === "inline" || sourcemap === "external";
31
+ }
32
+ export function isValidLoader(loader) {
33
+ const validLoaders = ["js"];
34
+ return typeof loader === "string" && validLoaders.includes(loader);
35
+ }
36
+ export function isValidEnv(env) {
37
+ if (typeof env !== "string") return false;
38
+ return env === "inline" || env === "disable" || env.endsWith("*");
39
+ }
40
+ export function isValidPackages(packages) {
41
+ return packages === "bundle" || packages === "external";
42
+ }
43
+ export function isStringArray(arr) {
44
+ return Array.isArray(arr) && arr.every((item) => typeof item === "string");
45
+ }
46
+ export function isStringOrStringArray(value) {
47
+ return typeof value === "string" || isStringArray(value);
48
+ }
49
+ export function validateBuildConfig(config) {
50
+ const errors = [];
51
+ if (!isBuildOptions(config)) {
52
+ errors.push("Invalid build configuration object");
53
+ return { valid: false, errors };
54
+ }
55
+ if (config.target && !isValidTarget(config.target)) {
56
+ errors.push(
57
+ `Invalid target: ${config.target}. Must be 'browser', 'bun', or 'node'`
58
+ );
59
+ }
60
+ if (config.format && !isValidFormat(config.format)) {
61
+ errors.push(
62
+ `Invalid format: ${config.format}. Must be 'esm', 'cjs', or 'iife'`
63
+ );
64
+ }
65
+ if (config.sourcemap && !isValidSourcemap(config.sourcemap)) {
66
+ errors.push(
67
+ `Invalid sourcemap: ${config.sourcemap}. Must be 'none', 'linked', 'inline', or 'external'`
68
+ );
69
+ }
70
+ if (config.minify && !isMinifyOptions(config.minify)) {
71
+ errors.push(
72
+ "Invalid minify options. Must be boolean or object with whitespace, syntax, identifiers properties"
73
+ );
74
+ }
75
+ if (config.jsx && !isJSXOptions(config.jsx)) {
76
+ errors.push(
77
+ "Invalid JSX options. Must have runtime (automatic|classic) and optional importSource (string)"
78
+ );
79
+ }
80
+ if (config.naming && !isNamingOptions(config.naming)) {
81
+ errors.push(
82
+ "Invalid naming options. Must have chunk, entry, asset properties as strings"
83
+ );
84
+ }
85
+ if (config.external && !isStringOrStringArray(config.external)) {
86
+ errors.push(
87
+ "Invalid external packages. Must be string or array of strings"
88
+ );
89
+ }
90
+ if (config.drop && !isStringArray(config.drop)) {
91
+ errors.push("Invalid drop patterns. Must be array of strings");
92
+ }
93
+ if (config.conditions && !isStringOrStringArray(config.conditions)) {
94
+ errors.push("Invalid conditions. Must be string or array of strings");
95
+ }
96
+ if (config.packages && !isValidPackages(config.packages)) {
97
+ errors.push(
98
+ `Invalid packages: ${config.packages}. Must be 'bundle' or 'external'`
99
+ );
100
+ }
101
+ if (config.env && !isValidEnv(config.env)) {
102
+ errors.push(
103
+ 'Invalid env. Must be "inline", "disable", or string ending with "*"'
104
+ );
105
+ }
106
+ if (config.loader && typeof config.loader === "object") {
107
+ for (const [ext, loader] of Object.entries(config.loader)) {
108
+ if (!isValidLoader(loader)) {
109
+ errors.push(`Invalid loader for extension ${ext}: ${loader}`);
110
+ }
111
+ }
112
+ }
113
+ return { valid: errors.length === 0, errors };
114
+ }
115
+ export function sanitizeBuildConfig(config) {
116
+ const sanitized = {
117
+ ...config
118
+ };
119
+ if (sanitized.target && !isValidTarget(sanitized.target)) {
120
+ sanitized.target = "bun";
121
+ }
122
+ if (sanitized.format && !isValidFormat(sanitized.format)) {
123
+ sanitized.format = "esm";
124
+ }
125
+ if (sanitized.sourcemap && !isValidSourcemap(sanitized.sourcemap)) {
126
+ sanitized.sourcemap = "none";
127
+ }
128
+ if (sanitized.minify && !isMinifyOptions(sanitized.minify)) {
129
+ sanitized.minify = Boolean(sanitized.minify);
130
+ }
131
+ if (sanitized.external && !isStringOrStringArray(sanitized.external)) {
132
+ delete sanitized.external;
133
+ }
134
+ if (sanitized.drop && !isStringArray(sanitized.drop)) {
135
+ delete sanitized.drop;
136
+ }
137
+ if (sanitized.conditions && !isStringOrStringArray(sanitized.conditions)) {
138
+ delete sanitized.conditions;
139
+ }
140
+ if (sanitized.packages && !isValidPackages(sanitized.packages)) {
141
+ sanitized.packages = "bundle";
142
+ }
143
+ if (sanitized.env && !isValidEnv(sanitized.env)) {
144
+ sanitized.env = "disable";
145
+ }
146
+ return sanitized;
147
+ }
@@ -0,0 +1,322 @@
1
+ import type { GoBuildOptions, PackageBuildConfig, PerformanceBudget } from "@reliverse/config/impl/build";
2
+ import type { TSConfig } from "pkg-types";
3
+ export interface PackageInfo {
4
+ name: string;
5
+ path: string;
6
+ hasTsConfig: boolean;
7
+ entryPoints: string[];
8
+ outputDir: string;
9
+ buildConfig?: PackageBuildConfig;
10
+ isFrontendApp?: boolean;
11
+ hasHtmlEntry?: boolean;
12
+ hasPublicDir?: boolean;
13
+ private?: boolean;
14
+ isCLI?: boolean;
15
+ hasGoFiles?: boolean;
16
+ }
17
+ export interface MinifyOptions {
18
+ whitespace?: boolean;
19
+ syntax?: boolean;
20
+ identifiers?: boolean;
21
+ }
22
+ export interface JSXOptions {
23
+ runtime?: "automatic" | "classic";
24
+ importSource?: string;
25
+ }
26
+ export interface NamingOptions {
27
+ chunk?: string;
28
+ entry?: string;
29
+ asset?: string;
30
+ }
31
+ export interface BuildResult {
32
+ package: PackageInfo;
33
+ success: boolean;
34
+ skipped: boolean;
35
+ output: string;
36
+ errors: string[];
37
+ warnings: string[];
38
+ buildTime: number;
39
+ bundleSize?: number;
40
+ cacheHit?: boolean;
41
+ }
42
+ export interface BuildSummary {
43
+ totalPackages: number;
44
+ failedPackages: number;
45
+ successfulPackages: number;
46
+ skippedPackages: number;
47
+ hasErrors: boolean;
48
+ results: BuildResult[];
49
+ totalBuildTime: number;
50
+ totalBundleSize: number;
51
+ cacheHits: number;
52
+ }
53
+ export interface BuildOptions {
54
+ concurrency?: number;
55
+ stopOnError?: boolean;
56
+ verbose?: boolean;
57
+ watch?: boolean;
58
+ bundler?: "bun" | "mkdist";
59
+ target?: "browser" | "bun" | "node";
60
+ format?: "esm" | "cjs" | "iife";
61
+ minify?: boolean | MinifyOptions;
62
+ minifyWhitespace?: boolean;
63
+ minifySyntax?: boolean;
64
+ minifyIdentifiers?: boolean;
65
+ sourcemap?: "none" | "linked" | "inline" | "external" | boolean;
66
+ splitting?: boolean;
67
+ external?: string | string[];
68
+ bytecode?: boolean;
69
+ drop?: string[];
70
+ packages?: "bundle" | "external";
71
+ publicPath?: string;
72
+ root?: string;
73
+ define?: Record<string, string>;
74
+ naming?: NamingOptions;
75
+ env?: "inline" | "disable" | `${string}*`;
76
+ banner?: string;
77
+ footer?: string;
78
+ conditions?: string[];
79
+ loader?: Record<string, BunLoaderType>;
80
+ ignoreDCEAnnotations?: boolean;
81
+ emitDCEAnnotations?: boolean;
82
+ throw?: boolean;
83
+ jsx?: JSXOptions;
84
+ keepNames?: boolean;
85
+ production?: boolean;
86
+ dev?: boolean;
87
+ compile?: boolean;
88
+ cache?: boolean;
89
+ noCache?: boolean;
90
+ entryNaming?: string;
91
+ chunkNaming?: string;
92
+ assetNaming?: string;
93
+ noBundle?: boolean;
94
+ reactFastRefresh?: boolean;
95
+ noClearScreen?: boolean;
96
+ windowsHideConsole?: boolean;
97
+ windowsIcon?: string;
98
+ windowsTitle?: string;
99
+ windowsPublisher?: string;
100
+ windowsVersion?: string;
101
+ windowsDescription?: string;
102
+ windowsCopyright?: string;
103
+ app?: boolean;
104
+ serverComponents?: boolean;
105
+ debugDumpServerFiles?: boolean;
106
+ debugNoMinify?: boolean;
107
+ html?: boolean | HtmlOptions;
108
+ assets?: AssetOptions;
109
+ devServer?: boolean | DevServerOptions;
110
+ cssChunking?: boolean;
111
+ port?: number;
112
+ open?: boolean;
113
+ publicAssets?: string;
114
+ debug?: boolean;
115
+ experimental?: string[];
116
+ macros?: boolean;
117
+ sideEffects?: boolean | string[];
118
+ bundleAnalyzer?: boolean;
119
+ typeCheck?: boolean;
120
+ generateTypes?: boolean;
121
+ bundleSizeLimit?: number;
122
+ performanceBudget?: PerformanceBudget;
123
+ imageOptimization?: boolean;
124
+ fontOptimization?: boolean;
125
+ cssOptimization?: boolean;
126
+ svgAsReact?: boolean;
127
+ cssModules?: boolean;
128
+ workerSupport?: boolean;
129
+ plugins?: string[];
130
+ performanceMonitoring?: boolean;
131
+ bundleAnalysis?: boolean;
132
+ maxConfigDepth?: number;
133
+ kind?: "library" | "cli" | "browser-app" | "native-app";
134
+ bin?: string;
135
+ validateTsconfig?: boolean;
136
+ strictTsconfig?: boolean;
137
+ dtsProvider?: "dts-bundle-generator" | "api-extractor" | "typescript";
138
+ go?: GoBuildOptions;
139
+ replaceExports?: boolean;
140
+ replaceExportsIgnorePackages?: string;
141
+ allowPrivateBuild?: string | string[];
142
+ filter?: string | string[];
143
+ goOnly?: boolean;
144
+ tsOnly?: boolean;
145
+ }
146
+ export interface CacheEntry {
147
+ hash: string;
148
+ timestamp: number;
149
+ buildTime: number;
150
+ bundleSize: number;
151
+ outputFiles: string[];
152
+ }
153
+ export interface CacheOptions {
154
+ enabled: boolean;
155
+ directory: string;
156
+ ttl: number;
157
+ }
158
+ export type BunLoaderType = "js" | "jsx" | "ts" | "tsx" | "json" | "toml" | "file" | "napi" | "wasm" | "text";
159
+ export type Loader = MkdistLoader;
160
+ export interface BunPlugin {
161
+ name: string;
162
+ setup: (build: unknown) => void;
163
+ }
164
+ export interface BuildArtifact {
165
+ path: string;
166
+ loader: Loader;
167
+ hash: string | null;
168
+ kind: "entry-point" | "chunk" | "asset" | "sourcemap" | "bytecode";
169
+ sourcemap: BuildArtifact | null;
170
+ }
171
+ export interface BuildMessage {
172
+ name: "BuildMessage";
173
+ position: Position | null;
174
+ code: string;
175
+ message: string;
176
+ level: "error" | "warning" | "info" | "debug" | "verbose";
177
+ toString(): string;
178
+ }
179
+ export interface ResolveMessage {
180
+ name: "ResolveMessage";
181
+ position: Position | null;
182
+ code: string;
183
+ message: string;
184
+ referrer: string;
185
+ specifier: string;
186
+ importKind: "entry_point" | "stmt" | "require" | "import" | "dynamic" | "require_resolve" | "at" | "at_conditional" | "url" | "internal";
187
+ level: "error" | "warning" | "info" | "debug" | "verbose";
188
+ toString(): string;
189
+ }
190
+ export interface Position {
191
+ file: string;
192
+ line: number;
193
+ column: number;
194
+ }
195
+ export interface HtmlOptions {
196
+ entryPoints?: string[];
197
+ inject?: boolean;
198
+ minify?: boolean;
199
+ }
200
+ export interface AssetOptions {
201
+ publicPath?: string;
202
+ copyFiles?: string[];
203
+ imageOptimization?: boolean;
204
+ }
205
+ export interface DevServerOptions {
206
+ port?: number;
207
+ host?: string;
208
+ hmr?: boolean;
209
+ open?: boolean;
210
+ }
211
+ export interface DlerPlugin {
212
+ name: string;
213
+ setup: (build: BunBuildConfig) => void;
214
+ onBuildStart?: () => void;
215
+ onBuildEnd?: (result: BuildResult, buildOptions?: BuildOptions) => void;
216
+ onResolve?: (args: unknown) => unknown;
217
+ onLoad?: (args: unknown) => unknown;
218
+ }
219
+ export interface CompileOptions {
220
+ windowsHideConsole?: boolean;
221
+ windowsIcon?: string;
222
+ windowsTitle?: string;
223
+ windowsPublisher?: string;
224
+ windowsVersion?: string;
225
+ windowsDescription?: string;
226
+ windowsCopyright?: string;
227
+ }
228
+ export interface BunBuildConfig {
229
+ entrypoints: string[];
230
+ outdir: string;
231
+ target?: "browser" | "bun" | "node";
232
+ format?: "esm" | "cjs" | "iife";
233
+ sourcemap?: "none" | "linked" | "inline" | "external" | boolean;
234
+ splitting?: boolean;
235
+ external?: string[];
236
+ bytecode?: boolean;
237
+ drop?: string[];
238
+ packages?: "bundle" | "external";
239
+ publicPath?: string;
240
+ root?: string;
241
+ define?: Record<string, string>;
242
+ naming?: NamingOptions;
243
+ env?: "inline" | "disable" | `${string}*`;
244
+ banner?: string;
245
+ footer?: string;
246
+ conditions?: string[];
247
+ loader?: Record<string, BunLoaderType>;
248
+ ignoreDCEAnnotations?: boolean;
249
+ emitDCEAnnotations?: boolean;
250
+ throw?: boolean;
251
+ jsx?: JSXOptions;
252
+ keepNames?: boolean;
253
+ minify?: boolean | MinifyOptions;
254
+ plugins?: BunPlugin[];
255
+ noBundle?: boolean;
256
+ reactFastRefresh?: boolean;
257
+ noClearScreen?: boolean;
258
+ windowsHideConsole?: boolean;
259
+ windowsIcon?: string;
260
+ windowsTitle?: string;
261
+ windowsPublisher?: string;
262
+ windowsVersion?: string;
263
+ windowsDescription?: string;
264
+ windowsCopyright?: string;
265
+ app?: boolean;
266
+ serverComponents?: boolean;
267
+ debugDumpServerFiles?: boolean;
268
+ debugNoMinify?: boolean;
269
+ compile?: CompileOptions | boolean;
270
+ verbose?: boolean;
271
+ }
272
+ export interface MkdistOptions {
273
+ srcDir: string;
274
+ distDir: string;
275
+ rootDir: string;
276
+ format?: "esm" | "cjs";
277
+ ext?: string;
278
+ pattern?: string;
279
+ cleanDist?: boolean;
280
+ addRelativeDeclarationExtensions?: boolean;
281
+ typescript?: {
282
+ compilerOptions?: TSConfig["compilerOptions"];
283
+ };
284
+ globOptions?: Record<string, unknown>;
285
+ verbose?: boolean;
286
+ [key: string]: unknown;
287
+ }
288
+ export interface InputFile {
289
+ path: string;
290
+ srcPath: string;
291
+ extension: string;
292
+ getContents: () => Promise<string>;
293
+ }
294
+ export interface MkdistInputFile extends InputFile {
295
+ srcPath: string;
296
+ }
297
+ export interface OutputFile {
298
+ path: string;
299
+ srcPath: string;
300
+ contents?: string;
301
+ extension?: string;
302
+ declaration?: boolean;
303
+ skip?: boolean;
304
+ raw?: boolean;
305
+ errors?: TypeError[];
306
+ }
307
+ export type LoaderName = "js";
308
+ export interface CreateLoaderOptions {
309
+ loaders?: (LoaderName | Loader)[];
310
+ declaration?: boolean;
311
+ format?: "esm" | "cjs";
312
+ ext?: string;
313
+ esbuild?: Record<string, unknown>;
314
+ [key: string]: unknown;
315
+ }
316
+ export interface LoaderContext {
317
+ loadFile: LoadFile;
318
+ options: CreateLoaderOptions;
319
+ }
320
+ export type LoadFile = (input: InputFile) => Promise<OutputFile[] | undefined>;
321
+ export type MkdistLoader = (input: InputFile, context: LoaderContext) => Promise<OutputFile[] | undefined>;
322
+ export type LoaderResult = OutputFile[];
File without changes
@@ -0,0 +1,12 @@
1
+ import type { BuildOptions, PackageInfo } from "../types.js";
2
+ /**
3
+ * Handle Go build for a package if applicable
4
+ */
5
+ export declare function handleGoBuild(pkg: PackageInfo, options: BuildOptions, verbose: boolean): Promise<void>;
6
+ /**
7
+ * Handle Go-only build mode
8
+ */
9
+ export declare function handleGoOnlyBuild(pkg: PackageInfo, options: BuildOptions): Promise<{
10
+ success: boolean;
11
+ errors: string[];
12
+ }>;