auklet 0.0.19 → 0.0.21
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/LICENSE +21 -0
- package/README.md +183 -393
- package/bin/entry.mjs +5 -0
- package/dist/build/bundleConfig.js +3 -2
- package/dist/build/cliOverrides.d.ts +22 -0
- package/dist/build/cliOverrides.js +22 -0
- package/dist/build/moduleConfig.js +1 -1
- package/dist/build/runTsdown.d.ts +2 -0
- package/dist/build/runTsdown.js +4 -3
- package/dist/build/tsdown/common.d.ts +2 -2
- package/dist/build/tsdown/context.d.ts +2 -1
- package/dist/build/tsdown/context.js +2 -1
- package/dist/build/tsdown/define.js +3 -2
- package/dist/build/tsdown/dependencies.js +3 -1
- package/dist/build/tsdown/entries.d.ts +2 -2
- package/dist/build/tsdown/entries.js +10 -10
- package/dist/build/tsdown/types.d.ts +1 -0
- package/dist/cli/build.d.ts +5 -0
- package/dist/cli/build.js +30 -0
- package/dist/cli/buildArgs.d.ts +8 -0
- package/dist/cli/buildArgs.js +114 -0
- package/dist/cli/buildCss.d.ts +12 -0
- package/dist/cli/buildCss.js +53 -0
- package/dist/cli/dev.d.ts +1 -0
- package/dist/cli/dev.js +39 -0
- package/dist/cli/main.d.ts +1 -0
- package/dist/cli/main.js +95 -0
- package/dist/cli/publish.d.ts +2 -0
- package/dist/cli/publish.js +9 -0
- package/dist/config.d.ts +3 -1
- package/dist/config.js +7 -1
- package/dist/configLoader.d.ts +1 -0
- package/dist/configLoader.js +42 -61
- package/dist/css/production/buildReporter.d.ts +3 -0
- package/dist/css/production/buildReporter.js +19 -0
- package/dist/css/production/builder.d.ts +8 -3
- package/dist/css/production/builder.js +9 -13
- package/dist/css/vite/hmr.js +10 -8
- package/dist/css/vite/moduleGraph/graph.js +2 -3
- package/dist/css/vite/moduleGraph/packageSource/monorepo.d.ts +5 -1
- package/dist/css/vite/moduleGraph/packageSource/monorepo.js +42 -33
- package/dist/css/vite/moduleGraph/packageSource/singlePackage.js +3 -3
- package/dist/css/vite/moduleGraph/requestCache.d.ts +4 -4
- package/dist/css/vite/moduleGraph/requestCache.js +8 -4
- package/dist/css/vite/moduleGraph/styleCodeFactory.js +4 -4
- package/dist/css/vite/moduleGraph/types.d.ts +0 -1
- package/dist/css/watch/watcher.d.ts +0 -1
- package/dist/css/watch/watcher.js +9 -15
- package/dist/index.d.ts +6 -7
- package/dist/index.js +5 -5
- package/dist/logger.d.ts +5 -0
- package/dist/logger.js +14 -0
- package/dist/publish/api/gitApi.d.ts +7 -0
- package/dist/publish/api/gitApi.js +55 -0
- package/dist/publish/api/packageJsonApi.d.ts +7 -0
- package/dist/publish/api/packageJsonApi.js +35 -0
- package/dist/publish/api/pnpmApi.d.ts +9 -0
- package/dist/publish/api/pnpmApi.js +85 -0
- package/dist/publish/api/pnpmPublishApi.d.ts +4 -0
- package/dist/publish/api/pnpmPublishApi.js +7 -0
- package/dist/publish/api/publishArgs.d.ts +2 -0
- package/dist/publish/api/publishArgs.js +25 -0
- package/dist/publish/api/publishHookApi.d.ts +10 -0
- package/dist/publish/api/publishHookApi.js +53 -0
- package/dist/publish/cli.d.ts +2 -0
- package/dist/publish/cli.js +95 -0
- package/dist/publish/ownerRunner.d.ts +6 -0
- package/dist/publish/ownerRunner.js +22 -0
- package/dist/publish/publishRunner.d.ts +16 -0
- package/dist/publish/publishRunner.js +108 -0
- package/dist/publish/runner/packageBuilder.d.ts +4 -0
- package/dist/publish/runner/packageBuilder.js +16 -0
- package/dist/publish/runner/packagePublisher.d.ts +7 -0
- package/dist/publish/runner/packagePublisher.js +21 -0
- package/dist/publish/runner/publishFailureReporter.d.ts +3 -0
- package/dist/publish/runner/publishFailureReporter.js +14 -0
- package/dist/publish/runner/publishOutputFormatter.d.ts +2 -0
- package/dist/publish/runner/publishOutputFormatter.js +83 -0
- package/dist/publish/runner/publishPreflight.d.ts +8 -0
- package/dist/publish/runner/publishPreflight.js +26 -0
- package/dist/publish/runner/publishSummaryReporter.d.ts +10 -0
- package/dist/publish/runner/publishSummaryReporter.js +81 -0
- package/dist/publish/runner/publishTargetError.d.ts +9 -0
- package/dist/publish/runner/publishTargetError.js +14 -0
- package/dist/publish/runner/releaseGitController.d.ts +10 -0
- package/dist/publish/runner/releaseGitController.js +41 -0
- package/dist/publish/runner/versionWriter.d.ts +13 -0
- package/dist/publish/runner/versionWriter.js +78 -0
- package/dist/publish/targetResolver.d.ts +7 -0
- package/dist/publish/targetResolver.js +195 -0
- package/dist/publish/types.d.ts +70 -0
- package/dist/publish/types.js +0 -0
- package/dist/publish/version.d.ts +5 -0
- package/dist/publish/version.js +55 -0
- package/dist/types.d.ts +8 -7
- package/dist/workspace/packages.d.ts +9 -0
- package/dist/workspace/packages.js +62 -0
- package/dist/workspace/root.d.ts +1 -0
- package/dist/workspace/root.js +14 -0
- package/package.json +15 -7
- package/bin/entry.cjs +0 -163
package/README.md
CHANGED
|
@@ -5,108 +5,140 @@
|
|
|
5
5
|
|
|
6
6
|
</div>
|
|
7
7
|
|
|
8
|
-
|
|
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
|
-
|
|
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.
|
|
13
|
+
It is designed for:
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
- single-package TypeScript libraries;
|
|
16
|
+
- single-package component libraries;
|
|
17
|
+
- pnpm monorepo TypeScript libraries;
|
|
18
|
+
- pnpm monorepo component packages.
|
|
15
19
|
|
|
16
|
-
|
|
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.
|
|
23
|
-
|
|
24
|
-
## Requirements
|
|
20
|
+
Requirements:
|
|
25
21
|
|
|
26
22
|
- Node.js `>=22`
|
|
23
|
+
- pnpm for publish and owner workflows
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
27
26
|
|
|
28
|
-
|
|
27
|
+
`auklet.config.js` or `auklet.config.mjs` is optional. Without it, auklet uses
|
|
28
|
+
`src` as source, `dist` as output, no module output, and default JavaScript
|
|
29
|
+
formats.
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
For a component package, a minimal config usually looks like this:
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
- monorepo component packages;
|
|
35
|
-
- monorepo TypeScript libraries.
|
|
33
|
+
```js
|
|
34
|
+
import { defineConfig } from 'auklet';
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
export const config = defineConfig({
|
|
37
|
+
modules: true,
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Build JavaScript and CSS output:
|
|
39
42
|
|
|
40
43
|
```bash
|
|
41
44
|
auk build
|
|
42
|
-
auk build-js
|
|
43
|
-
auk build-css
|
|
44
45
|
```
|
|
45
46
|
|
|
46
|
-
|
|
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
|
|
47
|
+
Import generated CSS entries from the package:
|
|
52
48
|
|
|
53
|
-
|
|
49
|
+
```ts
|
|
50
|
+
import '@scope/ui/style.css';
|
|
51
|
+
import '@scope/ui/components/Button.css';
|
|
52
|
+
```
|
|
54
53
|
|
|
55
|
-
|
|
54
|
+
Use the Vite plugin during local development:
|
|
56
55
|
|
|
57
56
|
```ts
|
|
58
|
-
import
|
|
57
|
+
import { aukletStylePlugin } from 'auklet';
|
|
59
58
|
|
|
60
|
-
export
|
|
61
|
-
|
|
62
|
-
output: 'dist',
|
|
63
|
-
modules: true,
|
|
59
|
+
export default {
|
|
60
|
+
plugins: [aukletStylePlugin()],
|
|
64
61
|
};
|
|
65
62
|
```
|
|
66
63
|
|
|
67
|
-
|
|
64
|
+
## CLI
|
|
68
65
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
The package exposes both `auk` and `auklet`.
|
|
67
|
+
|
|
68
|
+
| Command | Description |
|
|
69
|
+
| ----------------------- | --------------------------------------------------------------------- |
|
|
70
|
+
| `auk dev` | Watch JavaScript and CSS output together. |
|
|
71
|
+
| `auk build` | Remove configured output, then build JavaScript and CSS. |
|
|
72
|
+
| `auk build-js` | Run tsdown with auklet's built-in config unless `--config` is passed. |
|
|
73
|
+
| `auk build-js --watch` | Pass watch mode through to tsdown. |
|
|
74
|
+
| `auk build-css` | Generate CSS output only. |
|
|
75
|
+
| `auk build-css --watch` | Watch source/config/style files and rebuild CSS. |
|
|
76
|
+
| `auk publish` | Run the pnpm-based publish workflow. |
|
|
77
|
+
| `auk owner add <user>` | Add npm owners through pnpm. |
|
|
78
|
+
|
|
79
|
+
Build and dev commands can override package config for one run:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
auk build --source source --output build --modules
|
|
83
|
+
auk build --build.formats esm,cjs
|
|
84
|
+
auk build --build.target es2022
|
|
85
|
+
auk build --build.platform node
|
|
86
|
+
auk build --build.tsconfig tsconfig.build.json
|
|
72
87
|
```
|
|
73
88
|
|
|
74
|
-
|
|
89
|
+
Supported build override flags:
|
|
75
90
|
|
|
76
|
-
|
|
91
|
+
| Flag | Description |
|
|
92
|
+
| ----------------------------- | -------------------------------------------- |
|
|
93
|
+
| `--source <dir>` | Source directory. |
|
|
94
|
+
| `--output <dir>` | Output directory. |
|
|
95
|
+
| `--modules` | Enable unbundled module output. |
|
|
96
|
+
| `--no-modules` | Disable unbundled module output. |
|
|
97
|
+
| `--build.formats <formats>` | Comma-separated `cjs`, `esm`, and/or `iife`. |
|
|
98
|
+
| `--build.target <target>` | JavaScript target passed to tsdown. |
|
|
99
|
+
| `--build.platform <platform>` | `node`, `neutral`, or `browser`. |
|
|
100
|
+
| `--build.tsconfig <file>` | TypeScript config file. |
|
|
77
101
|
|
|
78
|
-
|
|
102
|
+
Config precedence:
|
|
103
|
+
|
|
104
|
+
```text
|
|
105
|
+
CLI flags > auklet.config.js / auklet.config.mjs > auklet defaults
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
`build-js` passes unknown flags through to tsdown. Auklet build override flags
|
|
109
|
+
cannot be combined with tsdown custom config flags:
|
|
79
110
|
|
|
80
111
|
```bash
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
pnpm auk build-js --watch
|
|
86
|
-
pnpm auk build-css
|
|
87
|
-
pnpm auk build-css --watch
|
|
112
|
+
# not allowed
|
|
113
|
+
auk build-js --source source --config tsdown.config.ts
|
|
114
|
+
auk build-js --output build -c tsdown.config.ts
|
|
115
|
+
auk build-js --modules --no-config
|
|
88
116
|
```
|
|
89
117
|
|
|
90
|
-
|
|
118
|
+
When `--config`, `-c`, or `--no-config` is used, tsdown owns the full build
|
|
119
|
+
config. Use auklet config files or tsdown config code directly instead of
|
|
120
|
+
auklet CLI overrides.
|
|
91
121
|
|
|
92
|
-
|
|
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.
|
|
122
|
+
Publish controls stay on CLI flags:
|
|
101
123
|
|
|
102
|
-
|
|
124
|
+
```bash
|
|
125
|
+
auk publish --filter @scope/ui
|
|
126
|
+
auk publish --version patch --dry-run
|
|
127
|
+
auk publish --no-format
|
|
128
|
+
```
|
|
103
129
|
|
|
104
|
-
|
|
130
|
+
`--no-format` disables auklet's publish output formatter for that run. It is not
|
|
131
|
+
configured in `package.json`.
|
|
105
132
|
|
|
106
|
-
|
|
107
|
-
|
|
133
|
+
## Configuration
|
|
134
|
+
|
|
135
|
+
`auklet.config.js` or `auklet.config.mjs` is loaded from the current package
|
|
136
|
+
root. Config files must export a named `config` binding:
|
|
137
|
+
|
|
138
|
+
```js
|
|
139
|
+
import { defineConfig } from 'auklet';
|
|
108
140
|
|
|
109
|
-
export const config
|
|
141
|
+
export const config = defineConfig({
|
|
110
142
|
source: 'src',
|
|
111
143
|
output: 'dist',
|
|
112
144
|
modules: true,
|
|
@@ -125,242 +157,33 @@ export const config: AukletConfig = {
|
|
|
125
157
|
},
|
|
126
158
|
},
|
|
127
159
|
},
|
|
128
|
-
};
|
|
160
|
+
});
|
|
129
161
|
```
|
|
130
162
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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
|
-
```
|
|
362
|
-
|
|
363
|
-
A common component-library dependency rule looks like this:
|
|
163
|
+
Configuration reference:
|
|
164
|
+
|
|
165
|
+
| Path | Default | Description |
|
|
166
|
+
| ------------------------------------- | ------------------------ | --------------------------------------------------------------------------------------------------------------------------- |
|
|
167
|
+
| `source` | `'src'` | Source directory relative to the current package root. |
|
|
168
|
+
| `output` | `'dist'` | Build output directory. `auk build` removes it before rebuilding. |
|
|
169
|
+
| `modules` | `false` | Generate unbundled module JS output and module-level CSS output. |
|
|
170
|
+
| `styles.themes` | `{}` | Current package theme entries, keyed by theme name. Values are paths relative to the current package root. |
|
|
171
|
+
| `styles.dependencies` | `{}` | External package style rules, keyed by dependency package name. |
|
|
172
|
+
| `styles.dependencies[pkg].entry` | `undefined` | Package-level style entry or entries from the dependency package. |
|
|
173
|
+
| `styles.dependencies[pkg].themes` | `undefined` | Theme entries from the dependency package, keyed by current package theme name. |
|
|
174
|
+
| `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`. |
|
|
175
|
+
| `build.formats` | `['cjs', 'esm', 'iife']` | Package-level bundle formats. |
|
|
176
|
+
| `build.target` | `'es2020'` | JavaScript target passed to tsdown. |
|
|
177
|
+
| `build.platform` | `'neutral'` | Runtime platform: `node`, `neutral`, or `browser`. |
|
|
178
|
+
| `build.banner` | generated | Custom bundle banner. |
|
|
179
|
+
| `build.externals` | `[]` | Extra external package names combined with package dependencies. |
|
|
180
|
+
| `build.alias` | `{}` | Path aliases passed to tsdown. |
|
|
181
|
+
| `build.mainFields` | IIFE only | Package entry field resolution order for bundle output. |
|
|
182
|
+
| `build.globals` | `{}` | Global names for IIFE externals. |
|
|
183
|
+
| `build.tsconfig` | nearest `tsconfig.json` | TypeScript config path relative to package root. |
|
|
184
|
+
| `build.configureTsdown` | `undefined` | Final hook for each generated tsdown config. |
|
|
185
|
+
|
|
186
|
+
Common dependency rule:
|
|
364
187
|
|
|
365
188
|
```ts
|
|
366
189
|
{
|
|
@@ -373,12 +196,24 @@ A common component-library dependency rule looks like this:
|
|
|
373
196
|
}
|
|
374
197
|
```
|
|
375
198
|
|
|
376
|
-
|
|
199
|
+
`configureTsdown` receives the generated tsdown config and a context:
|
|
200
|
+
|
|
201
|
+
```ts
|
|
202
|
+
type ConfigureTsdownContext = {
|
|
203
|
+
kind: 'bundle' | 'module';
|
|
204
|
+
format: 'cjs' | 'esm' | 'iife';
|
|
205
|
+
packageRoot: string;
|
|
206
|
+
output: string;
|
|
207
|
+
packageName?: string;
|
|
208
|
+
};
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## CSS Conventions And Limits
|
|
377
212
|
|
|
378
213
|
CSS auto import only scans `.tsx` files. `.ts` and `.d.ts` files do not
|
|
379
|
-
participate
|
|
214
|
+
participate.
|
|
380
215
|
|
|
381
|
-
Supported syntax:
|
|
216
|
+
Supported source syntax:
|
|
382
217
|
|
|
383
218
|
```tsx
|
|
384
219
|
import { Button } from '@scope/ui';
|
|
@@ -403,28 +238,35 @@ final exported component names, so it cannot infer CSS paths safely.
|
|
|
403
238
|
|
|
404
239
|
Inference rules:
|
|
405
240
|
|
|
406
|
-
- Package-root named imports use the imported name. For example,
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
- Deep imports use the import path. For example,
|
|
412
|
-
`import { Anything } from '@scope/ui/components/Button'` tries to generate
|
|
241
|
+
- Package-root named imports use the imported name. For example, `Button` from
|
|
242
|
+
`@scope/ui` tries `@scope/ui/components/Button.css`.
|
|
243
|
+
- Local aliases do not affect package-root inference. `Button as UIButton`
|
|
244
|
+
still uses `Button`.
|
|
245
|
+
- Deep imports use the import path. `@scope/ui/components/Button` tries
|
|
413
246
|
`@scope/ui/components/Button.css`.
|
|
414
|
-
-
|
|
415
|
-
|
|
416
|
-
- If JavaScript auto inference and handwritten source CSS `@import` point to the
|
|
417
|
-
same file, auklet dedupes the import.
|
|
247
|
+
- Missing inferred CSS files are skipped.
|
|
248
|
+
- Duplicate imports inferred from JS and handwritten source CSS are deduped.
|
|
418
249
|
|
|
419
250
|
Same-package source imports can be resolved through:
|
|
420
251
|
|
|
421
|
-
- relative paths
|
|
252
|
+
- relative paths such as `../Button`;
|
|
422
253
|
- `package.json#imports`, preferring the `source` condition;
|
|
423
254
|
- `tsconfig.json` `compilerOptions.paths`.
|
|
424
255
|
|
|
425
256
|
Only candidates resolved into the current package `source` directory are treated
|
|
426
257
|
as same-package CSS dependencies.
|
|
427
258
|
|
|
259
|
+
`build-css` handles CSS entry generation and simple `@import` expansion. It does
|
|
260
|
+
not aim to replace a full CSS toolchain. In particular, keep these boundaries in
|
|
261
|
+
mind:
|
|
262
|
+
|
|
263
|
+
- It does not process preprocessors such as Sass or Less.
|
|
264
|
+
- It does not implement CSS Modules.
|
|
265
|
+
- It does not perform URL rebasing.
|
|
266
|
+
- It does not evaluate conditional CSS import semantics beyond auklet's style
|
|
267
|
+
entry rules.
|
|
268
|
+
- It expects source CSS files and package/style paths to exist on disk.
|
|
269
|
+
|
|
428
270
|
## CSS Output
|
|
429
271
|
|
|
430
272
|
`build-css` generates package-level `index.css` when source styles exist.
|
|
@@ -473,10 +315,7 @@ output is not a completely empty file.
|
|
|
473
315
|
into virtual CSS modules. It only applies to the Vite dev server; production
|
|
474
316
|
builds still use `auk build` or `auk build-css`.
|
|
475
317
|
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
The plugin defaults to single-package mode. Vite root is treated as the current
|
|
479
|
-
package root:
|
|
318
|
+
Single-package mode is the default:
|
|
480
319
|
|
|
481
320
|
```ts
|
|
482
321
|
import { aukletStylePlugin } from 'auklet';
|
|
@@ -486,19 +325,8 @@ export default {
|
|
|
486
325
|
};
|
|
487
326
|
```
|
|
488
327
|
|
|
489
|
-
|
|
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
|
|
499
|
-
|
|
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:
|
|
328
|
+
Use monorepo mode when a workspace demo/app needs to work with multiple
|
|
329
|
+
workspace packages:
|
|
502
330
|
|
|
503
331
|
```ts
|
|
504
332
|
import { aukletStylePlugin } from 'auklet';
|
|
@@ -508,28 +336,14 @@ export default {
|
|
|
508
336
|
};
|
|
509
337
|
```
|
|
510
338
|
|
|
511
|
-
|
|
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.
|
|
339
|
+
Primary options:
|
|
529
340
|
|
|
530
|
-
|
|
341
|
+
| Option | Default | Description |
|
|
342
|
+
| ------ | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
343
|
+
| `mode` | `'package'` | `'package'` treats Vite root as the package root. `'monorepo'` finds `pnpm-workspace.yaml` upward from Vite root and reads pnpm workspace packages. |
|
|
344
|
+
| `root` | inferred | Custom graph root. Usually unnecessary. |
|
|
531
345
|
|
|
532
|
-
|
|
346
|
+
Supported dev CSS imports:
|
|
533
347
|
|
|
534
348
|
```ts
|
|
535
349
|
import '@scope/app/style.css';
|
|
@@ -539,13 +353,10 @@ import '@scope/app/components/Button.css';
|
|
|
539
353
|
import '@scope/app/themes/light.css';
|
|
540
354
|
```
|
|
541
355
|
|
|
542
|
-
### Dependency Resolution
|
|
543
|
-
|
|
544
356
|
In dev mode, workspace package style dependencies keep using auklet virtual CSS
|
|
545
357
|
recursion so style changes across packages can be tracked. Third-party CSS
|
|
546
358
|
dependencies are resolved from the package root that declares them and emitted
|
|
547
|
-
as Vite `/@fs/...` imports
|
|
548
|
-
virtual modules.
|
|
359
|
+
as Vite `/@fs/...` imports.
|
|
549
360
|
|
|
550
361
|
## Build Constants
|
|
551
362
|
|
|
@@ -561,58 +372,37 @@ Vitest uses test-friendly values with the same names: `__DEV__` is `true`,
|
|
|
561
372
|
|
|
562
373
|
## Programmatic API
|
|
563
374
|
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
aukletStylePlugin,
|
|
569
|
-
loadAukletConfig,
|
|
570
|
-
runTsdown,
|
|
571
|
-
} from 'auklet';
|
|
572
|
-
|
|
573
|
-
const aukletConfig = await loadAukletConfig(process.cwd());
|
|
574
|
-
|
|
575
|
-
await new ModuleStyleBuilder({
|
|
576
|
-
packageRoot: process.cwd(),
|
|
577
|
-
aukletConfig,
|
|
578
|
-
}).build();
|
|
579
|
-
```
|
|
375
|
+
The root package entry exposes the Vite plugin, configuration helpers, and a
|
|
376
|
+
small set of build helpers used by projects that need to compose auklet
|
|
377
|
+
programmatically. Publish and owner workflows remain CLI/internal implementation
|
|
378
|
+
details.
|
|
580
379
|
|
|
581
380
|
Public exports include:
|
|
582
381
|
|
|
583
|
-
- `ModuleStyleBuilder`
|
|
584
|
-
- `ModuleStyleWatcher`
|
|
585
382
|
- `aukletStylePlugin`
|
|
586
383
|
- `loadAukletConfig`
|
|
587
|
-
- `resolveAukletConfigModule`
|
|
588
|
-
- `createTsdownArgs`
|
|
589
384
|
- `runTsdown`
|
|
590
|
-
-
|
|
385
|
+
- `defineKernelPackageConfigFromFile`
|
|
386
|
+
- `defineKernelPackageConfigFromOptions`
|
|
387
|
+
- `runAukletCli`
|
|
388
|
+
- `AukletStylePluginOptions`
|
|
389
|
+
- `AukletConfig`
|
|
390
|
+
- `PackageBuildOptions`
|
|
391
|
+
- `StyleOptions`
|
|
392
|
+
- related user-facing TypeScript types
|
|
591
393
|
|
|
592
394
|
## Development
|
|
593
395
|
|
|
594
396
|
```bash
|
|
595
397
|
pnpm i
|
|
596
|
-
pnpm
|
|
597
|
-
pnpm
|
|
598
|
-
pnpm
|
|
398
|
+
pnpm test
|
|
399
|
+
pnpm typecheck
|
|
400
|
+
pnpm build
|
|
599
401
|
pnpm run format
|
|
600
402
|
```
|
|
601
403
|
|
|
602
404
|
Notes:
|
|
603
405
|
|
|
604
|
-
- `pnpm
|
|
406
|
+
- `pnpm build` rewrites `dist`.
|
|
605
407
|
- `pnpm run format` formats `bin`, `src`, `dist`, `examples`, and related files.
|
|
606
408
|
- Read `TESTING.md` before changing tests.
|
|
607
|
-
|
|
608
|
-
## Testing
|
|
609
|
-
|
|
610
|
-
Tests are organized into:
|
|
611
|
-
|
|
612
|
-
- `src/__tests__/e2e`: project-level output structure and dependency-chain tests.
|
|
613
|
-
- `src/__tests__/css`: CSS/style module and API tests.
|
|
614
|
-
- `src/__tests__/fixtures`: shared virtual project and style structure helpers.
|
|
615
|
-
- `src/__tests__/build`: tsdown/build config tests.
|
|
616
|
-
|
|
617
|
-
Temporary test projects are created under `src/__tests__/.tmp/` and ignored by
|
|
618
|
-
git.
|