@adddog/build-configs 0.0.1

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.
@@ -0,0 +1,631 @@
1
+ const libraryPresets = {
2
+ "library-esm": {
3
+ name: "library-esm",
4
+ description: "Modern ESM-only library",
5
+ bundler: "both",
6
+ tsup: {
7
+ format: ["esm"],
8
+ target: "es2022",
9
+ dts: {
10
+ resolve: true
11
+ }
12
+ },
13
+ unbuild: {
14
+ rollup: {
15
+ emitCJS: false
16
+ }
17
+ }
18
+ },
19
+ "library-dual": {
20
+ name: "library-dual",
21
+ description: "Library with both ESM and CJS outputs",
22
+ bundler: "both",
23
+ tsup: {
24
+ format: ["esm", "cjs"],
25
+ target: "node18",
26
+ dts: {
27
+ resolve: true
28
+ }
29
+ },
30
+ unbuild: {
31
+ rollup: {
32
+ emitCJS: true
33
+ },
34
+ declaration: "compatible"
35
+ }
36
+ },
37
+ "library-browser": {
38
+ name: "library-browser",
39
+ description: "Browser-compatible library",
40
+ bundler: "tsup",
41
+ tsup: {
42
+ format: ["esm", "cjs", "iife"],
43
+ platform: "browser",
44
+ target: "es2020",
45
+ globalName: "MyLib",
46
+ dts: {
47
+ resolve: true
48
+ },
49
+ minify: true
50
+ }
51
+ },
52
+ "library-unbundled": {
53
+ name: "library-unbundled",
54
+ description: "Library with file-to-file transpilation (mkdist)",
55
+ bundler: "unbuild",
56
+ unbuild: {
57
+ entries: [
58
+ "src/index",
59
+ {
60
+ builder: "mkdist",
61
+ input: "src/",
62
+ outDir: "dist/"
63
+ }
64
+ ]
65
+ }
66
+ },
67
+ "library-monorepo": {
68
+ name: "library-monorepo",
69
+ description: "Optimized for monorepo internal packages",
70
+ bundler: "both",
71
+ tsup: {
72
+ format: ["esm"],
73
+ dts: true,
74
+ sourcemap: true,
75
+ clean: true,
76
+ skipNodeModulesBundle: true
77
+ },
78
+ unbuild: {
79
+ rollup: {
80
+ emitCJS: false,
81
+ inlineDependencies: false
82
+ },
83
+ sourcemap: true
84
+ }
85
+ }
86
+ };
87
+
88
+ const cliPresets = {
89
+ "cli-simple": {
90
+ name: "cli-simple",
91
+ description: "Simple CLI tool with single entry point",
92
+ bundler: "both",
93
+ tsup: {
94
+ entry: ["src/cli.ts"],
95
+ format: ["esm"],
96
+ target: "node18",
97
+ platform: "node",
98
+ dts: false,
99
+ // CLIs don't need type definitions
100
+ clean: true,
101
+ minify: false,
102
+ shims: true
103
+ // Add CJS/ESM shims for compatibility
104
+ },
105
+ unbuild: {
106
+ entries: ["src/cli"],
107
+ declaration: false,
108
+ rollup: {
109
+ emitCJS: false
110
+ }
111
+ }
112
+ },
113
+ "cli-multi": {
114
+ name: "cli-multi",
115
+ description: "CLI tool with multiple commands",
116
+ bundler: "both",
117
+ tsup: {
118
+ entry: {
119
+ cli: "src/cli.ts",
120
+ index: "src/index.ts"
121
+ },
122
+ format: ["esm", "cjs"],
123
+ target: "node18",
124
+ platform: "node",
125
+ dts: true,
126
+ // Include types for programmatic usage
127
+ clean: true,
128
+ splitting: false
129
+ },
130
+ unbuild: {
131
+ entries: ["src/cli", "src/index"],
132
+ declaration: true,
133
+ rollup: {
134
+ emitCJS: true
135
+ }
136
+ }
137
+ },
138
+ "cli-bundled": {
139
+ name: "cli-bundled",
140
+ description: "CLI tool with all dependencies bundled",
141
+ bundler: "tsup",
142
+ tsup: {
143
+ entry: ["src/cli.ts"],
144
+ format: ["esm"],
145
+ target: "node18",
146
+ platform: "node",
147
+ dts: false,
148
+ bundle: true,
149
+ skipNodeModulesBundle: false,
150
+ // Bundle everything
151
+ noExternal: [/.*/],
152
+ // Include all dependencies
153
+ minify: true,
154
+ treeshake: true
155
+ }
156
+ }
157
+ };
158
+
159
+ const componentPresets = {
160
+ "react-component": {
161
+ name: "react-component",
162
+ description: "React component library",
163
+ bundler: "both",
164
+ tsup: {
165
+ entry: ["src/index.ts"],
166
+ format: ["esm", "cjs"],
167
+ target: "es2020",
168
+ platform: "browser",
169
+ dts: {
170
+ resolve: true
171
+ },
172
+ external: ["react", "react-dom"],
173
+ sourcemap: true,
174
+ clean: true,
175
+ splitting: false
176
+ },
177
+ unbuild: {
178
+ entries: [
179
+ "src/index",
180
+ {
181
+ builder: "mkdist",
182
+ input: "src/components/",
183
+ outDir: "dist/components/"
184
+ }
185
+ ],
186
+ externals: ["react", "react-dom"],
187
+ rollup: {
188
+ emitCJS: true
189
+ }
190
+ }
191
+ },
192
+ "vue-component": {
193
+ name: "vue-component",
194
+ description: "Vue component library",
195
+ bundler: "unbuild",
196
+ unbuild: {
197
+ entries: [
198
+ "src/index",
199
+ {
200
+ builder: "mkdist",
201
+ input: "src/components/",
202
+ outDir: "dist/components/"
203
+ }
204
+ ],
205
+ externals: ["vue"],
206
+ rollup: {
207
+ emitCJS: false
208
+ }
209
+ }
210
+ },
211
+ "web-component": {
212
+ name: "web-component",
213
+ description: "Framework-agnostic web components",
214
+ bundler: "tsup",
215
+ tsup: {
216
+ entry: ["src/index.ts"],
217
+ format: ["esm", "iife"],
218
+ target: "es2020",
219
+ platform: "browser",
220
+ dts: {
221
+ resolve: true
222
+ },
223
+ globalName: "WebComponents",
224
+ minify: true,
225
+ sourcemap: true
226
+ }
227
+ },
228
+ "design-system": {
229
+ name: "design-system",
230
+ description: "Design system with components and tokens",
231
+ bundler: "unbuild",
232
+ unbuild: {
233
+ entries: [
234
+ "src/index",
235
+ {
236
+ builder: "mkdist",
237
+ input: "src/components/",
238
+ outDir: "dist/components/"
239
+ },
240
+ {
241
+ builder: "mkdist",
242
+ input: "src/tokens/",
243
+ outDir: "dist/tokens/"
244
+ }
245
+ ],
246
+ rollup: {
247
+ emitCJS: true
248
+ },
249
+ declaration: "compatible"
250
+ }
251
+ }
252
+ };
253
+
254
+ const completePresets = {
255
+ "complete-tsup": {
256
+ name: "complete-tsup",
257
+ description: "Complete tsup config with all options defined",
258
+ bundler: "tsup",
259
+ tsup: {
260
+ // Entry configuration
261
+ entry: ["src/index.ts"],
262
+ // Output configuration
263
+ outDir: "dist",
264
+ format: ["esm", "cjs"],
265
+ legacyOutput: false,
266
+ // Target and platform
267
+ target: "node18",
268
+ platform: "node",
269
+ // TypeScript declarations
270
+ dts: {
271
+ resolve: true,
272
+ only: false,
273
+ compilerOptions: {
274
+ strict: true
275
+ }
276
+ },
277
+ // Source maps
278
+ sourcemap: true,
279
+ // Bundling behavior
280
+ bundle: true,
281
+ splitting: false,
282
+ skipNodeModulesBundle: true,
283
+ // Optimization
284
+ minify: false,
285
+ minifyWhitespace: false,
286
+ minifyIdentifiers: false,
287
+ minifySyntax: false,
288
+ keepNames: true,
289
+ treeshake: true,
290
+ // Build control
291
+ clean: true,
292
+ watch: false,
293
+ silent: false,
294
+ // Dependencies
295
+ external: [/node_modules/],
296
+ noExternal: [],
297
+ // Code transformation
298
+ shims: false,
299
+ cjsInterop: false,
300
+ replaceNodeEnv: false,
301
+ removeNodeProtocol: true,
302
+ // Advanced
303
+ metafile: false,
304
+ publicDir: false
305
+ }
306
+ },
307
+ "complete-unbuild": {
308
+ name: "complete-unbuild",
309
+ description: "Complete unbuild config with all options defined",
310
+ bundler: "unbuild",
311
+ unbuild: {
312
+ // Entry configuration
313
+ entries: ["src/index"],
314
+ // Output configuration
315
+ outDir: "dist",
316
+ // Build behavior
317
+ clean: true,
318
+ stub: false,
319
+ watch: false,
320
+ parallel: true,
321
+ // TypeScript declarations
322
+ declaration: "compatible",
323
+ // Source maps
324
+ sourcemap: true,
325
+ // Build control
326
+ failOnWarn: false,
327
+ // Dependencies
328
+ externals: [],
329
+ // Code transformation
330
+ alias: {},
331
+ replace: {},
332
+ // Rollup configuration
333
+ rollup: {
334
+ // Output format
335
+ emitCJS: false,
336
+ cjsBridge: false,
337
+ // Bundling
338
+ inlineDependencies: false,
339
+ preserveDynamicImports: false,
340
+ // Esbuild options
341
+ esbuild: {
342
+ target: "node18",
343
+ minify: false,
344
+ tsconfigRaw: {
345
+ compilerOptions: {
346
+ strict: true,
347
+ experimentalDecorators: false
348
+ }
349
+ }
350
+ },
351
+ // Plugins (set to false to disable)
352
+ replace: {},
353
+ alias: {},
354
+ resolve: {
355
+ extensions: [".mjs", ".js", ".json", ".ts"]
356
+ },
357
+ json: {},
358
+ commonjs: {
359
+ requireReturnsDefault: "auto"
360
+ }
361
+ },
362
+ // Stub options
363
+ stubOptions: {
364
+ jiti: {
365
+ interopDefault: true
366
+ }
367
+ }
368
+ }
369
+ },
370
+ "complete-tsup-full": {
371
+ name: "complete-tsup-full",
372
+ description: "Exhaustive tsup config with every possible option",
373
+ bundler: "tsup",
374
+ tsup: {
375
+ // === Entry Configuration ===
376
+ entry: ["src/index.ts"],
377
+ // === Output Configuration ===
378
+ outDir: "dist",
379
+ format: ["esm", "cjs", "iife"],
380
+ legacyOutput: false,
381
+ globalName: "MyLib",
382
+ // === Target and Platform ===
383
+ target: ["es2020", "node18"],
384
+ platform: "neutral",
385
+ // === TypeScript Declarations ===
386
+ dts: {
387
+ resolve: true,
388
+ only: false,
389
+ banner: "// TypeScript declarations",
390
+ footer: "// End of declarations",
391
+ compilerOptions: {
392
+ strict: true,
393
+ skipLibCheck: true
394
+ }
395
+ },
396
+ // === Source Maps ===
397
+ sourcemap: true,
398
+ // === Bundling Behavior ===
399
+ bundle: true,
400
+ splitting: true,
401
+ skipNodeModulesBundle: false,
402
+ // === Optimization ===
403
+ minify: "terser",
404
+ terserOptions: {
405
+ compress: {
406
+ drop_console: false,
407
+ drop_debugger: true
408
+ },
409
+ mangle: {
410
+ keep_classnames: true,
411
+ keep_fnames: true
412
+ }
413
+ },
414
+ minifyWhitespace: true,
415
+ minifyIdentifiers: true,
416
+ minifySyntax: true,
417
+ keepNames: false,
418
+ treeshake: "recommended",
419
+ // === Build Control ===
420
+ clean: ["dist/**/*"],
421
+ watch: false,
422
+ ignoreWatch: ["**/__tests__/**", "**/*.test.ts"],
423
+ silent: false,
424
+ // === Dependencies ===
425
+ external: [/^node:/, /^@types\//],
426
+ noExternal: ["some-package"],
427
+ // === Code Transformation ===
428
+ define: {
429
+ __VERSION__: JSON.stringify("1.0.0"),
430
+ "process.env.NODE_ENV": JSON.stringify("production")
431
+ },
432
+ env: {
433
+ NODE_ENV: "production"
434
+ },
435
+ inject: [],
436
+ banner: {
437
+ js: "/* My Library Banner */"
438
+ },
439
+ footer: {
440
+ js: "/* End of Library */"
441
+ },
442
+ shims: true,
443
+ cjsInterop: true,
444
+ replaceNodeEnv: true,
445
+ removeNodeProtocol: false,
446
+ // === Advanced ===
447
+ tsconfig: "tsconfig.build.json",
448
+ metafile: true,
449
+ publicDir: "public",
450
+ pure: ["console.log"],
451
+ loader: {
452
+ ".txt": "text",
453
+ ".png": "base64"
454
+ },
455
+ // === CSS (experimental) ===
456
+ injectStyle: false,
457
+ // === JSX ===
458
+ jsxFactory: "React.createElement",
459
+ jsxFragment: "React.Fragment"
460
+ }
461
+ },
462
+ "complete-unbuild-full": {
463
+ name: "complete-unbuild-full",
464
+ description: "Exhaustive unbuild config with every possible option",
465
+ bundler: "unbuild",
466
+ unbuild: {
467
+ // === Project Configuration ===
468
+ name: "my-package",
469
+ rootDir: process.cwd(),
470
+ // === Entry Configuration ===
471
+ entries: [
472
+ "src/index",
473
+ {
474
+ builder: "rollup",
475
+ input: "src/main",
476
+ name: "main"
477
+ },
478
+ {
479
+ builder: "mkdist",
480
+ input: "src/components/",
481
+ outDir: "dist/components/",
482
+ format: "esm",
483
+ ext: "mjs"
484
+ }
485
+ ],
486
+ // === Output Configuration ===
487
+ outDir: "dist",
488
+ // === Build Behavior ===
489
+ clean: true,
490
+ stub: false,
491
+ watch: false,
492
+ watchOptions: {
493
+ exclude: ["node_modules/**", "dist/**"]
494
+ },
495
+ parallel: true,
496
+ // === TypeScript Declarations ===
497
+ declaration: "node16",
498
+ // === Source Maps ===
499
+ sourcemap: true,
500
+ // === Build Control ===
501
+ failOnWarn: false,
502
+ // === Dependencies ===
503
+ externals: [/^node:/, "external-pkg"],
504
+ dependencies: [],
505
+ peerDependencies: [],
506
+ devDependencies: [],
507
+ // === Code Transformation ===
508
+ alias: {
509
+ "@": "./src",
510
+ "@utils": "./src/utils"
511
+ },
512
+ replace: {
513
+ __VERSION__: "1.0.0",
514
+ "process.env.NODE_ENV": "production"
515
+ },
516
+ // === Rollup Configuration ===
517
+ rollup: {
518
+ // Output format
519
+ emitCJS: true,
520
+ cjsBridge: true,
521
+ // Bundling
522
+ inlineDependencies: false,
523
+ preserveDynamicImports: false,
524
+ watch: false,
525
+ // Output options
526
+ output: {
527
+ banner: "/* My Library */",
528
+ footer: "/* End */",
529
+ exports: "auto",
530
+ interop: "auto"
531
+ },
532
+ // Esbuild options
533
+ esbuild: {
534
+ target: "es2020",
535
+ minify: true,
536
+ minifyWhitespace: true,
537
+ minifyIdentifiers: true,
538
+ minifySyntax: true,
539
+ tsconfigRaw: {
540
+ compilerOptions: {
541
+ strict: true,
542
+ experimentalDecorators: true
543
+ }
544
+ }
545
+ },
546
+ // Plugin configurations
547
+ replace: {
548
+ preventAssignment: true,
549
+ values: {
550
+ "process.env.NODE_ENV": JSON.stringify("production")
551
+ }
552
+ },
553
+ alias: {
554
+ entries: [
555
+ { find: "@", replacement: "./src" }
556
+ ]
557
+ },
558
+ resolve: {
559
+ extensions: [".mjs", ".js", ".json", ".ts"],
560
+ browser: false,
561
+ preferBuiltins: true
562
+ },
563
+ json: {
564
+ compact: false,
565
+ namedExports: true,
566
+ preferConst: true
567
+ },
568
+ commonjs: {
569
+ include: /node_modules/,
570
+ requireReturnsDefault: "auto",
571
+ esmExternals: true,
572
+ transformMixedEsModules: true
573
+ },
574
+ dts: {
575
+ respectExternal: true
576
+ }
577
+ },
578
+ // === Stub Options ===
579
+ stubOptions: {
580
+ jiti: {
581
+ interopDefault: true,
582
+ cache: true,
583
+ requireCache: false,
584
+ transformOptions: {}
585
+ },
586
+ absoluteJitiPath: false
587
+ },
588
+ // === Hooks ===
589
+ hooks: {
590
+ "build:prepare": async (_ctx) => {
591
+ console.log("Preparing build...");
592
+ },
593
+ "build:before": async (_ctx) => {
594
+ console.log("Starting build...");
595
+ },
596
+ "build:done": async (_ctx) => {
597
+ console.log("Build complete!");
598
+ }
599
+ }
600
+ }
601
+ }
602
+ };
603
+
604
+ const presets = {
605
+ ...libraryPresets,
606
+ ...cliPresets,
607
+ ...componentPresets,
608
+ ...completePresets
609
+ };
610
+ function getPreset(name) {
611
+ return presets[name];
612
+ }
613
+ function listPresets() {
614
+ return Object.keys(presets);
615
+ }
616
+ function getPresetsByBundler(bundler) {
617
+ return Object.fromEntries(
618
+ Object.entries(presets).filter(
619
+ ([, preset]) => preset.bundler === bundler || preset.bundler === "both"
620
+ )
621
+ );
622
+ }
623
+ const presetCategories = {
624
+ library: libraryPresets,
625
+ cli: cliPresets,
626
+ component: componentPresets,
627
+ complete: completePresets
628
+ };
629
+
630
+ export { getPreset, getPresetsByBundler, listPresets, presetCategories, presets };
631
+ //# sourceMappingURL=index.mjs.map