auklet 0.0.18 → 0.0.19
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/README.md +421 -128
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,43 +7,99 @@
|
|
|
7
7
|
|
|
8
8
|
<h1></h1>
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
auklet is a build tool for TypeScript packages. It generates JavaScript and
|
|
11
|
+
TypeScript output through `tsdown`, and also provides CSS style entry builds,
|
|
12
|
+
module style auto imports, and a Vite dev plugin for virtual package CSS.
|
|
11
13
|
|
|
12
14
|
## Features
|
|
13
15
|
|
|
14
|
-
-
|
|
15
|
-
- Generate package-level
|
|
16
|
-
- Infer
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
|
|
16
|
+
- Generate TypeScript package bundles, IIFE output, and unbundled module output.
|
|
17
|
+
- Generate package-level, module-level, theme, and external CSS entries.
|
|
18
|
+
- Infer module CSS dependencies from `.tsx` imports and re-exports.
|
|
19
|
+
- Turn package CSS imports into virtual CSS modules in Vite dev mode.
|
|
20
|
+
- Support single-package component libraries, single-package libraries,
|
|
21
|
+
monorepo component packages, and monorepo libraries.
|
|
22
|
+
- Watch source/config/style changes and rebuild CSS output.
|
|
20
23
|
|
|
21
24
|
## Requirements
|
|
22
25
|
|
|
23
26
|
- Node.js `>=22`
|
|
24
27
|
|
|
28
|
+
## Project Shapes
|
|
29
|
+
|
|
30
|
+
auklet supports four project shapes:
|
|
31
|
+
|
|
32
|
+
- single-package component library;
|
|
33
|
+
- single-package TypeScript library;
|
|
34
|
+
- monorepo component packages;
|
|
35
|
+
- monorepo TypeScript libraries.
|
|
36
|
+
|
|
37
|
+
Production build commands always run from the **current package root**, whether
|
|
38
|
+
that package lives in a monorepo or not:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
auk build
|
|
42
|
+
auk build-js
|
|
43
|
+
auk build-css
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Vite dev mode is provided by `aukletStylePlugin`, which exposes virtual CSS
|
|
47
|
+
entries. The plugin defaults to single-package mode. If a workspace demo/app
|
|
48
|
+
needs to work with multiple packages at the same time, enable monorepo mode
|
|
49
|
+
explicitly.
|
|
50
|
+
|
|
51
|
+
## Quick Start
|
|
52
|
+
|
|
53
|
+
### Single-Package Component Library
|
|
54
|
+
|
|
55
|
+
Add `auklet.config.ts` in the package root:
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
import type { AukletConfig } from 'auklet';
|
|
59
|
+
|
|
60
|
+
export const config: AukletConfig = {
|
|
61
|
+
source: 'src',
|
|
62
|
+
output: 'dist',
|
|
63
|
+
modules: true,
|
|
64
|
+
};
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Then import CSS entries from the current package:
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
import '@scope/ui/style.css';
|
|
71
|
+
import '@scope/ui/components/Button.css';
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
See the "Vite Plugin" section for dev plugin setup.
|
|
75
|
+
|
|
25
76
|
## CLI
|
|
26
77
|
|
|
27
|
-
The package exposes both `auk` and `auklet` commands
|
|
78
|
+
The package exposes both `auk` and `auklet` commands:
|
|
28
79
|
|
|
29
80
|
```bash
|
|
30
81
|
pnpm auk --help
|
|
82
|
+
pnpm auk dev
|
|
31
83
|
pnpm auk build
|
|
32
84
|
pnpm auk build-js
|
|
85
|
+
pnpm auk build-js --watch
|
|
33
86
|
pnpm auk build-css
|
|
34
87
|
pnpm auk build-css --watch
|
|
35
|
-
pnpm auk dev
|
|
36
88
|
```
|
|
37
89
|
|
|
38
90
|
Commands:
|
|
39
91
|
|
|
40
|
-
- `
|
|
41
|
-
- `build
|
|
42
|
-
|
|
43
|
-
- `build-
|
|
44
|
-
|
|
92
|
+
- `dev`: starts JavaScript watch and CSS watch together.
|
|
93
|
+
- `build`: removes the configured `output` directory, then builds JavaScript and
|
|
94
|
+
CSS output.
|
|
95
|
+
- `build-js`: runs tsdown. If no `--config` is passed, auklet uses its built-in
|
|
96
|
+
tsdown config.
|
|
97
|
+
- `build-js --watch`: passes `--watch` through to tsdown and watches JS/TS
|
|
98
|
+
builds.
|
|
99
|
+
- `build-css`: generates CSS output.
|
|
100
|
+
- `build-css --watch`: watches source/config/style files and rebuilds CSS.
|
|
45
101
|
|
|
46
|
-
## Configuration
|
|
102
|
+
## Configuration Example
|
|
47
103
|
|
|
48
104
|
Create `auklet.config.ts` in the package root:
|
|
49
105
|
|
|
@@ -54,7 +110,9 @@ export const config: AukletConfig = {
|
|
|
54
110
|
source: 'src',
|
|
55
111
|
output: 'dist',
|
|
56
112
|
modules: true,
|
|
57
|
-
|
|
113
|
+
build: {
|
|
114
|
+
formats: ['esm', 'cjs'],
|
|
115
|
+
},
|
|
58
116
|
styles: {
|
|
59
117
|
themes: {
|
|
60
118
|
light: './src/themes/light.css',
|
|
@@ -65,115 +123,316 @@ export const config: AukletConfig = {
|
|
|
65
123
|
entry: '/style.css',
|
|
66
124
|
components: ['/components/**.css'],
|
|
67
125
|
},
|
|
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
126
|
},
|
|
90
127
|
},
|
|
91
128
|
};
|
|
92
129
|
```
|
|
93
130
|
|
|
94
|
-
|
|
131
|
+
## Configuration Reference
|
|
132
|
+
|
|
133
|
+
The full `auklet.config.ts` shape is:
|
|
95
134
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
135
|
+
```ts
|
|
136
|
+
import type { UserConfig } from 'tsdown/config';
|
|
137
|
+
|
|
138
|
+
export interface AukletConfig {
|
|
139
|
+
/**
|
|
140
|
+
* Source directory, relative to the current package root.
|
|
141
|
+
*
|
|
142
|
+
* @default 'src'
|
|
143
|
+
*/
|
|
144
|
+
source?: string;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Build output directory, relative to the current package root.
|
|
148
|
+
*
|
|
149
|
+
* `auk build` removes this directory before generating JavaScript and CSS
|
|
150
|
+
* output again.
|
|
151
|
+
*
|
|
152
|
+
* @default 'dist'
|
|
153
|
+
*/
|
|
154
|
+
output?: string;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Whether to generate unbundled module output.
|
|
158
|
+
*
|
|
159
|
+
* When enabled, auklet generates module output such as `dist/es` and
|
|
160
|
+
* `dist/lib`. Module-level CSS output follows the same switch.
|
|
161
|
+
*
|
|
162
|
+
* @default false
|
|
163
|
+
*/
|
|
164
|
+
modules?: boolean;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Style build configuration.
|
|
168
|
+
*
|
|
169
|
+
* @default { themes: {}, dependencies: {} }
|
|
170
|
+
*/
|
|
171
|
+
styles?: {
|
|
172
|
+
/**
|
|
173
|
+
* Theme style entries for the current package.
|
|
174
|
+
*
|
|
175
|
+
* The key is the theme name, and the value is a style file path relative to
|
|
176
|
+
* the current package root.
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* {
|
|
180
|
+
* light: './src/themes/light.css',
|
|
181
|
+
* dark: './src/themes/dark.css',
|
|
182
|
+
* }
|
|
183
|
+
*
|
|
184
|
+
* @default {}
|
|
185
|
+
*/
|
|
186
|
+
themes?: Record<string, string>;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* External package style dependencies.
|
|
190
|
+
*
|
|
191
|
+
* The key is the dependency package name, and the value describes style
|
|
192
|
+
* entry rules for that package.
|
|
193
|
+
*
|
|
194
|
+
* @default {}
|
|
195
|
+
*/
|
|
196
|
+
dependencies?: Record<
|
|
197
|
+
string,
|
|
198
|
+
{
|
|
199
|
+
/**
|
|
200
|
+
* Package-level style entry from the dependency package.
|
|
201
|
+
*
|
|
202
|
+
* This participates in package style and external style generation for
|
|
203
|
+
* the current package.
|
|
204
|
+
*
|
|
205
|
+
* @default undefined
|
|
206
|
+
*/
|
|
207
|
+
entry?: string | string[];
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Theme style entries from the dependency package.
|
|
211
|
+
*
|
|
212
|
+
* The key should match a theme name in the current package, and the
|
|
213
|
+
* value is the corresponding theme entry in the dependency package.
|
|
214
|
+
*
|
|
215
|
+
* @default undefined
|
|
216
|
+
*/
|
|
217
|
+
themes?: Record<string, string>;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Module CSS auto import rules.
|
|
221
|
+
*
|
|
222
|
+
* The field name remains `components` for compatibility with common
|
|
223
|
+
* component-library usage. The rule itself is not limited to
|
|
224
|
+
* components; paths such as `/pages/**.css` or `/blocks/**.css` are also
|
|
225
|
+
* valid.
|
|
226
|
+
*
|
|
227
|
+
* @default undefined
|
|
228
|
+
*/
|
|
229
|
+
components?: string | string[];
|
|
230
|
+
}
|
|
231
|
+
>;
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* JavaScript/TypeScript build configuration.
|
|
236
|
+
*/
|
|
237
|
+
build?: {
|
|
238
|
+
/**
|
|
239
|
+
* Package-level bundle formats.
|
|
240
|
+
*
|
|
241
|
+
* @default ['cjs', 'esm', 'iife']
|
|
242
|
+
*/
|
|
243
|
+
formats?: Array<'cjs' | 'esm' | 'iife'>;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* JavaScript compilation target passed to tsdown.
|
|
247
|
+
*
|
|
248
|
+
* Bundle, IIFE, and module output use the same target.
|
|
249
|
+
*
|
|
250
|
+
* @default 'es2020'
|
|
251
|
+
*/
|
|
252
|
+
target?: string | string[] | false;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Runtime platform for the build target.
|
|
256
|
+
*
|
|
257
|
+
* @default 'neutral'
|
|
258
|
+
*/
|
|
259
|
+
platform?: 'node' | 'neutral' | 'browser';
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Custom bundle banner.
|
|
263
|
+
*
|
|
264
|
+
* When omitted, auklet generates one from package name/version/author.
|
|
265
|
+
*
|
|
266
|
+
* @default undefined
|
|
267
|
+
*/
|
|
268
|
+
banner?: string;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Additional external package names.
|
|
272
|
+
*
|
|
273
|
+
* These are combined with package.json dependencies and peerDependencies
|
|
274
|
+
* before being passed to tsdown.
|
|
275
|
+
*
|
|
276
|
+
* @default []
|
|
277
|
+
*/
|
|
278
|
+
externals?: string[];
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Path aliases passed to tsdown `alias`.
|
|
282
|
+
*
|
|
283
|
+
* This applies to both bundle output and module output.
|
|
284
|
+
*
|
|
285
|
+
* @default {}
|
|
286
|
+
*/
|
|
287
|
+
alias?: Record<string, string>;
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Package.json entry field resolution order for bundle output.
|
|
291
|
+
*
|
|
292
|
+
* This is passed to rolldown `resolve.mainFields`. When omitted, auklet
|
|
293
|
+
* only sets `['browser', 'module', 'main']` for IIFE bundles.
|
|
294
|
+
*
|
|
295
|
+
* @default undefined
|
|
296
|
+
*/
|
|
297
|
+
mainFields?: string[];
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Global names for IIFE externals.
|
|
301
|
+
*
|
|
302
|
+
* This is passed to tsdown `output.globals` and overrides the global names
|
|
303
|
+
* auklet infers from package names.
|
|
304
|
+
*
|
|
305
|
+
* @default {}
|
|
306
|
+
*/
|
|
307
|
+
globals?: Record<string, string>;
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* TypeScript config file path, relative to the current package root.
|
|
311
|
+
*
|
|
312
|
+
* When omitted, auklet searches upward from the current package root for
|
|
313
|
+
* the nearest `tsconfig.json`.
|
|
314
|
+
*
|
|
315
|
+
* @default undefined
|
|
316
|
+
*/
|
|
317
|
+
tsconfig?: string;
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Final tsdown config hook.
|
|
321
|
+
*
|
|
322
|
+
* auklet calls this after generating each tsdown config, allowing users to
|
|
323
|
+
* make final adjustments.
|
|
324
|
+
*
|
|
325
|
+
* @default undefined
|
|
326
|
+
*/
|
|
327
|
+
configureTsdown?: (
|
|
328
|
+
config: UserConfig,
|
|
329
|
+
context: {
|
|
330
|
+
/**
|
|
331
|
+
* Build output kind for the current config.
|
|
332
|
+
*
|
|
333
|
+
* `bundle` means package-level bundle/IIFE output.
|
|
334
|
+
* `module` means unbundled module output generated by `modules: true`.
|
|
335
|
+
*/
|
|
336
|
+
kind: 'bundle' | 'module';
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Output format for the current config.
|
|
340
|
+
*/
|
|
341
|
+
format: 'cjs' | 'esm' | 'iife';
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Current package root.
|
|
345
|
+
*/
|
|
346
|
+
packageRoot: string;
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Current package build output directory.
|
|
350
|
+
*/
|
|
351
|
+
output: string;
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Current package.json name.
|
|
355
|
+
*/
|
|
356
|
+
packageName?: string;
|
|
357
|
+
},
|
|
358
|
+
) => UserConfig;
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
```
|
|
100
362
|
|
|
101
|
-
|
|
363
|
+
A common component-library dependency rule looks like this:
|
|
102
364
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
365
|
+
```ts
|
|
366
|
+
{
|
|
367
|
+
entry: '/style.css',
|
|
368
|
+
components: ['/pages/**.css', '/components/**.css'],
|
|
369
|
+
themes: {
|
|
370
|
+
dark: '/themes/dark.css',
|
|
371
|
+
light: '/themes/light.css',
|
|
372
|
+
},
|
|
373
|
+
}
|
|
374
|
+
```
|
|
106
375
|
|
|
107
|
-
|
|
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`.
|
|
376
|
+
## CSS Auto Import
|
|
110
377
|
|
|
111
|
-
|
|
112
|
-
|
|
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.
|
|
378
|
+
CSS auto import only scans `.tsx` files. `.ts` and `.d.ts` files do not
|
|
379
|
+
participate in CSS auto import.
|
|
116
380
|
|
|
117
|
-
Supported
|
|
118
|
-
re-exports that can be traced back to an import binding:
|
|
381
|
+
Supported syntax:
|
|
119
382
|
|
|
120
383
|
```tsx
|
|
121
384
|
import { Button } from '@scope/ui';
|
|
385
|
+
import { Card as UICard } from '@scope/ui';
|
|
386
|
+
import { Dialog } from '@scope/ui/components/Dialog';
|
|
387
|
+
|
|
388
|
+
export { Button } from '@scope/ui';
|
|
122
389
|
export { Card } from '@scope/ui/components/Card';
|
|
123
390
|
|
|
124
391
|
import { Dialog as BaseDialog } from '@scope/ui';
|
|
125
392
|
export { BaseDialog as Dialog };
|
|
126
393
|
```
|
|
127
394
|
|
|
128
|
-
|
|
129
|
-
the exported component names cannot be inferred reliably.
|
|
130
|
-
|
|
131
|
-
Style configuration should use the grouped `styles` field.
|
|
395
|
+
Unsupported:
|
|
132
396
|
|
|
133
397
|
```ts
|
|
134
|
-
export
|
|
135
|
-
styles: {
|
|
136
|
-
dependencies: {
|
|
137
|
-
'@scope/ui': {
|
|
138
|
-
entry: '/style.css',
|
|
139
|
-
components: ['/components/**.css'],
|
|
140
|
-
},
|
|
141
|
-
},
|
|
142
|
-
},
|
|
143
|
-
};
|
|
398
|
+
export * from '@scope/ui/components/Button';
|
|
144
399
|
```
|
|
145
400
|
|
|
146
|
-
|
|
401
|
+
`export *` is intentionally unsupported because auklet cannot reliably infer the
|
|
402
|
+
final exported component names, so it cannot infer CSS paths safely.
|
|
147
403
|
|
|
148
|
-
|
|
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.
|
|
404
|
+
Inference rules:
|
|
159
405
|
|
|
160
|
-
|
|
406
|
+
- Package-root named imports use the imported name. For example,
|
|
407
|
+
`import { Button } from '@scope/ui'` tries to generate
|
|
408
|
+
`@scope/ui/components/Button.css`.
|
|
409
|
+
- Local aliases do not affect package-root import inference. For example,
|
|
410
|
+
`import { Button as UIButton } from '@scope/ui'` still uses `Button`.
|
|
411
|
+
- Deep imports use the import path. For example,
|
|
412
|
+
`import { Anything } from '@scope/ui/components/Button'` tries to generate
|
|
413
|
+
`@scope/ui/components/Button.css`.
|
|
414
|
+
- If the inferred CSS file does not exist, auklet skips it and does not generate
|
|
415
|
+
an invalid import.
|
|
416
|
+
- If JavaScript auto inference and handwritten source CSS `@import` point to the
|
|
417
|
+
same file, auklet dedupes the import.
|
|
161
418
|
|
|
162
|
-
|
|
419
|
+
Same-package source imports can be resolved through:
|
|
163
420
|
|
|
164
|
-
-
|
|
165
|
-
- `
|
|
166
|
-
- `
|
|
421
|
+
- relative paths, such as `../Button`;
|
|
422
|
+
- `package.json#imports`, preferring the `source` condition;
|
|
423
|
+
- `tsconfig.json` `compilerOptions.paths`.
|
|
167
424
|
|
|
168
|
-
|
|
425
|
+
Only candidates resolved into the current package `source` directory are treated
|
|
426
|
+
as same-package CSS dependencies.
|
|
169
427
|
|
|
170
428
|
## CSS Output
|
|
171
429
|
|
|
172
|
-
`build-css`
|
|
430
|
+
`build-css` generates package-level `index.css` when source styles exist.
|
|
173
431
|
|
|
174
|
-
|
|
432
|
+
When `modules: true` is enabled, auklet also generates module-level CSS output
|
|
433
|
+
under `dist/es` and `dist/lib`, aligned with JavaScript module output.
|
|
175
434
|
|
|
176
|
-
Typical
|
|
435
|
+
Typical output structure:
|
|
177
436
|
|
|
178
437
|
```text
|
|
179
438
|
dist/
|
|
@@ -194,18 +453,30 @@ dist/
|
|
|
194
453
|
...
|
|
195
454
|
```
|
|
196
455
|
|
|
197
|
-
|
|
456
|
+
Entry semantics:
|
|
198
457
|
|
|
199
458
|
- `index.css`: package-level aggregate CSS.
|
|
200
|
-
- `style/index.css`:
|
|
201
|
-
- `style/module.css`: current package
|
|
202
|
-
- `style/external.css`: external style
|
|
203
|
-
- `components/*/style/index.css`: component-level style entry.
|
|
459
|
+
- `style/index.css`: style entry for the current format.
|
|
460
|
+
- `style/module.css`: module styles from the current package.
|
|
461
|
+
- `style/external.css`: external style entry.
|
|
204
462
|
- `themes/*.css`: theme style entry.
|
|
463
|
+
- `components/*/style/index.css`: module-level style entry. `components/` is a
|
|
464
|
+
common output path, not a restriction that the internal model only supports
|
|
465
|
+
components.
|
|
466
|
+
|
|
467
|
+
If a generated CSS file is empty, auklet writes a placeholder comment so the
|
|
468
|
+
output is not a completely empty file.
|
|
205
469
|
|
|
206
470
|
## Vite Plugin
|
|
207
471
|
|
|
208
|
-
|
|
472
|
+
`aukletStylePlugin` is the Vite dev entry point. It turns package CSS imports
|
|
473
|
+
into virtual CSS modules. It only applies to the Vite dev server; production
|
|
474
|
+
builds still use `auk build` or `auk build-css`.
|
|
475
|
+
|
|
476
|
+
### Single-Package Mode
|
|
477
|
+
|
|
478
|
+
The plugin defaults to single-package mode. Vite root is treated as the current
|
|
479
|
+
package root:
|
|
209
480
|
|
|
210
481
|
```ts
|
|
211
482
|
import { aukletStylePlugin } from 'auklet';
|
|
@@ -215,12 +486,19 @@ export default {
|
|
|
215
486
|
};
|
|
216
487
|
```
|
|
217
488
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
489
|
+
This is equivalent to:
|
|
490
|
+
|
|
491
|
+
```ts
|
|
492
|
+
aukletStylePlugin({ mode: 'package' });
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
Single-package mode is intended for running a Vite demo directly from a
|
|
496
|
+
component-library package root.
|
|
497
|
+
|
|
498
|
+
### Monorepo Mode
|
|
221
499
|
|
|
222
|
-
|
|
223
|
-
|
|
500
|
+
Use monorepo mode when a demo/app lives in a workspace and needs to work with
|
|
501
|
+
multiple workspace packages at the same time:
|
|
224
502
|
|
|
225
503
|
```ts
|
|
226
504
|
import { aukletStylePlugin } from 'auklet';
|
|
@@ -230,40 +508,56 @@ export default {
|
|
|
230
508
|
};
|
|
231
509
|
```
|
|
232
510
|
|
|
233
|
-
`mode: 'monorepo'`
|
|
234
|
-
|
|
235
|
-
|
|
511
|
+
`mode: 'monorepo'` walks upward from Vite root to find `pnpm-workspace.yaml`,
|
|
512
|
+
then scans workspace packages.
|
|
513
|
+
|
|
514
|
+
### Plugin Options
|
|
515
|
+
|
|
516
|
+
```ts
|
|
517
|
+
export type AukletStylePluginOptions = {
|
|
518
|
+
mode?: 'package' | 'monorepo';
|
|
519
|
+
root?: string;
|
|
520
|
+
};
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
- `mode: 'package'`: default. Vite root is the current package root. This is
|
|
524
|
+
intended for single-package component libraries.
|
|
525
|
+
- `mode: 'monorepo'`: walks upward from Vite root to find `pnpm-workspace.yaml`
|
|
526
|
+
and scans workspace packages.
|
|
527
|
+
- `root`: custom graph root. This is usually unnecessary; use it only when a
|
|
528
|
+
monorepo root cannot be inferred automatically.
|
|
529
|
+
|
|
530
|
+
### Supported CSS Imports
|
|
236
531
|
|
|
237
532
|
The plugin resolves package CSS ids such as:
|
|
238
533
|
|
|
239
534
|
```ts
|
|
240
535
|
import '@scope/app/style.css';
|
|
536
|
+
import '@scope/app/external.css';
|
|
537
|
+
import '@scope/app/module.css';
|
|
241
538
|
import '@scope/app/components/Button.css';
|
|
242
539
|
import '@scope/app/themes/light.css';
|
|
243
540
|
```
|
|
244
541
|
|
|
245
|
-
|
|
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.
|
|
542
|
+
### Dependency Resolution
|
|
250
543
|
|
|
251
|
-
|
|
544
|
+
In dev mode, workspace package style dependencies keep using auklet virtual CSS
|
|
545
|
+
recursion so style changes across packages can be tracked. Third-party CSS
|
|
546
|
+
dependencies are resolved from the package root that declares them and emitted
|
|
547
|
+
as Vite `/@fs/...` imports, avoiding lost `node_modules` resolution context from
|
|
548
|
+
virtual modules.
|
|
252
549
|
|
|
253
|
-
|
|
550
|
+
## Build Constants
|
|
254
551
|
|
|
255
|
-
|
|
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.
|
|
552
|
+
`auk build` injects these compile-time constants into bundles:
|
|
259
553
|
|
|
260
|
-
|
|
554
|
+
- `__DEV__`: `true` when `process.env.NODE_ENV !== 'production'`, otherwise
|
|
555
|
+
`false`.
|
|
556
|
+
- `__TEST__`: always `false` in package builds.
|
|
557
|
+
- `__VERSION__`: current package version.
|
|
261
558
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
pnpm run test:examples
|
|
265
|
-
pnpm run dev:examples
|
|
266
|
-
```
|
|
559
|
+
Vitest uses test-friendly values with the same names: `__DEV__` is `true`,
|
|
560
|
+
`__TEST__` is `true`, and `__VERSION__` is `'unknown'`.
|
|
267
561
|
|
|
268
562
|
## Programmatic API
|
|
269
563
|
|
|
@@ -308,18 +602,17 @@ pnpm run format
|
|
|
308
602
|
Notes:
|
|
309
603
|
|
|
310
604
|
- `pnpm run build` rewrites `dist`.
|
|
311
|
-
- `pnpm run format` formats `bin`, `src`, and
|
|
312
|
-
- `TESTING.md`
|
|
605
|
+
- `pnpm run format` formats `bin`, `src`, `dist`, `examples`, and related files.
|
|
606
|
+
- Read `TESTING.md` before changing tests.
|
|
313
607
|
|
|
314
608
|
## Testing
|
|
315
609
|
|
|
316
610
|
Tests are organized into:
|
|
317
611
|
|
|
318
612
|
- `src/__tests__/e2e`: project-level output structure and dependency-chain tests.
|
|
319
|
-
- `src/__tests__/css`:
|
|
613
|
+
- `src/__tests__/css`: CSS/style module and API tests.
|
|
320
614
|
- `src/__tests__/fixtures`: shared virtual project and style structure helpers.
|
|
321
615
|
- `src/__tests__/build`: tsdown/build config tests.
|
|
322
616
|
|
|
323
|
-
Temporary test projects are created under `src/__tests__/.tmp/` and ignored by
|
|
324
|
-
|
|
325
|
-
Read `TESTING.md` before adding or changing tests.
|
|
617
|
+
Temporary test projects are created under `src/__tests__/.tmp/` and ignored by
|
|
618
|
+
git.
|