auklet 0.0.18 → 0.0.20

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 (93) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +255 -174
  3. package/bin/entry.mjs +5 -0
  4. package/dist/build/bundleConfig.js +1 -1
  5. package/dist/build/cliOverrides.d.ts +22 -0
  6. package/dist/build/cliOverrides.js +22 -0
  7. package/dist/build/moduleConfig.js +1 -1
  8. package/dist/build/runTsdown.d.ts +2 -0
  9. package/dist/build/runTsdown.js +4 -3
  10. package/dist/build/tsdown/common.d.ts +2 -2
  11. package/dist/build/tsdown/context.d.ts +2 -1
  12. package/dist/build/tsdown/context.js +2 -1
  13. package/dist/build/tsdown/define.js +3 -2
  14. package/dist/build/tsdown/dependencies.js +3 -1
  15. package/dist/build/tsdown/entries.d.ts +2 -2
  16. package/dist/build/tsdown/entries.js +10 -10
  17. package/dist/build/tsdown/types.d.ts +1 -0
  18. package/dist/cli/build.d.ts +5 -0
  19. package/dist/cli/build.js +30 -0
  20. package/dist/cli/buildArgs.d.ts +8 -0
  21. package/dist/cli/buildArgs.js +114 -0
  22. package/dist/cli/buildCss.d.ts +12 -0
  23. package/dist/cli/buildCss.js +53 -0
  24. package/dist/cli/dev.d.ts +1 -0
  25. package/dist/cli/dev.js +39 -0
  26. package/dist/cli/main.d.ts +1 -0
  27. package/dist/cli/main.js +95 -0
  28. package/dist/cli/publish.d.ts +2 -0
  29. package/dist/cli/publish.js +9 -0
  30. package/dist/css/production/buildReporter.d.ts +3 -0
  31. package/dist/css/production/buildReporter.js +19 -0
  32. package/dist/css/production/builder.d.ts +8 -3
  33. package/dist/css/production/builder.js +9 -13
  34. package/dist/css/vite/hmr.js +7 -6
  35. package/dist/css/vite/moduleGraph/graph.js +0 -1
  36. package/dist/css/vite/moduleGraph/packageSource/monorepo.d.ts +5 -1
  37. package/dist/css/vite/moduleGraph/packageSource/monorepo.js +40 -31
  38. package/dist/css/vite/moduleGraph/types.d.ts +0 -1
  39. package/dist/css/watch/watcher.d.ts +0 -1
  40. package/dist/css/watch/watcher.js +3 -10
  41. package/dist/index.d.ts +5 -7
  42. package/dist/index.js +4 -5
  43. package/dist/logger.d.ts +5 -0
  44. package/dist/logger.js +14 -0
  45. package/dist/publish/api/gitApi.d.ts +7 -0
  46. package/dist/publish/api/gitApi.js +55 -0
  47. package/dist/publish/api/packageJsonApi.d.ts +7 -0
  48. package/dist/publish/api/packageJsonApi.js +34 -0
  49. package/dist/publish/api/pnpmApi.d.ts +9 -0
  50. package/dist/publish/api/pnpmApi.js +85 -0
  51. package/dist/publish/api/pnpmPublishApi.d.ts +4 -0
  52. package/dist/publish/api/pnpmPublishApi.js +7 -0
  53. package/dist/publish/api/publishArgs.d.ts +2 -0
  54. package/dist/publish/api/publishArgs.js +25 -0
  55. package/dist/publish/api/publishHookApi.d.ts +10 -0
  56. package/dist/publish/api/publishHookApi.js +52 -0
  57. package/dist/publish/cli.d.ts +2 -0
  58. package/dist/publish/cli.js +94 -0
  59. package/dist/publish/ownerRunner.d.ts +6 -0
  60. package/dist/publish/ownerRunner.js +22 -0
  61. package/dist/publish/publishRunner.d.ts +16 -0
  62. package/dist/publish/publishRunner.js +108 -0
  63. package/dist/publish/runner/packageBuilder.d.ts +4 -0
  64. package/dist/publish/runner/packageBuilder.js +15 -0
  65. package/dist/publish/runner/packagePublisher.d.ts +7 -0
  66. package/dist/publish/runner/packagePublisher.js +21 -0
  67. package/dist/publish/runner/publishFailureReporter.d.ts +3 -0
  68. package/dist/publish/runner/publishFailureReporter.js +14 -0
  69. package/dist/publish/runner/publishOutputFormatter.d.ts +2 -0
  70. package/dist/publish/runner/publishOutputFormatter.js +83 -0
  71. package/dist/publish/runner/publishPreflight.d.ts +8 -0
  72. package/dist/publish/runner/publishPreflight.js +26 -0
  73. package/dist/publish/runner/publishSummaryReporter.d.ts +10 -0
  74. package/dist/publish/runner/publishSummaryReporter.js +81 -0
  75. package/dist/publish/runner/publishTargetError.d.ts +9 -0
  76. package/dist/publish/runner/publishTargetError.js +14 -0
  77. package/dist/publish/runner/releaseGitController.d.ts +10 -0
  78. package/dist/publish/runner/releaseGitController.js +41 -0
  79. package/dist/publish/runner/versionWriter.d.ts +13 -0
  80. package/dist/publish/runner/versionWriter.js +78 -0
  81. package/dist/publish/targetResolver.d.ts +7 -0
  82. package/dist/publish/targetResolver.js +195 -0
  83. package/dist/publish/types.d.ts +70 -0
  84. package/dist/publish/types.js +0 -0
  85. package/dist/publish/version.d.ts +5 -0
  86. package/dist/publish/version.js +55 -0
  87. package/dist/types.d.ts +8 -7
  88. package/dist/workspace/packages.d.ts +9 -0
  89. package/dist/workspace/packages.js +62 -0
  90. package/dist/workspace/root.d.ts +1 -0
  91. package/dist/workspace/root.js +14 -0
  92. package/package.json +15 -6
  93. package/bin/entry.cjs +0 -163
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026-present, chentao.arthur.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md CHANGED
@@ -5,47 +5,133 @@
5
5
 
6
6
  </div>
7
7
 
8
- <h1></h1>
8
+ auklet is a build tool for TypeScript packages. It wraps `tsdown` for
9
+ JavaScript output, generates CSS style entries for package/module/theme output,
10
+ provides module CSS auto imports, and includes a Vite dev plugin for virtual
11
+ package CSS.
9
12
 
10
- Build utilities for TypeScript packages and module CSS output.
13
+ It is designed for:
11
14
 
12
- ## Features
15
+ - single-package TypeScript libraries;
16
+ - single-package component libraries;
17
+ - pnpm monorepo TypeScript libraries;
18
+ - pnpm monorepo component packages.
13
19
 
14
- - Build JavaScript/TypeScript package output with the bundled tsdown config.
15
- - Generate package-level and module-level CSS entries.
16
- - Infer component style dependencies from source imports.
17
- - Generate theme and external style entry files.
18
- - Provide a Vite dev plugin for virtual package CSS entries in single-package and monorepo projects.
19
- - Watch source/config changes and rebuild module CSS output.
20
-
21
- ## Requirements
20
+ Requirements:
22
21
 
23
22
  - Node.js `>=22`
23
+ - pnpm for publish and owner workflows
24
+
25
+ ## Quick Start
26
+
27
+ `auklet.config.ts` is optional. Without it, auklet uses `src` as source,
28
+ `dist` as output, no module output, and default JavaScript formats.
29
+
30
+ For a component package, a minimal config usually looks like this:
31
+
32
+ ```ts
33
+ import type { AukletConfig } from 'auklet';
34
+
35
+ export const config: AukletConfig = {
36
+ modules: true,
37
+ };
38
+ ```
39
+
40
+ Build JavaScript and CSS output:
41
+
42
+ ```bash
43
+ auk build
44
+ ```
45
+
46
+ Import generated CSS entries from the package:
47
+
48
+ ```ts
49
+ import '@scope/ui/style.css';
50
+ import '@scope/ui/components/Button.css';
51
+ ```
52
+
53
+ Use the Vite plugin during local development:
54
+
55
+ ```ts
56
+ import { aukletStylePlugin } from 'auklet';
57
+
58
+ export default {
59
+ plugins: [aukletStylePlugin()],
60
+ };
61
+ ```
24
62
 
25
63
  ## CLI
26
64
 
27
- The package exposes both `auk` and `auklet` commands.
65
+ The package exposes both `auk` and `auklet`.
66
+
67
+ | Command | Description |
68
+ | ----------------------- | --------------------------------------------------------------------- |
69
+ | `auk dev` | Watch JavaScript and CSS output together. |
70
+ | `auk build` | Remove configured output, then build JavaScript and CSS. |
71
+ | `auk build-js` | Run tsdown with auklet's built-in config unless `--config` is passed. |
72
+ | `auk build-js --watch` | Pass watch mode through to tsdown. |
73
+ | `auk build-css` | Generate CSS output only. |
74
+ | `auk build-css --watch` | Watch source/config/style files and rebuild CSS. |
75
+ | `auk publish` | Run the pnpm-based publish workflow. |
76
+ | `auk owner add <user>` | Add npm owners through pnpm. |
77
+
78
+ Build and dev commands can override package config for one run:
28
79
 
29
80
  ```bash
30
- pnpm auk --help
31
- pnpm auk build
32
- pnpm auk build-js
33
- pnpm auk build-css
34
- pnpm auk build-css --watch
35
- pnpm auk dev
81
+ auk build --source source --output build --modules
82
+ auk build --build.formats esm,cjs
83
+ auk build --build.target es2022
84
+ auk build --build.platform node
85
+ auk build --build.tsconfig tsconfig.build.json
36
86
  ```
37
87
 
38
- Commands:
88
+ Supported build override flags:
89
+
90
+ | Flag | Description |
91
+ | ----------------------------- | -------------------------------------------- |
92
+ | `--source <dir>` | Source directory. |
93
+ | `--output <dir>` | Output directory. |
94
+ | `--modules` | Enable unbundled module output. |
95
+ | `--no-modules` | Disable unbundled module output. |
96
+ | `--build.formats <formats>` | Comma-separated `cjs`, `esm`, and/or `iife`. |
97
+ | `--build.target <target>` | JavaScript target passed to tsdown. |
98
+ | `--build.platform <platform>` | `node`, `neutral`, or `browser`. |
99
+ | `--build.tsconfig <file>` | TypeScript config file. |
39
100
 
40
- - `build` removes the configured `output` directory, builds JavaScript output, then builds CSS output.
41
- - `build-js` runs tsdown with the default auklet tsdown config unless a config flag is passed.
42
- - `build-css` generates module CSS output.
43
- - `build-css --watch` watches source/config files and rebuilds CSS.
44
- - `dev` runs JavaScript and CSS watch tasks together.
101
+ Config precedence:
102
+
103
+ ```text
104
+ CLI flags > auklet.config.ts > auklet defaults
105
+ ```
106
+
107
+ `build-js` passes unknown flags through to tsdown. Auklet build override flags
108
+ cannot be combined with tsdown custom config flags:
109
+
110
+ ```bash
111
+ # not allowed
112
+ auk build-js --source source --config tsdown.config.ts
113
+ auk build-js --output build -c tsdown.config.ts
114
+ auk build-js --modules --no-config
115
+ ```
116
+
117
+ When `--config`, `-c`, or `--no-config` is used, tsdown owns the full build
118
+ config. Use `auklet.config.ts` or tsdown config code directly instead of auklet
119
+ CLI overrides.
120
+
121
+ Publish controls stay on CLI flags:
122
+
123
+ ```bash
124
+ auk publish --filter @scope/ui
125
+ auk publish --version patch --dry-run
126
+ auk publish --no-format
127
+ ```
128
+
129
+ `--no-format` disables auklet's publish output formatter for that run. It is not
130
+ configured in `package.json`.
45
131
 
46
132
  ## Configuration
47
133
 
48
- Create `auklet.config.ts` in the package root:
134
+ `auklet.config.ts` is loaded from the current package root:
49
135
 
50
136
  ```ts
51
137
  import type { AukletConfig } from 'auklet';
@@ -54,7 +140,9 @@ export const config: AukletConfig = {
54
140
  source: 'src',
55
141
  output: 'dist',
56
142
  modules: true,
57
- tsconfig: 'tsconfig.json',
143
+ build: {
144
+ formats: ['esm', 'cjs'],
145
+ },
58
146
  styles: {
59
147
  themes: {
60
148
  light: './src/themes/light.css',
@@ -65,115 +153,126 @@ export const config: AukletConfig = {
65
153
  entry: '/style.css',
66
154
  components: ['/components/**.css'],
67
155
  },
68
- '@scope/theme': {
69
- entry: '/style.css',
70
- themes: {
71
- light: '/themes/light.css',
72
- dark: '/themes/dark.css',
73
- },
74
- },
75
- },
76
- },
77
- build: {
78
- alias: { ... },
79
- globals: { ... },
80
- target: 'es2020',
81
- formats: ['esm', 'cjs'],
82
- mainFields: ['browser', 'module', 'main'],
83
- configureTsdown(config, context) {
84
- if (context.kind !== 'bundle') return config;
85
- return {
86
- ...config,
87
- sourcemap: true,
88
- };
89
156
  },
90
157
  },
91
158
  };
92
159
  ```
93
160
 
94
- ### Style Options
161
+ Configuration reference:
162
+
163
+ | Path | Default | Description |
164
+ | ------------------------------------- | ------------------------ | --------------------------------------------------------------------------------------------------------------------------- |
165
+ | `source` | `'src'` | Source directory relative to the current package root. |
166
+ | `output` | `'dist'` | Build output directory. `auk build` removes it before rebuilding. |
167
+ | `modules` | `false` | Generate unbundled module JS output and module-level CSS output. |
168
+ | `styles.themes` | `{}` | Current package theme entries, keyed by theme name. Values are paths relative to the current package root. |
169
+ | `styles.dependencies` | `{}` | External package style rules, keyed by dependency package name. |
170
+ | `styles.dependencies[pkg].entry` | `undefined` | Package-level style entry or entries from the dependency package. |
171
+ | `styles.dependencies[pkg].themes` | `undefined` | Theme entries from the dependency package, keyed by current package theme name. |
172
+ | `styles.dependencies[pkg].components` | `undefined` | Module CSS auto import rules. The name is historical; rules can point to paths such as `/pages/**.css` or `/blocks/**.css`. |
173
+ | `build.formats` | `['cjs', 'esm', 'iife']` | Package-level bundle formats. |
174
+ | `build.target` | `'es2020'` | JavaScript target passed to tsdown. |
175
+ | `build.platform` | `'neutral'` | Runtime platform: `node`, `neutral`, or `browser`. |
176
+ | `build.banner` | generated | Custom bundle banner. |
177
+ | `build.externals` | `[]` | Extra external package names combined with package dependencies. |
178
+ | `build.alias` | `{}` | Path aliases passed to tsdown. |
179
+ | `build.mainFields` | IIFE only | Package entry field resolution order for bundle output. |
180
+ | `build.globals` | `{}` | Global names for IIFE externals. |
181
+ | `build.tsconfig` | nearest `tsconfig.json` | TypeScript config path relative to package root. |
182
+ | `build.configureTsdown` | `undefined` | Final hook for each generated tsdown config. |
183
+
184
+ Common dependency rule:
95
185
 
96
- - `source`: source directory relative to the package root. Defaults to `src`.
97
- - `output`: build output directory relative to the package root. Defaults to `dist`. `auk build` removes this directory before writing JavaScript and CSS output.
98
- - `styles.themes`: package theme style entries. Defaults to `{}`.
99
- - `styles.dependencies`: external package style dependencies. Defaults to `{}`.
186
+ ```ts
187
+ {
188
+ entry: '/style.css',
189
+ components: ['/pages/**.css', '/components/**.css'],
190
+ themes: {
191
+ dark: '/themes/dark.css',
192
+ light: '/themes/light.css',
193
+ },
194
+ }
195
+ ```
100
196
 
101
- Each `styles.dependencies` entry may define:
197
+ `configureTsdown` receives the generated tsdown config and a context:
102
198
 
103
- - `entry`: package-level style dependency.
104
- - `themes`: theme style dependency map.
105
- - `components`: glob-like component style rules used to infer style imports from source imports.
199
+ ```ts
200
+ type ConfigureTsdownContext = {
201
+ kind: 'bundle' | 'module';
202
+ format: 'cjs' | 'esm' | 'iife';
203
+ packageRoot: string;
204
+ output: string;
205
+ packageName?: string;
206
+ };
207
+ ```
106
208
 
107
- Component style inference only scans source `.tsx` files. Component imports or
108
- re-exports in `.ts` files are ignored for CSS auto import, so component barrel
109
- files that should drive component CSS must be `.tsx`.
209
+ ## CSS Conventions And Limits
110
210
 
111
- Same-package component style inference resolves relative imports,
112
- `package.json#imports` mappings, and `tsconfig.json` `compilerOptions.paths`.
113
- For `package.json#imports`, the `source` condition is preferred when present.
114
- Only aliases that resolve into the current package source directory are treated
115
- as same-package CSS dependencies.
211
+ CSS auto import only scans `.tsx` files. `.ts` and `.d.ts` files do not
212
+ participate.
116
213
 
117
- Supported value forms include named imports, named re-exports, and local
118
- re-exports that can be traced back to an import binding:
214
+ Supported source syntax:
119
215
 
120
216
  ```tsx
121
217
  import { Button } from '@scope/ui';
218
+ import { Card as UICard } from '@scope/ui';
219
+ import { Dialog } from '@scope/ui/components/Dialog';
220
+
221
+ export { Button } from '@scope/ui';
122
222
  export { Card } from '@scope/ui/components/Card';
123
223
 
124
224
  import { Dialog as BaseDialog } from '@scope/ui';
125
225
  export { BaseDialog as Dialog };
126
226
  ```
127
227
 
128
- `export * from '...'` is intentionally not supported for CSS auto import because
129
- the exported component names cannot be inferred reliably.
130
-
131
- Style configuration should use the grouped `styles` field.
228
+ Unsupported:
132
229
 
133
230
  ```ts
134
- export const config: AukletConfig = {
135
- styles: {
136
- dependencies: {
137
- '@scope/ui': {
138
- entry: '/style.css',
139
- components: ['/components/**.css'],
140
- },
141
- },
142
- },
143
- };
231
+ export * from '@scope/ui/components/Button';
144
232
  ```
145
233
 
146
- ### Build Options
234
+ `export *` is intentionally unsupported because auklet cannot reliably infer the
235
+ final exported component names, so it cannot infer CSS paths safely.
147
236
 
148
- - `modules`: whether to generate unbundled `dist/es` and `dist/lib` output. Defaults to `false`. CSS module style entries also follow this flag.
149
- - `build.formats`: package bundle formats: `esm`, `cjs`, or `iife`. Defaults to `['cjs', 'esm', 'iife']`.
150
- - `build.target`: JavaScript compilation target passed to tsdown. Defaults to `es2020` and is shared by bundle, global, and module output.
151
- - `build.platform`: build target runtime platform: `neutral`, `node`, or `browser`. Defaults to `neutral`.
152
- - `build.banner`: custom bundle banner. Defaults to a package name/version banner.
153
- - `build.externals`: additional external packages. Defaults to `[]`.
154
- - `build.alias`: path aliases passed to tsdown `alias`. Defaults to `{}`.
155
- - `build.mainFields`: bundle package entry resolution order passed to rolldown `resolve.mainFields`. When omitted, auklet only sets `['browser', 'module', 'main']` for IIFE bundles.
156
- - `build.globals`: IIFE external global names passed to tsdown `output.globals`. Values override auklet's generated global names.
157
- - `build.configureTsdown`: final customization hook for each generated tsdown config. It receives `(config, context)` and should return a tsdown config.
158
- - `build.tsconfig`: TypeScript config path relative to the package root. Defaults to the nearest `tsconfig.json` found from the package root upward.
237
+ Inference rules:
159
238
 
160
- ### Build Constants
239
+ - Package-root named imports use the imported name. For example, `Button` from
240
+ `@scope/ui` tries `@scope/ui/components/Button.css`.
241
+ - Local aliases do not affect package-root inference. `Button as UIButton`
242
+ still uses `Button`.
243
+ - Deep imports use the import path. `@scope/ui/components/Button` tries
244
+ `@scope/ui/components/Button.css`.
245
+ - Missing inferred CSS files are skipped.
246
+ - Duplicate imports inferred from JS and handwritten source CSS are deduped.
161
247
 
162
- `auk build` injects these compile-time constants into bundled output:
248
+ Same-package source imports can be resolved through:
163
249
 
164
- - `__DEV__`: `true` when `process.env.NODE_ENV !== 'production'`, otherwise `false`.
165
- - `__TEST__`: always `false` in package builds.
166
- - `__VERSION__`: current package version from `package.json`.
250
+ - relative paths such as `../Button`;
251
+ - `package.json#imports`, preferring the `source` condition;
252
+ - `tsconfig.json` `compilerOptions.paths`.
253
+
254
+ Only candidates resolved into the current package `source` directory are treated
255
+ as same-package CSS dependencies.
256
+
257
+ `build-css` handles CSS entry generation and simple `@import` expansion. It does
258
+ not aim to replace a full CSS toolchain. In particular, keep these boundaries in
259
+ mind:
167
260
 
168
- Vitest uses the same names with test-friendly values: `__DEV__` is `true`, `__TEST__` is `true`, and `__VERSION__` is `'unknown'`.
261
+ - It does not process preprocessors such as Sass or Less.
262
+ - It does not implement CSS Modules.
263
+ - It does not perform URL rebasing.
264
+ - It does not evaluate conditional CSS import semantics beyond auklet's style
265
+ entry rules.
266
+ - It expects source CSS files and package/style paths to exist on disk.
169
267
 
170
268
  ## CSS Output
171
269
 
172
- `build-css` always generates the package-level `index.css` when source styles exist.
270
+ `build-css` generates package-level `index.css` when source styles exist.
173
271
 
174
- Module style entries under `dist/es` and `dist/lib` are generated only when `modules` is `true`, matching the JavaScript module output.
272
+ When `modules: true` is enabled, auklet also generates module-level CSS output
273
+ under `dist/es` and `dist/lib`, aligned with JavaScript module output.
175
274
 
176
- Typical module output includes:
275
+ Typical output structure:
177
276
 
178
277
  ```text
179
278
  dist/
@@ -194,18 +293,27 @@ dist/
194
293
  ...
195
294
  ```
196
295
 
197
- Important entry semantics:
296
+ Entry semantics:
198
297
 
199
298
  - `index.css`: package-level aggregate CSS.
200
- - `style/index.css`: package style entry for a specific output format.
201
- - `style/module.css`: current package module styles.
202
- - `style/external.css`: external style entries.
203
- - `components/*/style/index.css`: component-level style entry.
299
+ - `style/index.css`: style entry for the current format.
300
+ - `style/module.css`: module styles from the current package.
301
+ - `style/external.css`: external style entry.
204
302
  - `themes/*.css`: theme style entry.
303
+ - `components/*/style/index.css`: module-level style entry. `components/` is a
304
+ common output path, not a restriction that the internal model only supports
305
+ components.
306
+
307
+ If a generated CSS file is empty, auklet writes a placeholder comment so the
308
+ output is not a completely empty file.
205
309
 
206
310
  ## Vite Plugin
207
311
 
208
- Use `aukletStylePlugin` in Vite dev mode to load virtual package CSS entries.
312
+ `aukletStylePlugin` is the Vite dev entry point. It turns package CSS imports
313
+ into virtual CSS modules. It only applies to the Vite dev server; production
314
+ builds still use `auk build` or `auk build-css`.
315
+
316
+ Single-package mode is the default:
209
317
 
210
318
  ```ts
211
319
  import { aukletStylePlugin } from 'auklet';
@@ -215,12 +323,8 @@ export default {
215
323
  };
216
324
  ```
217
325
 
218
- The plugin defaults to `mode: 'package'`, where Vite root is treated as the
219
- current package root. This is the expected setup for a single-package component
220
- library.
221
-
222
- For a workspace demo or app that imports CSS from packages under
223
- `packages/*`, enable monorepo mode:
326
+ Use monorepo mode when a workspace demo/app needs to work with multiple
327
+ workspace packages:
224
328
 
225
329
  ```ts
226
330
  import { aukletStylePlugin } from 'auklet';
@@ -230,96 +334,73 @@ export default {
230
334
  };
231
335
  ```
232
336
 
233
- `mode: 'monorepo'` automatically walks upward from Vite root to find
234
- `pnpm-workspace.yaml`. A custom graph root can be passed with `root` when the
235
- workspace root cannot be inferred.
337
+ Primary options:
338
+
339
+ | Option | Default | Description |
340
+ | ------ | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
341
+ | `mode` | `'package'` | `'package'` treats Vite root as the package root. `'monorepo'` finds `pnpm-workspace.yaml` upward from Vite root and reads pnpm workspace packages. |
342
+ | `root` | inferred | Custom graph root. Usually unnecessary. |
236
343
 
237
- The plugin resolves package CSS ids such as:
344
+ Supported dev CSS imports:
238
345
 
239
346
  ```ts
240
347
  import '@scope/app/style.css';
348
+ import '@scope/app/external.css';
349
+ import '@scope/app/module.css';
241
350
  import '@scope/app/components/Button.css';
242
351
  import '@scope/app/themes/light.css';
243
352
  ```
244
353
 
245
354
  In dev mode, workspace package style dependencies keep using auklet virtual CSS
246
- entries so changes can be tracked recursively. Third-party CSS dependencies are
247
- resolved from the package that declares the dependency and emitted as Vite
248
- `/@fs/...` imports, so packages such as `katex/dist/katex.min.css` do not need
249
- to be installed by the consuming app.
355
+ recursion so style changes across packages can be tracked. Third-party CSS
356
+ dependencies are resolved from the package root that declares them and emitted
357
+ as Vite `/@fs/...` imports.
250
358
 
251
- ## Examples
359
+ ## Build Constants
252
360
 
253
- The repository includes runnable examples for the supported project shapes:
361
+ `auk build` injects these compile-time constants into bundles:
254
362
 
255
- - `examples/components`: monorepo component packages.
256
- - `examples/libs`: monorepo TypeScript libraries without CSS output.
257
- - `examples/single-package`: single-package component library with Vite dev mode.
258
- - `examples/single-lib`: single-package TypeScript library without CSS output.
259
-
260
- Useful commands:
363
+ - `__DEV__`: `true` when `process.env.NODE_ENV !== 'production'`, otherwise
364
+ `false`.
365
+ - `__TEST__`: always `false` in package builds.
366
+ - `__VERSION__`: current package version.
261
367
 
262
- ```bash
263
- pnpm run build:examples
264
- pnpm run test:examples
265
- pnpm run dev:examples
266
- ```
368
+ Vitest uses test-friendly values with the same names: `__DEV__` is `true`,
369
+ `__TEST__` is `true`, and `__VERSION__` is `'unknown'`.
267
370
 
268
371
  ## Programmatic API
269
372
 
270
- ```ts
271
- import {
272
- ModuleStyleBuilder,
273
- ModuleStyleWatcher,
274
- aukletStylePlugin,
275
- loadAukletConfig,
276
- runTsdown,
277
- } from 'auklet';
278
-
279
- const aukletConfig = await loadAukletConfig(process.cwd());
280
-
281
- await new ModuleStyleBuilder({
282
- packageRoot: process.cwd(),
283
- aukletConfig,
284
- }).build();
285
- ```
373
+ The root package entry exposes the Vite plugin, configuration helpers, and a
374
+ small set of build helpers used by projects that need to compose auklet
375
+ programmatically. Publish and owner workflows remain CLI/internal implementation
376
+ details.
286
377
 
287
378
  Public exports include:
288
379
 
289
- - `ModuleStyleBuilder`
290
- - `ModuleStyleWatcher`
291
380
  - `aukletStylePlugin`
292
381
  - `loadAukletConfig`
293
- - `resolveAukletConfigModule`
294
- - `createTsdownArgs`
295
382
  - `runTsdown`
296
- - related TypeScript types
383
+ - `defineKernelPackageConfigFromFile`
384
+ - `defineKernelPackageConfigFromOptions`
385
+ - `runAukletCli`
386
+ - `AukletStylePluginOptions`
387
+ - `AukletConfig`
388
+ - `PackageBuildOptions`
389
+ - `StyleOptions`
390
+ - related user-facing TypeScript types
297
391
 
298
392
  ## Development
299
393
 
300
394
  ```bash
301
395
  pnpm i
302
- pnpm run test
303
- pnpm run typecheck
304
- pnpm run build
396
+ pnpm test
397
+ pnpm typecheck
398
+ pnpm build
305
399
  pnpm run format
306
400
  ```
307
401
 
308
402
  Notes:
309
403
 
310
- - `pnpm run build` rewrites `dist`.
311
- - `pnpm run format` formats `bin`, `src`, and `dist`.
312
- - `TESTING.md` defines the testing architecture and style rules for future changes.
313
-
314
- ## Testing
315
-
316
- Tests are organized into:
317
-
318
- - `src/__tests__/e2e`: project-level output structure and dependency-chain tests.
319
- - `src/__tests__/css`: module/API tests for CSS and style logic.
320
- - `src/__tests__/fixtures`: shared virtual project and style structure helpers.
321
- - `src/__tests__/build`: tsdown/build config tests.
322
-
323
- Temporary test projects are created under `src/__tests__/.tmp/` and ignored by git.
324
-
325
- Read `TESTING.md` before adding or changing tests.
404
+ - `pnpm build` rewrites `dist`.
405
+ - `pnpm run format` formats `bin`, `src`, `dist`, `examples`, and related files.
406
+ - Read `TESTING.md` before changing tests.
package/bin/entry.mjs ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { runAukletCli } from '../dist/index.js';
4
+
5
+ await runAukletCli();
@@ -47,7 +47,7 @@ export function createBundleConfigs(context, formats) {
47
47
  : undefined;
48
48
  return configureTsdown(context, {
49
49
  ...createCommonConfig(context, deps),
50
- entry: getBundleEntry(context.packageRoot),
50
+ entry: getBundleEntry(context.packageRoot, context.source),
51
51
  format,
52
52
  globalName: context.globalName,
53
53
  outDir: context.output,
@@ -0,0 +1,22 @@
1
+ import type { AukletConfig } from '#auklet/types';
2
+ export declare const aukletCliConfigOverridesEnv = "AUKLET_CONFIG_OVERRIDES";
3
+ export declare function encodeAukletCliConfigOverrides(config: AukletConfig): string;
4
+ export declare function readAukletCliConfigOverrides(): AukletConfig;
5
+ export declare function mergeAukletConfigOverrides(config: AukletConfig, overrides: AukletConfig): {
6
+ build: {
7
+ formats?: Array<import("#auklet/types").PackageBuildFormat>;
8
+ target?: import("#auklet/types").PackageBuildTarget;
9
+ platform?: import("#auklet/types").PackageBuildPlatform;
10
+ banner?: string;
11
+ externals?: Array<string>;
12
+ alias?: Record<string, string>;
13
+ mainFields?: Array<string>;
14
+ globals?: Record<string, string>;
15
+ configureTsdown?: import("#auklet/types").ConfigureTsdown;
16
+ tsconfig?: string;
17
+ } | undefined;
18
+ source?: string;
19
+ output?: string;
20
+ modules?: boolean;
21
+ styles?: import("#auklet/types").StyleOptions;
22
+ };
@@ -0,0 +1,22 @@
1
+ export const aukletCliConfigOverridesEnv = 'AUKLET_CONFIG_OVERRIDES';
2
+ export function encodeAukletCliConfigOverrides(config) {
3
+ return JSON.stringify(config);
4
+ }
5
+ export function readAukletCliConfigOverrides() {
6
+ const rawConfig = process.env[aukletCliConfigOverridesEnv];
7
+ if (!rawConfig)
8
+ return {};
9
+ return JSON.parse(rawConfig);
10
+ }
11
+ export function mergeAukletConfigOverrides(config, overrides) {
12
+ return {
13
+ ...config,
14
+ ...overrides,
15
+ build: config.build || overrides.build
16
+ ? {
17
+ ...config.build,
18
+ ...overrides.build,
19
+ }
20
+ : undefined,
21
+ };
22
+ }
@@ -19,7 +19,7 @@ export function createModuleConfigs(context) {
19
19
  const commonConfig = createCommonConfig(context, {
20
20
  neverBundle: context.packageExternal,
21
21
  });
22
- const entry = getModuleEntries(context.packageRoot);
22
+ const entry = getModuleEntries(context.packageRoot, context.source);
23
23
  return [
24
24
  createModuleConfig(context, commonConfig, entry, 'esm', path.join(context.output, 'es')),
25
25
  createModuleConfig(context, commonConfig, entry, 'cjs', path.join(context.output, 'lib')),
@@ -1,5 +1,7 @@
1
+ export declare function hasTsdownConfigArg(args: Array<string>): boolean;
1
2
  export type RunTsdownOptions = {
2
3
  cwd?: string;
4
+ env?: Record<string, string>;
3
5
  };
4
6
  export declare function createTsdownArgs(args: Array<string>): string[];
5
7
  export declare function runTsdown(args: Array<string>, options?: RunTsdownOptions): Promise<number>;