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.
- package/LICENSE +21 -0
- package/README.md +255 -174
- package/bin/entry.mjs +5 -0
- package/dist/build/bundleConfig.js +1 -1
- 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/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 +7 -6
- package/dist/css/vite/moduleGraph/graph.js +0 -1
- package/dist/css/vite/moduleGraph/packageSource/monorepo.d.ts +5 -1
- package/dist/css/vite/moduleGraph/packageSource/monorepo.js +40 -31
- 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 +3 -10
- package/dist/index.d.ts +5 -7
- package/dist/index.js +4 -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 +34 -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 +52 -0
- package/dist/publish/cli.d.ts +2 -0
- package/dist/publish/cli.js +94 -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 +15 -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 -6
- 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
|
-
|
|
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
|
-
|
|
13
|
+
It is designed for:
|
|
11
14
|
|
|
12
|
-
|
|
15
|
+
- single-package TypeScript libraries;
|
|
16
|
+
- single-package component libraries;
|
|
17
|
+
- pnpm monorepo TypeScript libraries;
|
|
18
|
+
- pnpm monorepo component packages.
|
|
13
19
|
|
|
14
|
-
|
|
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
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
-
|
|
197
|
+
`configureTsdown` receives the generated tsdown config and a context:
|
|
102
198
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
211
|
+
CSS auto import only scans `.tsx` files. `.ts` and `.d.ts` files do not
|
|
212
|
+
participate.
|
|
116
213
|
|
|
117
|
-
Supported
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
248
|
+
Same-package source imports can be resolved through:
|
|
163
249
|
|
|
164
|
-
-
|
|
165
|
-
- `
|
|
166
|
-
- `
|
|
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
|
-
|
|
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`
|
|
270
|
+
`build-css` generates package-level `index.css` when source styles exist.
|
|
173
271
|
|
|
174
|
-
|
|
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
|
|
275
|
+
Typical output structure:
|
|
177
276
|
|
|
178
277
|
```text
|
|
179
278
|
dist/
|
|
@@ -194,18 +293,27 @@ dist/
|
|
|
194
293
|
...
|
|
195
294
|
```
|
|
196
295
|
|
|
197
|
-
|
|
296
|
+
Entry semantics:
|
|
198
297
|
|
|
199
298
|
- `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.
|
|
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
|
-
|
|
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
|
-
|
|
219
|
-
|
|
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
|
-
|
|
234
|
-
|
|
235
|
-
|
|
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
|
-
|
|
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
|
-
|
|
247
|
-
resolved from the package that declares
|
|
248
|
-
`/@fs/...` imports
|
|
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
|
-
##
|
|
359
|
+
## Build Constants
|
|
252
360
|
|
|
253
|
-
|
|
361
|
+
`auk build` injects these compile-time constants into bundles:
|
|
254
362
|
|
|
255
|
-
- `
|
|
256
|
-
|
|
257
|
-
- `
|
|
258
|
-
- `
|
|
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
|
-
|
|
263
|
-
|
|
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
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
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
|
-
-
|
|
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
|
|
303
|
-
pnpm
|
|
304
|
-
pnpm
|
|
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
|
|
311
|
-
- `pnpm run format` formats `bin`, `src`, and
|
|
312
|
-
- `TESTING.md`
|
|
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
|
@@ -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>;
|