auklet 0.0.3 → 0.0.4

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 (79) hide show
  1. package/README.md +81 -42
  2. package/bin/entry.cjs +33 -11
  3. package/dist/build/runTsdown.js +2 -3
  4. package/dist/build/tsdownConfig.d.ts +138 -2
  5. package/dist/build/tsdownConfig.js +108 -63
  6. package/dist/config.d.ts +38 -6
  7. package/dist/config.js +43 -7
  8. package/dist/configLoader.js +1 -2
  9. package/dist/css/config.d.ts +2 -0
  10. package/dist/css/config.js +10 -0
  11. package/dist/css/constants.d.ts +6 -0
  12. package/dist/css/constants.js +6 -0
  13. package/dist/css/core/moduleGraph.d.ts +55 -0
  14. package/dist/css/core/moduleGraph.js +362 -0
  15. package/dist/css/core/moduleGraphRequestCache.d.ts +80 -0
  16. package/dist/css/core/moduleGraphRequestCache.js +92 -0
  17. package/dist/css/core/moduleStyleImportCollector.d.ts +5 -3
  18. package/dist/css/core/moduleStyleImportCollector.js +27 -45
  19. package/dist/css/core/style/dependencies.d.ts +20 -0
  20. package/dist/css/core/style/dependencies.js +55 -0
  21. package/dist/css/core/style/files.d.ts +8 -0
  22. package/dist/css/core/style/files.js +19 -0
  23. package/dist/css/core/style/plan.d.ts +59 -0
  24. package/dist/css/core/style/plan.js +27 -0
  25. package/dist/css/core/style/specifier.d.ts +14 -0
  26. package/dist/css/core/style/specifier.js +27 -0
  27. package/dist/css/core/styleModuleEntryPlanner.d.ts +29 -0
  28. package/dist/css/core/styleModuleEntryPlanner.js +66 -0
  29. package/dist/css/core/stylePackageContext.d.ts +27 -0
  30. package/dist/css/core/stylePackageContext.js +57 -0
  31. package/dist/css/core/styleProcessor.d.ts +3 -3
  32. package/dist/css/core/styleProcessor.js +18 -35
  33. package/dist/css/core/workspaceStyleResolver.d.ts +4 -5
  34. package/dist/css/core/workspaceStyleResolver.js +12 -28
  35. package/dist/css/production/builder.d.ts +18 -0
  36. package/dist/css/production/builder.js +68 -0
  37. package/dist/css/production/format/componentWriter.d.ts +12 -0
  38. package/dist/css/production/format/componentWriter.js +67 -0
  39. package/dist/css/production/format/entryWriter.d.ts +12 -0
  40. package/dist/css/production/format/entryWriter.js +54 -0
  41. package/dist/css/production/format/externalWriter.d.ts +9 -0
  42. package/dist/css/production/format/externalWriter.js +39 -0
  43. package/dist/css/production/format/moduleWriter.d.ts +8 -0
  44. package/dist/css/production/format/moduleWriter.js +31 -0
  45. package/dist/css/production/format/shared.d.ts +20 -0
  46. package/dist/css/production/format/shared.js +8 -0
  47. package/dist/css/production/format/sourceWriter.d.ts +6 -0
  48. package/dist/css/production/format/sourceWriter.js +16 -0
  49. package/dist/css/production/format/themeWriter.d.ts +16 -0
  50. package/dist/css/production/format/themeWriter.js +80 -0
  51. package/dist/css/production/moduleOutputWriter.d.ts +26 -0
  52. package/dist/css/production/moduleOutputWriter.js +83 -0
  53. package/dist/css/production/packageEntryWriter.d.ts +20 -0
  54. package/dist/css/production/packageEntryWriter.js +55 -0
  55. package/dist/css/vite/hmr.d.ts +4 -4
  56. package/dist/css/vite/hmr.js +14 -27
  57. package/dist/css/vite/vitePlugin.d.ts +5 -5
  58. package/dist/css/vite/vitePlugin.js +21 -30
  59. package/dist/css/watch/{moduleCssWatcher.d.ts → watcher.d.ts} +7 -4
  60. package/dist/css/watch/watcher.js +82 -0
  61. package/dist/index.d.ts +15 -12
  62. package/dist/index.js +6 -5
  63. package/dist/types.d.ts +40 -20
  64. package/dist/utils.d.ts +5 -1
  65. package/dist/utils.js +37 -12
  66. package/package.json +19 -14
  67. package/dist/css/core/config.d.ts +0 -2
  68. package/dist/css/core/config.js +0 -11
  69. package/dist/css/core/constants.d.ts +0 -3
  70. package/dist/css/core/constants.js +0 -3
  71. package/dist/css/core/moduleCssGraph.d.ts +0 -51
  72. package/dist/css/core/moduleCssGraph.js +0 -416
  73. package/dist/css/core/path.d.ts +0 -4
  74. package/dist/css/core/path.js +0 -26
  75. package/dist/css/core/styleEntry.d.ts +0 -45
  76. package/dist/css/core/styleEntry.js +0 -108
  77. package/dist/css/production/moduleCssBuilder.d.ts +0 -33
  78. package/dist/css/production/moduleCssBuilder.js +0 -445
  79. package/dist/css/watch/moduleCssWatcher.js +0 -106
package/README.md CHANGED
@@ -1,4 +1,11 @@
1
- # auklet
1
+ <div align="center">
2
+ <h2>auklet</h2>
3
+
4
+ [![NPM version](https://img.shields.io/npm/v/auklet.svg?style=flat-square)](https://www.npmjs.com/package/auklet)
5
+
6
+ </div>
7
+
8
+ <h1></h1>
2
9
 
3
10
  Build utilities for TypeScript packages and module CSS output.
4
11
 
@@ -45,59 +52,91 @@ Create `auklet.config.ts` in the package root:
45
52
  import type { AukletConfig } from 'auklet';
46
53
 
47
54
  export const config: AukletConfig = {
48
- sourceDir: 'src',
49
- outputDir: 'dist',
50
- themes: {
51
- light: './src/themes/light.css',
52
- dark: './src/themes/dark.css',
53
- },
54
- cssDependencies: {
55
- '@scope/ui': {
56
- global: '/style.css',
57
- component: ['/components/**.css'],
55
+ source: 'src',
56
+ output: 'dist',
57
+ styles: {
58
+ themes: {
59
+ light: './src/themes/light.css',
60
+ dark: './src/themes/dark.css',
58
61
  },
59
- '@scope/theme': {
60
- global: '/style.css',
61
- themes: {
62
- light: '/themes/light.css',
63
- dark: '/themes/dark.css',
62
+ dependencies: {
63
+ '@scope/ui': {
64
+ entry: '/style.css',
65
+ components: ['/components/**.css'],
66
+ },
67
+ '@scope/theme': {
68
+ entry: '/style.css',
69
+ themes: {
70
+ light: '/themes/light.css',
71
+ dark: '/themes/dark.css',
72
+ },
64
73
  },
65
74
  },
66
75
  },
76
+ modules: true,
67
77
  build: {
68
78
  formats: ['esm', 'cjs'],
69
- modules: true,
79
+ target: 'es2020',
70
80
  tsconfig: 'tsconfig.json',
71
81
  },
72
82
  };
73
83
  ```
74
84
 
75
- ### CSS Options
85
+ ### Style Options
76
86
 
77
- - `sourceDir`: source directory relative to the package root. Defaults to `src`.
78
- - `outputDir`: build output directory relative to the package root. Defaults to `dist`.
79
- - `themes`: package theme style entries. Defaults to no themes.
80
- - `cssDependencies`: external package style dependencies.
87
+ - `source`: source directory relative to the package root. Defaults to `src`.
88
+ - `output`: build output directory relative to the package root. Defaults to `dist`.
89
+ - `styles.themes`: package theme style entries. Defaults to `{}`.
90
+ - `styles.dependencies`: external package style dependencies. Defaults to `{}`.
81
91
 
82
- Each `cssDependencies` entry may define:
92
+ Each `styles.dependencies` entry may define:
83
93
 
84
- - `global`: package-level style dependency.
94
+ - `entry`: package-level style dependency.
85
95
  - `themes`: theme style dependency map.
86
- - `component`: glob-like component style rules used to infer style imports from source imports.
96
+ - `components`: glob-like component style rules used to infer style imports from source imports.
97
+
98
+ Style configuration should use the grouped `styles` field.
99
+
100
+ ```ts
101
+ export const config: AukletConfig = {
102
+ styles: {
103
+ dependencies: {
104
+ '@scope/ui': {
105
+ entry: '/style.css',
106
+ components: ['/components/**.css'],
107
+ },
108
+ },
109
+ },
110
+ };
111
+ ```
87
112
 
88
113
  ### Build Options
89
114
 
90
- - `formats`: package bundle formats: `esm`, `cjs`, or `iife`.
91
- - `banner`: custom bundle banner.
92
- - `externals`: additional external packages.
93
- - `modules`: whether to generate unbundled `dist/es` and `dist/lib` output.
94
- - `tsconfig`: TypeScript config path relative to the package root.
115
+ - `modules`: whether to generate unbundled `dist/es` and `dist/lib` output. Defaults to `false`. CSS module style entries also follow this flag.
116
+ - `build.formats`: package bundle formats: `esm`, `cjs`, or `iife`. Defaults to `['cjs', 'esm', 'iife']`.
117
+ - `build.target`: JavaScript compilation target passed to tsdown. Defaults to `es2020` and is shared by bundle, global, and module output.
118
+ - `build.platform`: build target runtime platform: `neutral`, `node`, or `browser`. Defaults to `neutral`.
119
+ - `build.banner`: custom bundle banner. Defaults to a package name/version banner.
120
+ - `build.externals`: additional external packages. Defaults to `[]`.
121
+ - `build.tsconfig`: TypeScript config path relative to the package root. Defaults to the nearest `tsconfig.json` found from the package root upward.
122
+
123
+ ### Build Constants
124
+
125
+ `auk build` injects these compile-time constants into bundled output:
126
+
127
+ - `__DEV__`: `true` when `process.env.NODE_ENV !== 'production'`, otherwise `false`.
128
+ - `__TEST__`: always `false` in package builds.
129
+ - `__VERSION__`: current package version from `package.json`.
130
+
131
+ Vitest uses the same names with test-friendly values: `__DEV__` is `true`, `__TEST__` is `true`, and `__VERSION__` is `'unknown'`.
95
132
 
96
133
  ## CSS Output
97
134
 
98
- `build-css` generates package and module style entries under the output directory.
135
+ `build-css` always generates the package-level `index.css` when source styles exist.
136
+
137
+ Module style entries under `dist/es` and `dist/lib` are generated only when `modules` is `true`, matching the JavaScript module output.
99
138
 
100
- Typical output includes:
139
+ Typical module output includes:
101
140
 
102
141
  ```text
103
142
  dist/
@@ -129,13 +168,13 @@ Important entry semantics:
129
168
 
130
169
  ## Vite Plugin
131
170
 
132
- Use `aukletCssPlugin` in Vite dev mode to load virtual package CSS entries.
171
+ Use `aukletStylePlugin` in Vite dev mode to load virtual package CSS entries.
133
172
 
134
173
  ```ts
135
- import { aukletCssPlugin } from 'auklet';
174
+ import { aukletStylePlugin } from 'auklet';
136
175
 
137
176
  export default {
138
- plugins: [aukletCssPlugin()],
177
+ plugins: [aukletStylePlugin()],
139
178
  };
140
179
  ```
141
180
 
@@ -151,16 +190,16 @@ import '@scope/app/themes/light.css';
151
190
 
152
191
  ```ts
153
192
  import {
154
- ModuleCssBuilder,
155
- ModuleCssWatcher,
156
- aukletCssPlugin,
193
+ ModuleStyleBuilder,
194
+ ModuleStyleWatcher,
195
+ aukletStylePlugin,
157
196
  loadAukletConfig,
158
197
  runTsdown,
159
198
  } from 'auklet';
160
199
 
161
200
  const aukletConfig = await loadAukletConfig(process.cwd());
162
201
 
163
- await new ModuleCssBuilder({
202
+ await new ModuleStyleBuilder({
164
203
  packageRoot: process.cwd(),
165
204
  aukletConfig,
166
205
  }).build();
@@ -168,9 +207,9 @@ await new ModuleCssBuilder({
168
207
 
169
208
  Public exports include:
170
209
 
171
- - `ModuleCssBuilder`
172
- - `ModuleCssWatcher`
173
- - `aukletCssPlugin`
210
+ - `ModuleStyleBuilder`
211
+ - `ModuleStyleWatcher`
212
+ - `aukletStylePlugin`
174
213
  - `loadAukletConfig`
175
214
  - `resolveAukletConfigModule`
176
215
  - `createTsdownArgs`
package/bin/entry.cjs CHANGED
@@ -4,7 +4,19 @@ const fs = require('node:fs');
4
4
  const path = require('node:path');
5
5
  const minimist = require('minimist');
6
6
 
7
- const runBuildCss = async (args) => {
7
+ const getPackageVersion = () => {
8
+ const packageJson = JSON.parse(
9
+ fs.readFileSync(path.resolve(__dirname, '../package.json'), 'utf8'),
10
+ );
11
+ return packageJson.version;
12
+ };
13
+
14
+ const runVersion = async () => {
15
+ console.log(getPackageVersion());
16
+ return 0;
17
+ };
18
+
19
+ const runBuildStyle = async (args) => {
8
20
  const shouldWatch = args.includes('--watch') || args.includes('-w');
9
21
  const { loadAukletConfig } = await import('../dist/configLoader.js');
10
22
  const aukletConfig = await loadAukletConfig(process.cwd(), {
@@ -12,10 +24,8 @@ const runBuildCss = async (args) => {
12
24
  });
13
25
 
14
26
  if (shouldWatch) {
15
- const { ModuleCssWatcher } = await import(
16
- '../dist/css/watch/moduleCssWatcher.js'
17
- );
18
- const watcher = new ModuleCssWatcher({ aukletConfig, logger: console });
27
+ const { ModuleStyleWatcher } = await import('../dist/css/watch/watcher.js');
28
+ const watcher = new ModuleStyleWatcher({ aukletConfig, logger: console });
19
29
  await watcher.watch();
20
30
  const close = () => {
21
31
  watcher
@@ -29,10 +39,10 @@ const runBuildCss = async (args) => {
29
39
  return 0;
30
40
  }
31
41
 
32
- const { ModuleCssBuilder } = await import(
33
- '../dist/css/production/moduleCssBuilder.js'
42
+ const { ModuleStyleBuilder } = await import(
43
+ '../dist/css/production/builder.js'
34
44
  );
35
- const builder = new ModuleCssBuilder({ aukletConfig, logger: console });
45
+ const builder = new ModuleStyleBuilder({ aukletConfig, logger: console });
36
46
  await builder.build();
37
47
  return 0;
38
48
  };
@@ -51,7 +61,7 @@ const runBuild = async (args) => {
51
61
  const jsExitCode = await runBuildJs(args);
52
62
  if (jsExitCode) return jsExitCode;
53
63
 
54
- return runBuildCss([]);
64
+ return runBuildStyle([]);
55
65
  };
56
66
 
57
67
  const runDev = async () => {
@@ -90,9 +100,10 @@ const runDev = async () => {
90
100
  };
91
101
 
92
102
  const argv = minimist(process.argv.slice(2), {
93
- boolean: ['help'],
103
+ boolean: ['help', 'version'],
94
104
  alias: {
95
105
  h: 'help',
106
+ v: 'version',
96
107
  },
97
108
  });
98
109
  const [command, ...args] = argv._;
@@ -100,6 +111,11 @@ const commandIndex = process.argv.indexOf(command);
100
111
  const commandArgs =
101
112
  commandIndex >= 0 ? process.argv.slice(commandIndex + 1) : args;
102
113
 
114
+ if (argv.version) {
115
+ console.log(getPackageVersion());
116
+ process.exit(0);
117
+ }
118
+
103
119
  if (argv.help || !command) {
104
120
  console.log('Usage: auk <command>');
105
121
  console.log('');
@@ -108,14 +124,20 @@ if (argv.help || !command) {
108
124
  console.log(' build-js Build package JavaScript output with tsdown');
109
125
  console.log(' build-css Build package module CSS output, supports --watch');
110
126
  console.log(' dev Watch package JavaScript and CSS output');
127
+ console.log(' version Print auklet version');
128
+ console.log('');
129
+ console.log('Options:');
130
+ console.log(' -v, --version Print auklet version');
131
+ console.log(' -h, --help Print help');
111
132
  process.exit(argv.help ? 0 : 1);
112
133
  }
113
134
 
114
135
  const runners = {
115
136
  build: runBuild,
116
137
  'build-js': runBuildJs,
117
- 'build-css': runBuildCss,
138
+ 'build-css': runBuildStyle,
118
139
  dev: runDev,
140
+ version: runVersion,
119
141
  };
120
142
 
121
143
  const runner = runners[command];
@@ -25,12 +25,11 @@ export function createTsdownArgs(args) {
25
25
  return [tsdownRunFile, ...tsdownArgs];
26
26
  }
27
27
  export async function runTsdown(args, options = {}) {
28
- var _a, _b;
29
28
  const tsdownArgs = createTsdownArgs(args);
30
29
  const result = await execa(process.execPath, tsdownArgs, {
31
- cwd: (_a = options.cwd) !== null && _a !== void 0 ? _a : process.cwd(),
30
+ cwd: options.cwd ?? process.cwd(),
32
31
  stdio: 'inherit',
33
32
  reject: false,
34
33
  });
35
- return (_b = result.exitCode) !== null && _b !== void 0 ? _b : 0;
34
+ return result.exitCode ?? 0;
36
35
  }
@@ -4,9 +4,145 @@ export type TsdownFormat = PackageBuildFormat;
4
4
  export declare function defineKernelPackageConfigFromOptions(
5
5
  packageRoot?: string,
6
6
  config?: AukletConfig,
7
- ): Array<UserConfig>;
7
+ ): (
8
+ | {
9
+ entry: {
10
+ index: string;
11
+ };
12
+ format: PackageBuildFormat;
13
+ globalName: string;
14
+ outDir: string;
15
+ dts: boolean;
16
+ treeshake: true;
17
+ banner: string;
18
+ outExtensions: () => {
19
+ js: string;
20
+ };
21
+ outputOptions: {
22
+ entryFileNames: string;
23
+ chunkFileNames: string;
24
+ globals: {
25
+ [k: string]: string;
26
+ };
27
+ };
28
+ cwd: string;
29
+ root: string;
30
+ clean: false;
31
+ sourcemap: false;
32
+ tsconfig: string;
33
+ target: NonNullable<
34
+ import('#auklet/types').PackageBuildTarget | undefined
35
+ >;
36
+ platform: NonNullable<
37
+ import('#auklet/types').PackageBuildPlatform | undefined
38
+ >;
39
+ deps: import('node_modules/tsdown/dist/types-CQaSBA5U.mjs').L;
40
+ define: {
41
+ __TEST__: string;
42
+ __VERSION__: string;
43
+ __DEV__: string;
44
+ };
45
+ }
46
+ | {
47
+ entry: Record<string, string>;
48
+ format: 'cjs' | 'esm';
49
+ outDir: string;
50
+ dts: true;
51
+ unbundle: true;
52
+ outExtensions: () => {
53
+ js: string;
54
+ dts: string;
55
+ };
56
+ cwd: string;
57
+ root: string;
58
+ clean: false;
59
+ sourcemap: false;
60
+ tsconfig: string;
61
+ target: NonNullable<
62
+ import('#auklet/types').PackageBuildTarget | undefined
63
+ >;
64
+ platform: NonNullable<
65
+ import('#auklet/types').PackageBuildPlatform | undefined
66
+ >;
67
+ deps: import('node_modules/tsdown/dist/types-CQaSBA5U.mjs').L;
68
+ define: {
69
+ __TEST__: string;
70
+ __VERSION__: string;
71
+ __DEV__: string;
72
+ };
73
+ }
74
+ )[];
8
75
  export declare function defineKernelPackageConfigFromFile(
9
76
  packageRoot?: string,
10
- ): Promise<Array<UserConfig>>;
77
+ ): Promise<
78
+ (
79
+ | {
80
+ entry: {
81
+ index: string;
82
+ };
83
+ format: PackageBuildFormat;
84
+ globalName: string;
85
+ outDir: string;
86
+ dts: boolean;
87
+ treeshake: true;
88
+ banner: string;
89
+ outExtensions: () => {
90
+ js: string;
91
+ };
92
+ outputOptions: {
93
+ entryFileNames: string;
94
+ chunkFileNames: string;
95
+ globals: {
96
+ [k: string]: string;
97
+ };
98
+ };
99
+ cwd: string;
100
+ root: string;
101
+ clean: false;
102
+ sourcemap: false;
103
+ tsconfig: string;
104
+ target: NonNullable<
105
+ import('#auklet/types').PackageBuildTarget | undefined
106
+ >;
107
+ platform: NonNullable<
108
+ import('#auklet/types').PackageBuildPlatform | undefined
109
+ >;
110
+ deps: import('node_modules/tsdown/dist/types-CQaSBA5U.mjs').L;
111
+ define: {
112
+ __TEST__: string;
113
+ __VERSION__: string;
114
+ __DEV__: string;
115
+ };
116
+ }
117
+ | {
118
+ entry: Record<string, string>;
119
+ format: 'cjs' | 'esm';
120
+ outDir: string;
121
+ dts: true;
122
+ unbundle: true;
123
+ outExtensions: () => {
124
+ js: string;
125
+ dts: string;
126
+ };
127
+ cwd: string;
128
+ root: string;
129
+ clean: false;
130
+ sourcemap: false;
131
+ tsconfig: string;
132
+ target: NonNullable<
133
+ import('#auklet/types').PackageBuildTarget | undefined
134
+ >;
135
+ platform: NonNullable<
136
+ import('#auklet/types').PackageBuildPlatform | undefined
137
+ >;
138
+ deps: import('node_modules/tsdown/dist/types-CQaSBA5U.mjs').L;
139
+ define: {
140
+ __TEST__: string;
141
+ __VERSION__: string;
142
+ __DEV__: string;
143
+ };
144
+ }
145
+ )[]
146
+ >;
11
147
  declare const _default: Promise<UserConfig[]>;
12
148
  export default _default;