@aemvite/aem-config 0.1.0

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 (44) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/LICENSE +21 -0
  3. package/README.md +278 -0
  4. package/dist/buildClientlibs.d.ts +45 -0
  5. package/dist/buildClientlibs.d.ts.map +1 -0
  6. package/dist/buildClientlibs.js +67 -0
  7. package/dist/buildClientlibs.js.map +1 -0
  8. package/dist/cli.d.ts +3 -0
  9. package/dist/cli.d.ts.map +1 -0
  10. package/dist/cli.js +60 -0
  11. package/dist/cli.js.map +1 -0
  12. package/dist/clientlibEmitter.d.ts +21 -0
  13. package/dist/clientlibEmitter.d.ts.map +1 -0
  14. package/dist/clientlibEmitter.js +26 -0
  15. package/dist/clientlibEmitter.js.map +1 -0
  16. package/dist/defaults.d.ts +14 -0
  17. package/dist/defaults.d.ts.map +1 -0
  18. package/dist/defaults.js +21 -0
  19. package/dist/defaults.js.map +1 -0
  20. package/dist/defineAemConfig.d.ts +18 -0
  21. package/dist/defineAemConfig.d.ts.map +1 -0
  22. package/dist/defineAemConfig.js +19 -0
  23. package/dist/defineAemConfig.js.map +1 -0
  24. package/dist/index.d.ts +9 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +8 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/loadAemConfig.d.ts +10 -0
  29. package/dist/loadAemConfig.d.ts.map +1 -0
  30. package/dist/loadAemConfig.js +49 -0
  31. package/dist/loadAemConfig.js.map +1 -0
  32. package/dist/mergeDefaults.d.ts +13 -0
  33. package/dist/mergeDefaults.d.ts.map +1 -0
  34. package/dist/mergeDefaults.js +35 -0
  35. package/dist/mergeDefaults.js.map +1 -0
  36. package/dist/resolveBuildOptions.d.ts +15 -0
  37. package/dist/resolveBuildOptions.d.ts.map +1 -0
  38. package/dist/resolveBuildOptions.js +41 -0
  39. package/dist/resolveBuildOptions.js.map +1 -0
  40. package/dist/types.d.ts +77 -0
  41. package/dist/types.d.ts.map +1 -0
  42. package/dist/types.js +2 -0
  43. package/dist/types.js.map +1 -0
  44. package/package.json +68 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,23 @@
1
+ # Changelog
2
+
3
+ All notable changes to **@aemvite/aem-config** will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.0] - 2026-06-25
9
+
10
+ ### Added
11
+
12
+ - Initial public release.
13
+ - `defineAemConfig()` typed identity helper and `loadAemConfig()` loader for
14
+ `.ts` / `.mts` / `.js` / `.mjs` config files (`.ts` loaded via Vite's bundled
15
+ esbuild — no extra runtime loader).
16
+ - `buildClientlibs()` orchestrator that runs one Vite library build per
17
+ clientlib entry into a shared `outDir` and invokes the clientlib emitter.
18
+ - `BuildOptions` API with three-layer resolution (mode baseline → global
19
+ `AemConfig.build` → per-clientlib `AemClientlib.build`) controlling
20
+ `minify`, `sourcemap`, and `target`, plus `resolveBuildOptions()` for
21
+ tooling/tests.
22
+ - `aem-build` CLI (`--mode`, `--config`, `--out-dir`) for invoking the
23
+ orchestrator from `npm` scripts.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Luca Nerlich
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 all
13
+ 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 THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,278 @@
1
+ # @aemvite/aem-config
2
+
3
+ > Typed config helper, loader, and Vite build orchestrator for AEM
4
+ > `ui.frontend` clientlibs.
5
+
6
+ `@aemvite/aem-config` is the entry point of the [`@aemvite/*`](https://github.com/LucaNerlich/aem-vite)
7
+ toolchain. It lets you declare one or more AEM clientlibs in a typed
8
+ `aem.config.ts`, then drives one Vite library build per entry into a shared
9
+ `outDir` and hands off to
10
+ [`@aemvite/vite-plugin-aem-clientlib`](https://github.com/LucaNerlich/aem-vite/tree/main/packages/vite-plugin-aem-clientlib)
11
+ to emit byte-identical `.content.xml` / `js.txt` / `css.txt` descriptors.
12
+
13
+ It replaces two legacy pieces in an AEM `ui.frontend` Maven module: the
14
+ hand-maintained split webpack entry configuration **and** the
15
+ `aem-clientlib-generator` `clientlib.config.js`.
16
+
17
+ ## Install
18
+
19
+ ```sh
20
+ # Vite 8 makes `esbuild` an OPTIONAL peer dependency — install it explicitly
21
+ # alongside `vite`, otherwise `npm run prod` fails with `Cannot find package 'esbuild'`.
22
+ npm i -D @aemvite/aem-config vite esbuild
23
+ # Sass is only needed if your entries import .scss/.sass
24
+ npm i -D sass
25
+ ```
26
+
27
+ - **Peer dependency:** `vite` `^7 || ^8` (with Vite 8 also requires `esbuild` `^0.27.0 || ^0.28.0` — Vite declares it as an optional peer, so consumers must install it explicitly)
28
+ - **Engines:** Node `^20.19.0 || >=22.12.0`
29
+ - Depends on `@aemvite/vite-plugin-aem-clientlib` (installed automatically).
30
+
31
+ ## What it does
32
+
33
+ - Lets you declare every clientlib as plain data (`name`, `entry`,
34
+ `categories`, …) instead of hand-writing webpack entry blobs.
35
+ - Loads your `aem.config.ts` via Vite's bundled esbuild — no `jiti`, no
36
+ pre-compile step.
37
+ - Resolves per-clientlib build options (`minify`, `sourcemap`, `target`) in
38
+ three layers: mode baseline → global → per-clientlib.
39
+ - Runs one Vite library build per entry with `inlineDynamicImports: true`
40
+ into a shared `outDir`, then triggers the clientlib descriptor emitter.
41
+ - Ships an `aem-build` CLI you can call from `npm` scripts (so Maven's
42
+ `frontend-maven-plugin` stays unchanged).
43
+
44
+ ## Quick start
45
+
46
+ ```ts
47
+ // aem.config.ts
48
+ import { defineAemConfig } from "@aemvite/aem-config";
49
+
50
+ export default defineAemConfig({
51
+ clientLibRoot: "../ui.apps/src/main/content/jcr_root/apps/aemvite/clientlibs",
52
+ clientlibs: [
53
+ {
54
+ name: "site",
55
+ entry: "src/main.ts",
56
+ categories: ["aemvite.site"],
57
+ dependencies: ["aemvite.dependencies"],
58
+ },
59
+ {
60
+ name: "dependencies",
61
+ entry: "src/deps.ts",
62
+ categories: ["aemvite.dependencies"],
63
+ },
64
+ ],
65
+ });
66
+ ```
67
+
68
+ Run a build:
69
+
70
+ ```sh
71
+ npx aem-build --mode production --config aem.config.ts
72
+ ```
73
+
74
+ Wire it into `package.json`:
75
+
76
+ ```json
77
+ {
78
+ "scripts": {
79
+ "dev": "aem-build --mode development",
80
+ "prod": "aem-build --mode production"
81
+ }
82
+ }
83
+ ```
84
+
85
+ ## Config shape
86
+
87
+ ### `AemConfig`
88
+
89
+ | Field | Type | Default | Notes |
90
+ |---|---|---|---|
91
+ | `clientLibRoot` | `string` | — | Output root for emitted `clientlib-<name>/` folders. Absolute or relative to the config file. |
92
+ | `clientlibs` | `AemClientlib[]` | — | One entry per clientlib folder. |
93
+ | `defaults` | `Partial<AemClientlib>` | `{}` | Per-clientlib defaults merged into every entry (per-clientlib values win). |
94
+ | `build` | `BuildOptions` | `{}` | Global build overrides; layered under per-clientlib `build` (see below). |
95
+
96
+ ### `AemClientlib`
97
+
98
+ | Field | Type | Default | Notes |
99
+ |---|---|---|---|
100
+ | `name` | `string` | — | Clientlib folder name (e.g. `"site"` → `clientlib-site`). |
101
+ | `entry` | `string` | — | Path to the entry source file (relative to the config dir or absolute). Empty string is allowed for descriptor-only clientlibs. |
102
+ | `categories` | `readonly string[]` | — | AEM `categories="[...]"`. Required, non-empty. |
103
+ | `dependencies` | `readonly string[]` | _(omitted)_ | AEM `dependencies="[...]"`. Omitted from `.content.xml` when empty/undefined. |
104
+ | `embed` | `readonly string[]` | _(none)_ | Embedded clientlib categories. |
105
+ | `resources` | `readonly string[]` | _(none)_ | Resource directories to copy into the clientlib's `resources/` folder. |
106
+ | `allowProxy` | `boolean` | `true` | `allowProxy="{Boolean}…"`. |
107
+ | `serializationFormat` | `"xml"` | `"xml"` | `.content.xml` serialization format. |
108
+ | `cssProcessor` | `readonly string[]` | `["default:none","min:none"]` | AEM CSS processor directives. |
109
+ | `jsProcessor` | `readonly string[]` | `["default:none","min:none"]` | AEM JS processor directives. |
110
+ | `build` | `BuildOptions` | `{}` | Per-clientlib build overrides; layered over `AemConfig.build`. |
111
+
112
+ Array fields (`cssProcessor`, `jsProcessor`, `dependencies`, `embed`,
113
+ `categories`, `resources`) are replaced wholesale rather than concatenated when
114
+ defaults are merged.
115
+
116
+ ## Multiple clientlibs
117
+
118
+ Every clientlib runs as its own Vite library build into the same `dist/`. The
119
+ first build clears the directory; subsequent builds accumulate. Each entry
120
+ inherits `defaults`, then its own values, then its own `build` overrides.
121
+
122
+ ```ts
123
+ export default defineAemConfig({
124
+ clientLibRoot: "../clientlibs",
125
+ defaults: { allowProxy: true },
126
+ clientlibs: [
127
+ { name: "site", entry: "src/main.ts", categories: ["aemvite.site"] },
128
+ { name: "admin", entry: "src/admin.ts", categories: ["aemvite.admin"] },
129
+ ],
130
+ });
131
+ ```
132
+
133
+ ## Build options (`BuildOptions`)
134
+
135
+ ```ts
136
+ type BuildOptions = {
137
+ minify?: boolean | { js?: boolean; css?: boolean };
138
+ sourcemap?: boolean | "inline" | "hidden";
139
+ target?: string | string[];
140
+ };
141
+ ```
142
+
143
+ ### Resolution order
144
+
145
+ Lowest → highest precedence:
146
+
147
+ 1. **Mode baseline**
148
+ - `development`: `{ minify: false, sourcemap: "inline" }`
149
+ - `production`: `{ minify: { js: true, css: true }, sourcemap: false }`
150
+ - Default `target` = `"es2015"`.
151
+ 2. **Global** `AemConfig.build` — applied to every clientlib.
152
+ 3. **Per-clientlib** `AemClientlib.build` — wins over the global block.
153
+
154
+ `minify`: a boolean toggles both JS and CSS; the object form overrides a single
155
+ asset and lets the other fall through to the next layer. So in production,
156
+ `{ minify: { js: false } }` on a clientlib keeps CSS minification on.
157
+
158
+ `sourcemap` and `target` are simple overrides — the higher layer wins entirely.
159
+
160
+ ### Global override
161
+
162
+ ```ts
163
+ export default defineAemConfig({
164
+ clientLibRoot: "../clientlibs",
165
+ build: { sourcemap: "hidden", target: "es2020" },
166
+ clientlibs: [
167
+ { name: "site", entry: "src/main.ts", categories: ["aemvite.site"] },
168
+ ],
169
+ });
170
+ ```
171
+
172
+ ### Per-clientlib override
173
+
174
+ ```ts
175
+ export default defineAemConfig({
176
+ clientLibRoot: "../clientlibs",
177
+ build: { minify: true },
178
+ clientlibs: [
179
+ {
180
+ name: "site",
181
+ entry: "src/main.ts",
182
+ categories: ["aemvite.site"],
183
+ // CSS only — keep JS minified per the global block.
184
+ build: { minify: { css: false }, sourcemap: "inline" },
185
+ },
186
+ {
187
+ name: "admin",
188
+ entry: "src/admin.ts",
189
+ categories: ["aemvite.admin"],
190
+ build: { target: ["es2018", "chrome70"] },
191
+ },
192
+ ],
193
+ });
194
+ ```
195
+
196
+ ## Backward compatibility
197
+
198
+ With no `build` set anywhere, resolved options match the mode baselines:
199
+
200
+ | Mode | JS minify | CSS minify | sourcemap | target |
201
+ |---|---|---|---|---|
202
+ | `development` | off | off | `"inline"` | `"es2015"` |
203
+ | `production` | on (esbuild) | on (esbuild) | off | `"es2015"` |
204
+
205
+ Emitted clientlib descriptors (`.content.xml`, `js.txt`, `css.txt`) are
206
+ unaffected by build options and remain byte-identical to the golden reference.
207
+
208
+ ## API
209
+
210
+ All exports from `@aemvite/aem-config`:
211
+
212
+ ### Functions
213
+
214
+ | Export | Signature | Effect |
215
+ |---|---|---|
216
+ | `defineAemConfig` | `(config: AemConfig) => AemConfig` | Typed identity helper for `aem.config.ts`. |
217
+ | `loadAemConfig` | `(path: string) => Promise<ResolvedAemConfig>` | Load a `.ts`/`.mts`/`.cts` config via Vite's bundled esbuild (`loadConfigFromFile`), or a `.js`/`.mjs` config via dynamic `import()`. Merges defaults before returning. |
218
+ | `mergeDefaults` | `(config: AemConfig) => ResolvedAemConfig` | Apply package + user `defaults` to every clientlib. |
219
+ | `resolveBuildOptions` | `(mode: BuildMode, global?: BuildOptions, perClientlib?: BuildOptions) => ResolvedBuildOptions` | Resolve the three-layer build options for a single clientlib. Exported for tooling and tests. |
220
+ | `buildClientlibs` | `(options: BuildClientlibsOptions & { emitter?: ClientlibEmitter \| null }) => Promise<{ config: ResolvedAemConfig; outDir: string }>` | Run one Vite library build per entry into `outDir`, then invoke the clientlib emitter. Pass `emitter: null` to skip emission (e.g. in tests). |
221
+ | `resolveClientlibEmitter` | `() => Promise<ClientlibEmitter \| null>` | Optionally resolve the emitter from `@aemvite/vite-plugin-aem-clientlib`. Returns `null` if not installed. |
222
+
223
+ ### Constants
224
+
225
+ | Export | Type | Value |
226
+ |---|---|---|
227
+ | `defaults` | `Required<Pick<AemClientlib, "allowProxy" \| "serializationFormat" \| "cssProcessor" \| "jsProcessor">>` | Built-in per-clientlib defaults (see `AemClientlib` table). |
228
+ | `modeBaselines` | `Record<BuildMode, BuildOptions>` | `development`: `{ minify: false, sourcemap: "inline" }`. `production`: `{ minify: { js: true, css: true }, sourcemap: false }`. |
229
+ | `defaultTarget` | `string` | `"es2015"`. |
230
+
231
+ ### Types
232
+
233
+ `AemConfig`, `AemClientlib`, `BuildOptions`, `BuildMode`, `BuildClientlibsOptions`,
234
+ `ProcessorList`, `ResolvedAemClientlib`, `ResolvedAemConfig`,
235
+ `ResolvedBuildOptions`, `ClientlibEmitter`, `ClientlibEmitterInput`.
236
+
237
+ ## CLI: `aem-build`
238
+
239
+ ```
240
+ Usage: aem-build [options]
241
+
242
+ Options:
243
+ --mode, -m <dev|prod|development|production> Build mode (default: production)
244
+ --config, -c <path> Path to aem.config.ts
245
+ (default: ./aem.config.ts,
246
+ then .mts, then .js)
247
+ --out-dir, -o <path> Output directory
248
+ (default: ./dist)
249
+ -h, --help Show help
250
+ ```
251
+
252
+ Both shorthand (`dev`/`prod`) and full (`development`/`production`) mode names
253
+ are accepted. The CLI exits with code `1` and prints the error stack on any
254
+ failure.
255
+
256
+ ## Notes & caveats
257
+
258
+ - **Per-entry isolation:** every clientlib runs as its own `vite build()` with
259
+ `inlineDynamicImports: true`, so code-splitting between clientlibs is by
260
+ design impossible — each clientlib produces a single `.js` and (optional)
261
+ `.css`. Share code via a dedicated `dependencies` clientlib instead.
262
+ - **`outDir` lifecycle:** `emptyOutDir: true` is set only for the first build;
263
+ subsequent builds accumulate into the same `dist/`. Don't run two
264
+ `buildClientlibs()` invocations against the same `outDir` in parallel.
265
+ - **`.ts` config loading:** uses Vite's `loadConfigFromFile`. Vite is imported
266
+ lazily so tests that stub the loader don't pay the startup cost.
267
+ - **Descriptor parity:** build options never affect emitted descriptors —
268
+ `.content.xml`, `js.txt`, and `css.txt` remain byte-identical to the golden
269
+ reference regardless of mode, minify, or sourcemap settings.
270
+
271
+ ## License
272
+
273
+ [MIT](./LICENSE) © Luca Nerlich
274
+
275
+ ## Repository
276
+
277
+ <https://github.com/LucaNerlich/aem-vite> (this package lives in
278
+ [`packages/aem-config`](https://github.com/LucaNerlich/aem-vite/tree/main/packages/aem-config)).
@@ -0,0 +1,45 @@
1
+ import { type ClientlibEmitter } from "./clientlibEmitter.js";
2
+ import type { BuildClientlibsOptions, BuildMode, BuildOptions, ResolvedAemClientlib, ResolvedAemConfig } from "./types.js";
3
+ export interface BuildClientlibsExtraOptions {
4
+ /** Optional emitter override (mainly for tests). */
5
+ emitter?: ClientlibEmitter | null;
6
+ }
7
+ /**
8
+ * Build every clientlib defined by `configPath` by running one Vite library
9
+ * build per entry into a shared `outDir`, then invoking the clientlib emitter.
10
+ *
11
+ * Dev mode: no minify + inline sourcemap.
12
+ * Prod mode: esbuild minify for JS and CSS + no sourcemap.
13
+ *
14
+ * `emptyOutDir` is set to `true` only for the first build so subsequent builds
15
+ * accumulate into the same `dist/`.
16
+ */
17
+ export declare function buildClientlibs(options: BuildClientlibsOptions & BuildClientlibsExtraOptions): Promise<{
18
+ config: ResolvedAemConfig;
19
+ outDir: string;
20
+ }>;
21
+ export declare function buildOptionsFor(clientlib: ResolvedAemClientlib, configDir: string, outDir: string, mode: BuildMode, isFirst: boolean, globalBuild?: BuildOptions): {
22
+ configFile: false;
23
+ mode: BuildMode;
24
+ logLevel: "warn";
25
+ build: {
26
+ outDir: string;
27
+ emptyOutDir: boolean;
28
+ minify: "esbuild" | false;
29
+ cssMinify: "esbuild" | false;
30
+ sourcemap: boolean | "inline" | "hidden";
31
+ target: string | string[];
32
+ lib: {
33
+ entry: string;
34
+ formats: ("es")[];
35
+ fileName: () => string;
36
+ };
37
+ rollupOptions: {
38
+ output: {
39
+ inlineDynamicImports: boolean;
40
+ assetFileNames: string;
41
+ };
42
+ };
43
+ };
44
+ };
45
+ //# sourceMappingURL=buildClientlibs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildClientlibs.d.ts","sourceRoot":"","sources":["../src/buildClientlibs.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EACV,sBAAsB,EACtB,SAAS,EACT,YAAY,EACZ,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,2BAA2B;IAC1C,oDAAoD;IACpD,OAAO,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;CACnC;AAED;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,sBAAsB,GAAG,2BAA2B,GAC5D,OAAO,CAAC;IAAE,MAAM,EAAE,iBAAiB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAgCxD;AAED,wBAAgB,eAAe,CAC7B,SAAS,EAAE,oBAAoB,EAC/B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,OAAO,EAChB,WAAW,CAAC,EAAE,YAAY;;;;;;;gBAc8B,SAAS,GAAG,KAAK;mBACb,SAAS,GAAG,KAAK;;;;;qBAKpD,CAAC,IAAI,CAAC,EAAE;;;;;;;;;;EAWlC"}
@@ -0,0 +1,67 @@
1
+ import path from "node:path";
2
+ import { loadAemConfig } from "./loadAemConfig.js";
3
+ import { resolveClientlibEmitter, } from "./clientlibEmitter.js";
4
+ import { resolveBuildOptions } from "./resolveBuildOptions.js";
5
+ /**
6
+ * Build every clientlib defined by `configPath` by running one Vite library
7
+ * build per entry into a shared `outDir`, then invoking the clientlib emitter.
8
+ *
9
+ * Dev mode: no minify + inline sourcemap.
10
+ * Prod mode: esbuild minify for JS and CSS + no sourcemap.
11
+ *
12
+ * `emptyOutDir` is set to `true` only for the first build so subsequent builds
13
+ * accumulate into the same `dist/`.
14
+ */
15
+ export async function buildClientlibs(options) {
16
+ const { mode, configPath } = options;
17
+ const configDir = path.dirname(path.resolve(configPath));
18
+ const outDir = path.resolve(configDir, options.outDir ?? "dist");
19
+ const config = await loadAemConfig(configPath);
20
+ const { build } = await import("vite");
21
+ for (let i = 0; i < config.clientlibs.length; i++) {
22
+ const clientlib = config.clientlibs[i];
23
+ await build(buildOptionsFor(clientlib, configDir, outDir, mode, i === 0, config.build));
24
+ }
25
+ const emitter = options.emitter === undefined
26
+ ? await resolveClientlibEmitter()
27
+ : options.emitter;
28
+ if (emitter) {
29
+ await emitter.emit({ config, outDir });
30
+ }
31
+ return { config, outDir };
32
+ }
33
+ export function buildOptionsFor(clientlib, configDir, outDir, mode, isFirst, globalBuild) {
34
+ const entry = path.resolve(configDir, clientlib.entry);
35
+ const entryName = stripExt(path.basename(entry));
36
+ const baseDir = clientlib.name;
37
+ const resolved = resolveBuildOptions(mode, globalBuild, clientlib.build);
38
+ return {
39
+ configFile: false,
40
+ mode,
41
+ logLevel: "warn",
42
+ build: {
43
+ outDir,
44
+ emptyOutDir: isFirst,
45
+ minify: (resolved.minify.js ? "esbuild" : false),
46
+ cssMinify: (resolved.minify.css ? "esbuild" : false),
47
+ sourcemap: resolved.sourcemap,
48
+ target: resolved.target,
49
+ lib: {
50
+ entry,
51
+ formats: ["es"],
52
+ fileName: () => `${baseDir}/${entryName}.js`,
53
+ },
54
+ rollupOptions: {
55
+ output: {
56
+ inlineDynamicImports: true,
57
+ assetFileNames: `${baseDir}/[name][extname]`,
58
+ },
59
+ },
60
+ },
61
+ };
62
+ }
63
+ function stripExt(name) {
64
+ const idx = name.lastIndexOf(".");
65
+ return idx === -1 ? name : name.slice(0, idx);
66
+ }
67
+ //# sourceMappingURL=buildClientlibs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildClientlibs.js","sourceRoot":"","sources":["../src/buildClientlibs.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,uBAAuB,GAExB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAc/D;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,OAA6D;IAE7D,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IACrC,M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{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.js ADDED
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env node
2
+ import { parseArgs } from "node:util";
3
+ import path from "node:path";
4
+ import { existsSync } from "node:fs";
5
+ import { buildClientlibs } from "./buildClientlibs.js";
6
+ const HELP = `Usage: aem-build [options]
7
+
8
+ Options:
9
+ --mode <dev|prod|development|production> Build mode (default: production)
10
+ --config <path> Path to aem.config.ts (default: ./aem.config.ts)
11
+ --out-dir <path> Output directory (default: ./dist)
12
+ -h, --help Show this help`;
13
+ async function main() {
14
+ const args = parse(process.argv.slice(2));
15
+ if (!args)
16
+ return;
17
+ await buildClientlibs(args);
18
+ }
19
+ function parse(argv) {
20
+ const { values } = parseArgs({
21
+ args: argv,
22
+ options: {
23
+ mode: { type: "string", short: "m", default: "production" },
24
+ config: { type: "string", short: "c" },
25
+ "out-dir": { type: "string", short: "o" },
26
+ help: { type: "boolean", short: "h", default: false },
27
+ },
28
+ strict: true,
29
+ allowPositionals: false,
30
+ });
31
+ if (values.help) {
32
+ console.log(HELP);
33
+ return null;
34
+ }
35
+ const mode = normaliseMode(String(values.mode));
36
+ const configPath = path.resolve(String(values.config ?? defaultConfigPath()));
37
+ const outDir = values["out-dir"] ? String(values["out-dir"]) : undefined;
38
+ return { mode, configPath, outDir };
39
+ }
40
+ function normaliseMode(value) {
41
+ if (value === "dev" || value === "development")
42
+ return "development";
43
+ if (value === "prod" || value === "production")
44
+ return "production";
45
+ throw new Error(`Unknown --mode '${value}' (expected dev|prod)`);
46
+ }
47
+ function defaultConfigPath() {
48
+ const candidates = ["aem.config.ts", "aem.config.mts", "aem.config.js"];
49
+ for (const candidate of candidates) {
50
+ const resolved = path.resolve(process.cwd(), candidate);
51
+ if (existsSync(resolved))
52
+ return resolved;
53
+ }
54
+ return "aem.config.ts";
55
+ }
56
+ main().catch((error) => {
57
+ console.error(error instanceof Error ? error.stack ?? error.message : error);
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E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { ResolvedAemConfig } from "./types.js";
2
+ /**
3
+ * Structural contract the build orchestrator expects from any clientlib
4
+ * emitter (implemented by `@aemvite/vite-plugin-aem-clientlib`). Kept here so
5
+ * `@aemvite/aem-config` doesn't hard-depend on its sibling package during
6
+ * parallel wave-2 development.
7
+ */
8
+ export interface ClientlibEmitterInput {
9
+ config: ResolvedAemConfig;
10
+ outDir: string;
11
+ }
12
+ export interface ClientlibEmitter {
13
+ emit(input: ClientlibEmitterInput): Promise<void> | void;
14
+ }
15
+ /**
16
+ * Try to resolve the emitter from `@aemvite/vite-plugin-aem-clientlib`.
17
+ * Returns `null` when the sibling package isn't installed yet so the
18
+ * orchestrator can run (e.g. inside this package's own unit tests).
19
+ */
20
+ export declare function resolveClientlibEmitter(): Promise<ClientlibEmitter | null>;
21
+ //# sourceMappingURL=clientlibEmitter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clientlibEmitter.d.ts","sourceRoot":"","sources":["../src/clientlibEmitter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAC1D;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAuBhF"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Try to resolve the emitter from `@aemvite/vite-plugin-aem-clientlib`.
3
+ * Returns `null` when the sibling package isn't installed yet so the
4
+ * orchestrator can run (e.g. inside this package's own unit tests).
5
+ */
6
+ export async function resolveClientlibEmitter() {
7
+ try {
8
+ const mod = (await import("@aemvite/vite-plugin-aem-clientlib"));
9
+ const fn = mod.emitClientlibs;
10
+ if (typeof fn === "function") {
11
+ return {
12
+ emit: (input) => fn(input),
13
+ };
14
+ }
15
+ const factory = mod.createClientlibEmitter;
16
+ if (typeof factory === "function") {
17
+ const instance = factory();
18
+ return await instance;
19
+ }
20
+ return null;
21
+ }
22
+ catch {
23
+ return null;
24
+ }
25
+ }
26
+ //# sourceMappingURL=clientlibEmitter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clientlibEmitter.js","sourceRoot":"","sources":["../src/clientlibEmitter.ts"],"names":[],"mappings":"AAiBA;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB;IAC3C,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,CAAC,MAAM,MAAM,CACvB,oCAAoC,CACrC,CAA4B,CAAC;QAC9B,MAAM,EAAE,GAAG,GAAG,CAAC,cAAc,CAAC;QAC9B,IAAI,OAAO,EAAE,KAAK,UAAU,EAAE,CAAC;YAC7B,OAAO;gBACL,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CACb,EAAyD,CAAC,KAAK,CAAC;aACpE,CAAC;QACJ,CAAC;QACD,MAAM,OAAO,GAAG,GAAG,CAAC,sBAAsB,CAAC;QAC3C,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;YAClC,MAAM,QAAQ,GACZ,OACD,EAAE,CAAC;YACJ,OAAO,MAAM,QAAQ,CAAC;QACxB,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { AemClientlib, BuildMode, BuildOptions } from "./types.js";
2
+ /**
3
+ * Default values applied to every clientlib when none is specified.
4
+ * Mirrors the historical `aem-clientlib-generator` `libsBaseConfig`.
5
+ */
6
+ export declare const defaults: Required<Pick<AemClientlib, "allowProxy" | "serializationFormat" | "cssProcessor" | "jsProcessor">>;
7
+ /**
8
+ * Per-mode baseline for build options. Layered under `AemConfig.build` and
9
+ * per-clientlib `AemClientlib.build`.
10
+ */
11
+ export declare const modeBaselines: Record<BuildMode, BuildOptions>;
12
+ /** Default esbuild target when no `build.target` is set anywhere. */
13
+ export declare const defaultTarget: string;
14
+ //# sourceMappingURL=defaults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../src/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAExE;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAC7B,IAAI,CACF,YAAY,EACZ,YAAY,GAAG,qBAAqB,GAAG,cAAc,GAAG,aAAa,CACtE,CAMF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,SAAS,EAAE,YAAY,CAGzD,CAAC;AAEF,qEAAqE;AACrE,eAAO,MAAM,aAAa,EAAE,MAAiB,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Default values applied to every clientlib when none is specified.
3
+ * Mirrors the historical `aem-clientlib-generator` `libsBaseConfig`.
4
+ */
5
+ export const defaults = {
6
+ allowProxy: true,
7
+ serializationFormat: "xml",
8
+ cssProcessor: ["default:none", "min:none"],
9
+ jsProcessor: ["default:none", "min:none"],
10
+ };
11
+ /**
12
+ * Per-mode baseline for build options. Layered under `AemConfig.build` and
13
+ * per-clientlib `AemClientlib.build`.
14
+ */
15
+ export const modeBaselines = {
16
+ development: { minify: false, sourcemap: "inline" },
17
+ production: { minify: { js: true, css: true }, sourcemap: false },
18
+ };
19
+ /** Default esbuild target when no `build.target` is set anywhere. */
20
+ export const defaultTarget = "es2015";
21
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.js","sourceRoot":"","sources":["../src/defaults.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAKjB;IACF,UAAU,EAAE,IAAI;IAChB,mBAAmB,EAAE,KAAK;IAC1B,YAAY,EAAE,CAAC,cAAc,EAAE,UAAU,CAAC;IAC1C,WAAW,EAAE,CAAC,cAAc,EAAE,UAAU,CAAC;CAC1C,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAoC;IAC5D,WAAW,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE;IACnD,UAAU,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;CAClE,CAAC;AAEF,qEAAqE;AACrE,MAAM,CAAC,MAAM,aAAa,GAAW,QAAQ,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { AemConfig } from "./types.js";
2
+ /**
3
+ * Identity helper for typed `aem.config.ts` files.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * import { defineAemConfig } from "@aemvite/aem-config";
8
+ *
9
+ * export default defineAemConfig({
10
+ * clientLibRoot: "../ui.apps/.../clientlibs",
11
+ * clientlibs: [
12
+ * { name: "clientlib-site", entry: "src/main.ts", categories: ["aemvite.site"] },
13
+ * ],
14
+ * });
15
+ * ```
16
+ */
17
+ export declare function defineAemConfig(config: AemConfig): AemConfig;
18
+ //# sourceMappingURL=defineAemConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineAemConfig.d.ts","sourceRoot":"","sources":["../src/defineAemConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,CAE5D"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Identity helper for typed `aem.config.ts` files.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * import { defineAemConfig } from "@aemvite/aem-config";
7
+ *
8
+ * export default defineAemConfig({
9
+ * clientLibRoot: "../ui.apps/.../clientlibs",
10
+ * clientlibs: [
11
+ * { name: "clientlib-site", entry: "src/main.ts", categories: ["aemvite.site"] },
12
+ * ],
13
+ * });
14
+ * ```
15
+ */
16
+ export function defineAemConfig(config) {
17
+ return config;
18
+ }
19
+ //# sourceMappingURL=defineAemConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineAemConfig.js","sourceRoot":"","sources":["../src/defineAemConfig.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,eAAe,CAAC,MAAiB;IAC/C,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,9 @@
1
+ export { defineAemConfig } from "./defineAemConfig.js";
2
+ export { loadAemConfig } from "./loadAemConfig.js";
3
+ export { mergeDefaults } from "./mergeDefaults.js";
4
+ export { buildClientlibs } from "./buildClientlibs.js";
5
+ export { resolveClientlibEmitter, type ClientlibEmitter, type ClientlibEmitterInput, } from "./clientlibEmitter.js";
6
+ export { defaults, defaultTarget, modeBaselines } from "./defaults.js";
7
+ export { resolveBuildOptions } from "./resolveBuildOptions.js";
8
+ export type { AemClientlib, AemConfig, BuildClientlibsOptions, BuildMode, BuildOptions, ProcessorList, ResolvedAemClientlib, ResolvedAemConfig, ResolvedBuildOptions, } from "./types.js";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EACL,uBAAuB,EACvB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,GAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,YAAY,EACV,YAAY,EACZ,SAAS,EACT,sBAAsB,EACtB,SAAS,EACT,YAAY,EACZ,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ export { defineAemConfig } from "./defineAemConfig.js";
2
+ export { loadAemConfig } from "./loadAemConfig.js";
3
+ export { mergeDefaults } from "./mergeDefaults.js";
4
+ export { buildClientlibs } from "./buildClientlibs.js";
5
+ export { resolveClientlibEmitter, } from "./clientlibEmitter.js";
6
+ export { defaults, defaultTarget, modeBaselines } from "./defaults.js";
7
+ export { resolveBuildOptions } from "./resolveBuildOptions.js";
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EACL,uBAAuB,GAGxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { ResolvedAemConfig } from "./types.js";
2
+ /**
3
+ * Load an `aem.config.ts` (or `.js`/`.mjs`) file from disk and merge defaults.
4
+ *
5
+ * `.ts` files are transpiled via Vite's bundled esbuild
6
+ * (`loadConfigFromFile`) — no extra runtime loader (no jiti) is needed.
7
+ * `.js`/`.mjs` files are imported directly to keep the no-dep path fast.
8
+ */
9
+ export declare function loadAemConfig(configPath: string): Promise<ResolvedAemConfig>;
10
+ //# sourceMappingURL=loadAemConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadAemConfig.d.ts","sourceRoot":"","sources":["../src/loadAemConfig.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAa,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/D;;;;;;GAMG;AACH,wBAAsB,aAAa,CACjC,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,iBAAiB,CAAC,CAU5B"}
@@ -0,0 +1,49 @@
1
+ import path from "node:path";
2
+ import { pathToFileURL } from "node:url";
3
+ import { mergeDefaults } from "./mergeDefaults.js";
4
+ /**
5
+ * Load an `aem.config.ts` (or `.js`/`.mjs`) file from disk and merge defaults.
6
+ *
7
+ * `.ts` files are transpiled via Vite's bundled esbuild
8
+ * (`loadConfigFromFile`) — no extra runtime loader (no jiti) is needed.
9
+ * `.js`/`.mjs` files are imported directly to keep the no-dep path fast.
10
+ */
11
+ export async function loadAemConfig(configPath) {
12
+ const absolute = path.resolve(configPath);
13
+ const ext = path.extname(absolute).toLowerCase();
14
+ const raw = ext === ".ts" || ext === ".mts" || ext === ".cts"
15
+ ? await loadViaVite(absolute)
16
+ : await loadViaImport(absolute);
17
+ return mergeDefaults(raw);
18
+ }
19
+ async function loadViaVite(absolute) {
20
+ // Import Vite lazily so consumers that pre-resolve their config (or stub
21
+ // this loader in tests) don't pay the cost of loading Vite up front.
22
+ const { loadConfigFromFile } = await import("vite");
23
+ const result = await loadConfigFromFile({ command: "build", mode: "production" }, absolute);
24
+ if (!result) {
25
+ throw new Error(`Failed to load AEM config at ${absolute}`);
26
+ }
27
+ return unwrapDefault(result.config);
28
+ }
29
+ async function loadViaImport(absolute) {
30
+ const mod = (await import(pathToFileURL(absolute).href));
31
+ const value = mod.default ?? mod;
32
+ return unwrapDefault(value);
33
+ }
34
+ function unwrapDefault(value) {
35
+ const candidate = typeof value === "object" && value !== null && "default" in value
36
+ ? value.default
37
+ : value;
38
+ if (!isAemConfig(candidate)) {
39
+ throw new Error("AEM config must export an object with `clientLibRoot` and `clientlibs`");
40
+ }
41
+ return candidate;
42
+ }
43
+ function isAemConfig(value) {
44
+ return (typeof value === "object" &&
45
+ value !== null &&
46
+ typeof value.clientLibRoot === "string" &&
47
+ Array.isArray(value.clientlibs));
48
+ }
49
+ //# sourceMappingURL=loadAemConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadAemConfig.js","sourceRoot":"","sources":["../src/loadAemConfig.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,UAAkB;IAElB,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC1C,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC;IAEjD,MAAM,GAAG,GACP,GAAG,KAAK,KAAK,IAAI,GAAG,KAAK,MAAM,IAAI,GAAG,KAAK,MAAM;QAC/C,CAAC,CAAC,MAAM,WAAW,CAAC,QAAQ,CAAC;QAC7B,CAAC,CAAC,MAAM,aAAa,CAAC,QAAQ,CAAC,CAAC;IAEpC,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC;AAC5B,CAAC;AAED,KAAK,UAAU,WAAW,CAAC,QA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}
@@ -0,0 +1,13 @@
1
+ import type { AemConfig, ResolvedAemConfig } from "./types.js";
2
+ /**
3
+ * Merge the package-level `defaults` followed by the user-supplied
4
+ * `config.defaults` block into every clientlib entry.
5
+ *
6
+ * Precedence (highest wins): per-clientlib values → `config.defaults` →
7
+ * built-in `defaults`.
8
+ *
9
+ * Array fields (`cssProcessor`, `jsProcessor`, `dependencies`, `embed`,
10
+ * `categories`, `resources`) are replaced wholesale rather than concatenated.
11
+ */
12
+ export declare function mergeDefaults(config: AemConfig): ResolvedAemConfig;
13
+ //# sourceMappingURL=mergeDefaults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mergeDefaults.d.ts","sourceRoot":"","sources":["../src/mergeDefaults.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,SAAS,EAET,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,GAAG,iBAAiB,CAUlE"}
@@ -0,0 +1,35 @@
1
+ import { defaults } from "./defaults.js";
2
+ /**
3
+ * Merge the package-level `defaults` followed by the user-supplied
4
+ * `config.defaults` block into every clientlib entry.
5
+ *
6
+ * Precedence (highest wins): per-clientlib values → `config.defaults` →
7
+ * built-in `defaults`.
8
+ *
9
+ * Array fields (`cssProcessor`, `jsProcessor`, `dependencies`, `embed`,
10
+ * `categories`, `resources`) are replaced wholesale rather than concatenated.
11
+ */
12
+ export function mergeDefaults(config) {
13
+ const userDefaults = config.defaults ?? {};
14
+ const clientlibs = config.clientlibs.map((clientlib) => resolveClientlib(clientlib, userDefaults));
15
+ return {
16
+ clientLibRoot: config.clientLibRoot,
17
+ clientlibs,
18
+ ...(config.build !== undefined ? { build: config.build } : {}),
19
+ };
20
+ }
21
+ function resolveClientlib(clientlib, userDefaults) {
22
+ const merged = {
23
+ ...defaults,
24
+ ...userDefaults,
25
+ ...clientlib,
26
+ };
27
+ return {
28
+ ...merged,
29
+ allowProxy: merged.allowProxy ?? defaults.allowProxy,
30
+ serializationFormat: merged.serializationFormat ?? defaults.serializationFormat,
31
+ cssProcessor: merged.cssProcessor ?? defaults.cssProcessor,
32
+ jsProcessor: merged.jsProcessor ?? defaults.jsProcessor,
33
+ };
34
+ }
35
+ //# sourceMappingURL=mergeDefaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mergeDefaults.js","sourceRoot":"","sources":["../src/mergeDefaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAQzC;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAAC,MAAiB;IAC7C,MAAM,YAAY,GAAG,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC;IAC3C,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CACrD,gBAAgB,CAAC,SAAS,EAAE,YAAY,CAAC,CAC1C,CAAC;IACF,OAAO;QACL,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,UAAU;QACV,GAAG,CAAC,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC/D,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CACvB,SAAuB,EACvB,YAAmC;IAEnC,MAAM,MAAM,GAAiB;QAC3B,GAAG,QAAQ;QACX,GAAG,YAAY;QACf,GAAG,SAAS;KACb,CAAC;IACF,OAAO;QACL,GAAG,MAAM;QACT,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,QAAQ,CAAC,UAAU;QACpD,mBAAmB,EACjB,MAAM,CAAC,mBAAmB,IAAI,QAAQ,CAAC,mBAAmB;QAC5D,YAAY,EAAE,MAAM,CAAC,YAAY,IAAI,QAAQ,CAAC,YAAY;QAC1D,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,QAAQ,CAAC,WAAW;KACxD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { BuildMode, BuildOptions, ResolvedBuildOptions } from "./types.js";
2
+ /**
3
+ * Resolve build options for a single clientlib in three layers (lowest →
4
+ * highest precedence): mode baseline → global `AemConfig.build` → per-clientlib
5
+ * `AemClientlib.build`.
6
+ *
7
+ * `minify`:
8
+ * - Boolean `true` ⇒ `{ js: true, css: true }`; `false` ⇒ both off.
9
+ * - Object form overrides per-asset; unspecified keys fall through to the next
10
+ * layer (per-clientlib `{ js: true }` keeps the lower-layer `css` value).
11
+ *
12
+ * `sourcemap` and `target` are plain overrides; the higher layer wins.
13
+ */
14
+ export declare function resolveBuildOptions(mode: BuildMode, global?: BuildOptions, perClientlib?: BuildOptions): ResolvedBuildOptions;
15
+ //# sourceMappingURL=resolveBuildOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveBuildOptions.d.ts","sourceRoot":"","sources":["../src/resolveBuildOptions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,SAAS,EACT,YAAY,EACZ,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAIpB;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,SAAS,EACf,MAAM,CAAC,EAAE,YAAY,EACrB,YAAY,CAAC,EAAE,YAAY,GAC1B,oBAAoB,CAgBtB"}
@@ -0,0 +1,41 @@
1
+ import { defaultTarget, modeBaselines } from "./defaults.js";
2
+ /**
3
+ * Resolve build options for a single clientlib in three layers (lowest →
4
+ * highest precedence): mode baseline → global `AemConfig.build` → per-clientlib
5
+ * `AemClientlib.build`.
6
+ *
7
+ * `minify`:
8
+ * - Boolean `true` ⇒ `{ js: true, css: true }`; `false` ⇒ both off.
9
+ * - Object form overrides per-asset; unspecified keys fall through to the next
10
+ * layer (per-clientlib `{ js: true }` keeps the lower-layer `css` value).
11
+ *
12
+ * `sourcemap` and `target` are plain overrides; the higher layer wins.
13
+ */
14
+ export function resolveBuildOptions(mode, global, perClientlib) {
15
+ const baseline = modeBaselines[mode];
16
+ return {
17
+ minify: {
18
+ js: pickMinify("js", perClientlib?.minify, global?.minify, baseline.minify),
19
+ css: pickMinify("css", perClientlib?.minify, global?.minify, baseline.minify),
20
+ },
21
+ sourcemap: perClientlib?.sourcemap ?? global?.sourcemap ?? baseline.sourcemap ?? false,
22
+ target: perClientlib?.target ?? global?.target ?? defaultTarget,
23
+ };
24
+ }
25
+ /**
26
+ * Walk minify layers from highest → lowest precedence and pick the first
27
+ * defined value for `key`. Boolean layers always answer; object layers only
28
+ * answer when they specify the key.
29
+ */
30
+ function pickMinify(key, ...layers) {
31
+ for (const layer of layers) {
32
+ if (layer === undefined)
33
+ continue;
34
+ if (typeof layer === "boolean")
35
+ return layer;
36
+ if (layer[key] !== undefined)
37
+ return layer[key];
38
+ }
39
+ return false;
40
+ }
41
+ //# sourceMappingURL=resolveBuildOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveBuildOptions.js","sourceRoot":"","sources":["../src/resolveBuildOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAS7D;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAAe,EACf,MAAqB,EACrB,YAA2B;IAE3B,MAAM,QAAQ,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IACrC,OAAO;QACL,MAAM,EAAE;YACN,EAAE,EAAE,UAAU,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC;YAC3E,GAAG,EAAE,UAAU,CACb,KAAK,EACL,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,EACd,QAAQ,CAAC,MAAM,CAChB;SACF;QACD,SAAS,EACP,YAAY,EAAE,SAAS,IAAI,MAAM,EAAE,SAAS,IAAI,QAAQ,CAAC,SAAS,IAAI,KAAK;QAC7E,MAAM,EAAE,YAAY,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,IAAI,aAAa;KAChE,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAS,UAAU,CACjB,GAAiB,EACjB,GAAG,MAA8B;IAEjC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,KAAK,KAAK,SAAS;YAAE,SAAS;QAClC,IAAI,OAAO,KAAK,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;QAC7C,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC,GAAG,CAAE,CAAC;IACnD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,77 @@
1
+ export type ProcessorList = readonly string[];
2
+ /**
3
+ * Author-facing build options. Each field is optional and overlays on top of
4
+ * the mode baseline (development/production) and the global `AemConfig.build`.
5
+ *
6
+ * - `minify`: boolean toggles both JS and CSS; object form overrides per-asset.
7
+ * - `sourcemap`: `true`/`false`/`"inline"`/`"hidden"` (forwarded to Vite).
8
+ * - `target`: esbuild build target (e.g. `"es2015"` or `["es2015", "chrome58"]`).
9
+ */
10
+ export interface BuildOptions {
11
+ minify?: boolean | {
12
+ js?: boolean;
13
+ css?: boolean;
14
+ };
15
+ sourcemap?: boolean | "inline" | "hidden";
16
+ target?: string | string[];
17
+ }
18
+ /**
19
+ * Fully resolved build options used by `buildClientlibs` to drive each
20
+ * per-entry Vite build.
21
+ */
22
+ export interface ResolvedBuildOptions {
23
+ minify: {
24
+ js: boolean;
25
+ css: boolean;
26
+ };
27
+ sourcemap: boolean | "inline" | "hidden";
28
+ target: string | string[];
29
+ }
30
+ export interface AemClientlib {
31
+ /** Clientlib folder name (e.g. `clientlib-site`). */
32
+ name: string;
33
+ /** Path to the entry source file (relative to config dir or absolute). */
34
+ entry: string;
35
+ /** AEM categories array. */
36
+ categories: readonly string[];
37
+ /** Other clientlib categories this depends on. */
38
+ dependencies?: readonly string[];
39
+ /** Embedded clientlib categories. */
40
+ embed?: readonly string[];
41
+ /** Resource directories to copy into the clientlib's `resources/` folder. */
42
+ resources?: readonly string[];
43
+ /** Whether the clientlib is proxyable via `/etc.clientlibs`. */
44
+ allowProxy?: boolean;
45
+ /** Serialization format of `.content.xml` (default: `"xml"`). */
46
+ serializationFormat?: "xml";
47
+ /** AEM CSS processor directives. */
48
+ cssProcessor?: ProcessorList;
49
+ /** AEM JS processor directives. */
50
+ jsProcessor?: ProcessorList;
51
+ /** Per-clientlib build overrides; layered over `AemConfig.build`. */
52
+ build?: BuildOptions;
53
+ }
54
+ export interface AemConfig {
55
+ /** Absolute or relative path where clientlib folders are written. */
56
+ clientLibRoot: string;
57
+ /** Clientlib definitions. */
58
+ clientlibs: AemClientlib[];
59
+ /** Per-clientlib defaults merged into each entry of `clientlibs`. */
60
+ defaults?: Partial<AemClientlib>;
61
+ /** Global build options applied to every clientlib (overridden per-clientlib). */
62
+ build?: BuildOptions;
63
+ }
64
+ export type ResolvedAemClientlib = AemClientlib & Required<Pick<AemClientlib, "allowProxy" | "serializationFormat" | "cssProcessor" | "jsProcessor">>;
65
+ export interface ResolvedAemConfig {
66
+ clientLibRoot: string;
67
+ clientlibs: ResolvedAemClientlib[];
68
+ /** Raw global build options (resolved per-mode at build time). */
69
+ build?: BuildOptions;
70
+ }
71
+ export type BuildMode = "development" | "production";
72
+ export interface BuildClientlibsOptions {
73
+ mode: BuildMode;
74
+ configPath: string;
75
+ outDir?: string;
76
+ }
77
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,SAAS,MAAM,EAAE,CAAC;AAE9C;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,OAAO,GAAG;QAAE,EAAE,CAAC,EAAE,OAAO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CAAC;IACjC,kFAAkF;IAClF,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB;AAED,MAAM,MAAM,oBAAoB,GAAG,YAAY,GAC7C,QAAQ,CACN,IAAI,CACF,YAAY,EACZ,YAAY,GAAG,qBAAqB,GAAG,cAAc,GAAG,aAAa,CACtE,CACF,CAAC;AAEJ,MAAM,WAAW,iBAAiB;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,oBAAoB,EAAE,CAAC;IACnC,kEAAkE;IAClE,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB;AAED,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,YAAY,CAAC;AAErD,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,SAAS,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@aemvite/aem-config",
3
+ "version": "0.1.0",
4
+ "description": "Typed config helper, loader, and Vite build orchestrator for AEM clientlib packages.",
5
+ "keywords": [
6
+ "aem",
7
+ "clientlib",
8
+ "vite",
9
+ "config",
10
+ "edge-delivery",
11
+ "aemvite",
12
+ "build",
13
+ "orchestrator"
14
+ ],
15
+ "homepage": "https://github.com/LucaNerlich/aem-vite#readme",
16
+ "bugs": {
17
+ "url": "https://github.com/LucaNerlich/aem-vite/issues"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/LucaNerlich/aem-vite.git",
22
+ "directory": "packages/aem-config"
23
+ },
24
+ "license": "MIT",
25
+ "author": "Luca Nerlich",
26
+ "type": "module",
27
+ "main": "dist/index.js",
28
+ "module": "dist/index.js",
29
+ "types": "dist/index.d.ts",
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/index.d.ts",
33
+ "import": "./dist/index.js"
34
+ }
35
+ },
36
+ "bin": {
37
+ "aem-build": "dist/cli.js"
38
+ },
39
+ "files": [
40
+ "dist",
41
+ "README.md",
42
+ "CHANGELOG.md",
43
+ "LICENSE"
44
+ ],
45
+ "engines": {
46
+ "node": "^20.19.0 || >=22.12.0"
47
+ },
48
+ "dependencies": {
49
+ "@aemvite/vite-plugin-aem-clientlib": "^0.1.0"
50
+ },
51
+ "peerDependencies": {
52
+ "vite": "^7 || ^8"
53
+ },
54
+ "devDependencies": {
55
+ "@types/node": "^22.20.0",
56
+ "typescript": "^5.9.3",
57
+ "vite": "8.1.0",
58
+ "vitest": "4.1.9"
59
+ },
60
+ "publishConfig": {
61
+ "access": "public"
62
+ },
63
+ "scripts": {
64
+ "build": "tsc -p tsconfig.json",
65
+ "test": "vitest run",
66
+ "test:watch": "vitest"
67
+ }
68
+ }