auklet 0.0.3 → 0.0.5

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 (81) hide show
  1. package/README.md +99 -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 +7 -0
  12. package/dist/css/constants.js +7 -0
  13. package/dist/css/core/moduleGraph.d.ts +55 -0
  14. package/dist/css/core/moduleGraph.js +363 -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/style/dependencies.d.ts +20 -0
  18. package/dist/css/core/style/dependencies.js +55 -0
  19. package/dist/css/core/style/files.d.ts +8 -0
  20. package/dist/css/core/style/files.js +19 -0
  21. package/dist/css/core/style/plan.d.ts +59 -0
  22. package/dist/css/core/style/plan.js +27 -0
  23. package/dist/css/core/style/specifier.d.ts +14 -0
  24. package/dist/css/core/style/specifier.js +27 -0
  25. package/dist/css/core/{moduleStyleImportCollector.d.ts → styleImports/collector.d.ts} +5 -5
  26. package/dist/css/core/{moduleStyleImportCollector.js → styleImports/collector.js} +36 -99
  27. package/dist/css/core/styleImports/sourceReference.d.ts +19 -0
  28. package/dist/css/core/styleImports/sourceReference.js +193 -0
  29. package/dist/css/core/styleModuleEntryPlanner.d.ts +29 -0
  30. package/dist/css/core/styleModuleEntryPlanner.js +67 -0
  31. package/dist/css/core/stylePackageContext.d.ts +27 -0
  32. package/dist/css/core/stylePackageContext.js +57 -0
  33. package/dist/css/core/styleProcessor.d.ts +3 -3
  34. package/dist/css/core/styleProcessor.js +18 -35
  35. package/dist/css/core/workspaceStyleResolver.d.ts +4 -5
  36. package/dist/css/core/workspaceStyleResolver.js +12 -28
  37. package/dist/css/production/builder.d.ts +18 -0
  38. package/dist/css/production/builder.js +68 -0
  39. package/dist/css/production/format/componentWriter.d.ts +12 -0
  40. package/dist/css/production/format/componentWriter.js +67 -0
  41. package/dist/css/production/format/entryWriter.d.ts +12 -0
  42. package/dist/css/production/format/entryWriter.js +54 -0
  43. package/dist/css/production/format/externalWriter.d.ts +9 -0
  44. package/dist/css/production/format/externalWriter.js +39 -0
  45. package/dist/css/production/format/moduleWriter.d.ts +8 -0
  46. package/dist/css/production/format/moduleWriter.js +31 -0
  47. package/dist/css/production/format/shared.d.ts +20 -0
  48. package/dist/css/production/format/shared.js +8 -0
  49. package/dist/css/production/format/sourceWriter.d.ts +6 -0
  50. package/dist/css/production/format/sourceWriter.js +16 -0
  51. package/dist/css/production/format/themeWriter.d.ts +16 -0
  52. package/dist/css/production/format/themeWriter.js +80 -0
  53. package/dist/css/production/moduleOutputWriter.d.ts +26 -0
  54. package/dist/css/production/moduleOutputWriter.js +83 -0
  55. package/dist/css/production/packageEntryWriter.d.ts +20 -0
  56. package/dist/css/production/packageEntryWriter.js +55 -0
  57. package/dist/css/vite/hmr.d.ts +4 -4
  58. package/dist/css/vite/hmr.js +14 -27
  59. package/dist/css/vite/vitePlugin.d.ts +5 -5
  60. package/dist/css/vite/vitePlugin.js +21 -30
  61. package/dist/css/watch/{moduleCssWatcher.d.ts → watcher.d.ts} +8 -4
  62. package/dist/css/watch/watcher.js +91 -0
  63. package/dist/index.d.ts +15 -12
  64. package/dist/index.js +6 -5
  65. package/dist/types.d.ts +40 -20
  66. package/dist/utils.d.ts +5 -1
  67. package/dist/utils.js +37 -12
  68. package/package.json +19 -14
  69. package/dist/css/core/config.d.ts +0 -2
  70. package/dist/css/core/config.js +0 -11
  71. package/dist/css/core/constants.d.ts +0 -3
  72. package/dist/css/core/constants.js +0 -3
  73. package/dist/css/core/moduleCssGraph.d.ts +0 -51
  74. package/dist/css/core/moduleCssGraph.js +0 -416
  75. package/dist/css/core/path.d.ts +0 -4
  76. package/dist/css/core/path.js +0 -26
  77. package/dist/css/core/styleEntry.d.ts +0 -45
  78. package/dist/css/core/styleEntry.js +0 -108
  79. package/dist/css/production/moduleCssBuilder.d.ts +0 -33
  80. package/dist/css/production/moduleCssBuilder.js +0 -445
  81. package/dist/css/watch/moduleCssWatcher.js +0 -106
package/dist/index.d.ts CHANGED
@@ -1,26 +1,29 @@
1
1
  export type {
2
- CssOptions,
3
- CssDependencyGroup,
4
2
  AukletConfig,
5
3
  LoadAukletConfigOptions,
6
- ModuleCssBuildConfig,
7
- ModuleCssBuildContext,
8
- ModuleCssBuildOptions,
4
+ ModuleStyleBuildConfig,
5
+ ModuleStyleBuildContext,
6
+ ModuleStyleBuildOptions,
7
+ NormalizedAukletConfig,
8
+ NormalizedStyleDependencyGroup,
9
9
  PackageBuildFormat,
10
10
  PackageBuildOptions,
11
- ResolvedModuleCssBuildContext,
11
+ ResolvedModuleStyleBuildContext,
12
+ StyleDependencyGroup,
13
+ StyleOptions,
12
14
  } from '#auklet/types';
13
15
  export type { RunTsdownOptions } from '#auklet/build/runTsdown';
14
- export type { AukletCssPluginOptions } from '#auklet/css/vite/vitePlugin';
16
+ export type { AukletStylePluginOptions } from '#auklet/css/vite/vitePlugin';
15
17
  export {
16
- aukletDefaultCssDependencyConfig,
17
- aukletDefaultCssOptions,
18
+ aukletDefaultOptions,
19
+ aukletDefaultStyleDependencyConfig,
20
+ normalizeAukletConfig,
18
21
  } from '#auklet/config';
19
22
  export {
20
23
  loadAukletConfig,
21
24
  resolveAukletConfigModule,
22
25
  } from '#auklet/configLoader';
23
- export { aukletCssPlugin } from '#auklet/css/vite/vitePlugin';
26
+ export { aukletStylePlugin } from '#auklet/css/vite/vitePlugin';
24
27
  export { createTsdownArgs, runTsdown } from '#auklet/build/runTsdown';
25
- export { ModuleCssWatcher } from '#auklet/css/watch/moduleCssWatcher';
26
- export { ModuleCssBuilder } from '#auklet/css/production/moduleCssBuilder';
28
+ export { ModuleStyleWatcher } from '#auklet/css/watch/watcher';
29
+ export { ModuleStyleBuilder } from '#auklet/css/production/builder';
package/dist/index.js CHANGED
@@ -1,12 +1,13 @@
1
1
  export {
2
- aukletDefaultCssDependencyConfig,
3
- aukletDefaultCssOptions,
2
+ aukletDefaultOptions,
3
+ aukletDefaultStyleDependencyConfig,
4
+ normalizeAukletConfig,
4
5
  } from '#auklet/config';
5
6
  export {
6
7
  loadAukletConfig,
7
8
  resolveAukletConfigModule,
8
9
  } from '#auklet/configLoader';
9
- export { aukletCssPlugin } from '#auklet/css/vite/vitePlugin';
10
+ export { aukletStylePlugin } from '#auklet/css/vite/vitePlugin';
10
11
  export { createTsdownArgs, runTsdown } from '#auklet/build/runTsdown';
11
- export { ModuleCssWatcher } from '#auklet/css/watch/moduleCssWatcher';
12
- export { ModuleCssBuilder } from '#auklet/css/production/moduleCssBuilder';
12
+ export { ModuleStyleWatcher } from '#auklet/css/watch/watcher';
13
+ export { ModuleStyleBuilder } from '#auklet/css/production/builder';
package/dist/types.d.ts CHANGED
@@ -1,23 +1,43 @@
1
- export type CssDependencyGroup = {
2
- global?: string | Array<string>;
1
+ export type StyleDependencyGroup = {
2
+ entry?: string | Array<string>;
3
3
  themes?: Record<string, string>;
4
- component?: string | Array<string>;
4
+ components?: string | Array<string>;
5
5
  };
6
- export interface CssOptions {
7
- cssDependencies?: Record<string, CssDependencyGroup>;
6
+ export type StyleOptions = {
8
7
  themes?: Record<string, string>;
9
- sourceDir?: string;
10
- outputDir?: string;
8
+ dependencies?: Record<string, StyleDependencyGroup>;
9
+ };
10
+ export type NormalizedStyleDependencyGroup = {
11
+ entry?: string | Array<string>;
12
+ themes?: Record<string, string>;
13
+ components?: string | Array<string>;
14
+ };
15
+ export interface NormalizedAukletConfig {
16
+ source: string;
17
+ output: string;
18
+ modules: boolean;
19
+ styles: {
20
+ themes: Record<string, string>;
21
+ dependencies: Record<string, NormalizedStyleDependencyGroup>;
22
+ };
23
+ build: Required<Pick<PackageBuildOptions, 'formats' | 'target' | 'platform'>>;
11
24
  }
12
25
  export type PackageBuildFormat = 'cjs' | 'esm' | 'iife';
26
+ export type PackageBuildPlatform = 'node' | 'neutral' | 'browser';
27
+ export type PackageBuildTarget = string | Array<string> | false;
13
28
  export type PackageBuildOptions = {
14
29
  formats?: Array<PackageBuildFormat>;
30
+ target?: PackageBuildTarget;
31
+ platform?: PackageBuildPlatform;
15
32
  banner?: string;
16
33
  externals?: Array<string>;
17
- modules?: boolean;
18
34
  tsconfig?: string;
19
35
  };
20
- export interface AukletConfig extends CssOptions {
36
+ export interface AukletConfig {
37
+ source?: string;
38
+ output?: string;
39
+ modules?: boolean;
40
+ styles?: StyleOptions;
21
41
  build?: PackageBuildOptions;
22
42
  }
23
43
  export type AukletLogger = {
@@ -29,30 +49,30 @@ export type LoadAukletConfigOptions = {
29
49
  configFile?: string;
30
50
  cacheBust?: boolean;
31
51
  };
32
- export interface ModuleCssBuildContext {
52
+ export interface ModuleStyleBuildContext {
33
53
  packageRoot?: string;
34
54
  aukletConfig?: AukletConfig;
35
55
  logger?: AukletLogger;
36
- sourceDir?: string;
37
- outputDir?: string;
56
+ source?: string;
57
+ output?: string;
38
58
  }
39
- export interface ResolvedModuleCssBuildContext {
59
+ export interface ResolvedModuleStyleBuildContext {
40
60
  packageRoot: string;
41
61
  sourceDir: string;
42
62
  outputDir: string;
43
63
  }
44
- export type ModuleCssBuildOptions = {
64
+ export type ModuleStyleBuildOptions = {
45
65
  aukletConfig?: AukletConfig;
46
66
  logger?: AukletLogger;
47
67
  };
48
- export interface ModuleCssBuildOutputConfig {
68
+ export interface ModuleStyleBuildOutputConfig {
49
69
  outputFormats: Array<string>;
50
70
  styleDir: string;
51
- indexCssFile: string;
52
- externalCssFile: string;
53
- moduleCssFile: string;
71
+ indexStyleFile: string;
72
+ externalStyleFile: string;
73
+ moduleStyleFile: string;
54
74
  }
55
- export interface ModuleCssBuildConfig {
56
- output: ModuleCssBuildOutputConfig;
75
+ export interface ModuleStyleBuildConfig {
76
+ output: ModuleStyleBuildOutputConfig;
57
77
  styleExtensions: Array<string>;
58
78
  }
package/dist/utils.d.ts CHANGED
@@ -8,8 +8,12 @@ export declare const TYPE_IMPORT_PREFIX: RegExp;
8
8
  export declare const IMPORT_ALIAS_SEPARATOR: RegExp;
9
9
  export declare function isTestDir(name: string): boolean;
10
10
  export declare function isTestFile(name: string): boolean;
11
- export declare function fileWalker(dir: string): Array<string>;
11
+ export declare function fileWalker(dir: string): string[];
12
12
  export declare function toPosixPath(value: string): string;
13
+ export declare function isWindowsAbsolutePath(file: string): boolean;
14
+ export declare function normalizeFileKey(file: string): string;
15
+ export declare function toFsSpecifier(file: string): string;
16
+ export declare function toWatchPath(...parts: Array<string>): string;
13
17
  export declare function removeExtension(file: string): string;
14
18
  export declare function getSourceModuleDir(file: string): string;
15
19
  export declare function escapeRegExp(value: string): string;
package/dist/utils.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { slash } from 'aidly';
4
+ const WINDOWS_ABSOLUTE_PATH_RE = /^[a-zA-Z]:[\\/]/;
4
5
  export const POSIX_SEPARATOR = '/';
5
6
  export const IMPORT_LIST_SEPARATOR = ',';
6
7
  export const TEST_DIR_NAMES = new Set([
@@ -22,22 +23,47 @@ export function isTestFile(name) {
22
23
  }
23
24
  export function fileWalker(dir) {
24
25
  const files = [];
25
- const entries = fs.readdirSync(dir, { withFileTypes: true });
26
- for (const entry of entries) {
27
- if (entry.isDirectory() && isTestDir(entry.name)) continue;
28
- const fullPath = path.join(dir, entry.name);
29
- if (entry.isDirectory()) {
30
- files.push(...fileWalker(fullPath));
31
- continue;
26
+ const walk = (currentDir) => {
27
+ const entries = fs.readdirSync(currentDir, { withFileTypes: true });
28
+ for (const entry of entries) {
29
+ if (entry.isDirectory() && isTestDir(entry.name)) continue;
30
+ const fullPath = path.join(currentDir, entry.name);
31
+ if (entry.isDirectory()) {
32
+ walk(fullPath);
33
+ continue;
34
+ }
35
+ if (isTestFile(entry.name)) continue;
36
+ files.push(fullPath);
32
37
  }
33
- if (isTestFile(entry.name)) continue;
34
- files.push(fullPath);
35
- }
38
+ };
39
+ walk(dir);
36
40
  return files;
37
41
  }
38
42
  export function toPosixPath(value) {
39
43
  return slash(value);
40
44
  }
45
+ export function isWindowsAbsolutePath(file) {
46
+ return WINDOWS_ABSOLUTE_PATH_RE.test(file);
47
+ }
48
+ export function normalizeFileKey(file) {
49
+ if (process.platform !== 'win32' && isWindowsAbsolutePath(file)) {
50
+ return toPosixPath(file);
51
+ }
52
+ const resolved = path.resolve(file);
53
+ const realpath = fs.existsSync(resolved)
54
+ ? fs.realpathSync.native(resolved)
55
+ : resolved;
56
+ return toPosixPath(realpath);
57
+ }
58
+ export function toFsSpecifier(file) {
59
+ return path.posix.join('/@fs', normalizeFileKey(file));
60
+ }
61
+ export function toWatchPath(...parts) {
62
+ if (parts[0] && isWindowsAbsolutePath(parts[0])) {
63
+ return toPosixPath(path.win32.join(...parts));
64
+ }
65
+ return toPosixPath(path.join(...parts));
66
+ }
41
67
  export function removeExtension(file) {
42
68
  return file.slice(0, -path.extname(file).length);
43
69
  }
@@ -52,8 +78,7 @@ export function escapeRegExp(value) {
52
78
  return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
53
79
  }
54
80
  export function appendUniqueMapValue(map, key, value) {
55
- var _a;
56
- const values = (_a = map.get(key)) !== null && _a !== void 0 ? _a : [];
81
+ const values = map.get(key) ?? [];
57
82
  if (!values.includes(value)) values.push(value);
58
83
  map.set(key, values);
59
84
  }
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "auklet",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "type": "module",
5
5
  "author": "chentao.arthur",
6
+ "packageManager": "pnpm@10.27.0",
6
7
  "description": "Build utilities for TypeScript packages and module CSS output.",
7
8
  "engines": {
8
9
  "node": ">=22",
@@ -12,6 +13,17 @@
12
13
  "auk": "./bin/entry.cjs",
13
14
  "auklet": "./bin/entry.cjs"
14
15
  },
16
+ "scripts": {
17
+ "prepare": "husky",
18
+ "build": "rimraf dist && tsc -p tsconfig.json",
19
+ "test": "vitest run src/__tests__",
20
+ "test:examples": "pnpm build:examples && vitest run examples/__tests__",
21
+ "test:coverage": "vitest run src/__tests__ --coverage",
22
+ "typecheck": "tsc --noEmit --skipLibCheck",
23
+ "build:examples": "pnpm --filter './examples/*' build",
24
+ "format:md": "prettier --write \"*.md\" \"examples/**/*.md\"",
25
+ "format": "prettier --write \"package.json\" \"pnpm-workspace.yaml\" \"(bin|src|dist|examples)/**/*.{js,mjs,cjs,ts,tsx,json,md,yaml,css}\""
26
+ },
15
27
  "exports": {
16
28
  ".": {
17
29
  "types": "./dist/index.d.ts",
@@ -42,9 +54,7 @@
42
54
  "!dist/__tests__"
43
55
  ],
44
56
  "dependencies": {
45
- "@types/node": "^22.17.0",
46
- "@types/minimist": "^1.2.5",
47
- "@vitest/coverage-v8": "^1.6.0",
57
+ "unrun": "^0.3.0",
48
58
  "execa": "^9.1.0",
49
59
  "aidly": "^1.37.0",
50
60
  "rimraf": "^6.0.1",
@@ -56,9 +66,12 @@
56
66
  "tailwindcss": "^4.2.4"
57
67
  },
58
68
  "devDependencies": {
69
+ "@types/node": "^22.17.0",
70
+ "@types/minimist": "^1.2.5",
71
+ "@vitest/coverage-v8": "^1.6.0",
59
72
  "husky": "^9.0.11",
60
- "lint-staged": "^15.2.5",
61
73
  "prettier": "^2.4.1",
74
+ "lint-staged": "^15.2.5",
62
75
  "vite": "^8.0.13",
63
76
  "vitest": "^1.6.0"
64
77
  },
@@ -72,13 +85,5 @@
72
85
  "*.{json,md}": [
73
86
  "prettier --write"
74
87
  ]
75
- },
76
- "scripts": {
77
- "build": "rimraf dist && tsc -p tsconfig.json",
78
- "test": "vitest run",
79
- "test:coverage": "vitest run --coverage",
80
- "typecheck": "tsc --noEmit --skipLibCheck",
81
- "format:md": "prettier --write --parser markdown \"TESTING.md\"",
82
- "format": "prettier --write \"(bin|src|dist)/**/*.{js,mjs,cjs,ts,tsx}\""
83
88
  }
84
- }
89
+ }
@@ -1,2 +0,0 @@
1
- import type { ModuleCssBuildConfig } from '#auklet/types';
2
- export declare const moduleCssBuildConfig: ModuleCssBuildConfig;
@@ -1,11 +0,0 @@
1
- const CSS_EXTENSION = '.css';
2
- export const moduleCssBuildConfig = {
3
- output: {
4
- styleDir: 'style',
5
- indexCssFile: 'index.css',
6
- moduleCssFile: 'module.css',
7
- externalCssFile: 'external.css',
8
- outputFormats: ['es', 'lib'],
9
- },
10
- styleExtensions: [CSS_EXTENSION],
11
- };
@@ -1,3 +0,0 @@
1
- export declare const IMPORT_AT_RULE = 'import';
2
- export declare const LINE_SEPARATOR = '\n';
3
- export declare const RELATIVE_IMPORT_PREFIX = '.';
@@ -1,3 +0,0 @@
1
- export const IMPORT_AT_RULE = 'import';
2
- export const LINE_SEPARATOR = '\n';
3
- export const RELATIVE_IMPORT_PREFIX = '.';
@@ -1,51 +0,0 @@
1
- import type { AukletConfig, ModuleCssBuildConfig } from '#auklet/types';
2
- export interface ModuleCssGraphOptions {
3
- workspaceRoot: string;
4
- packagesDir?: string;
5
- config?: ModuleCssBuildConfig;
6
- loadAukletConfig?: (
7
- packageRoot: string,
8
- options?: {
9
- cacheBust?: boolean;
10
- },
11
- ) => Promise<AukletConfig>;
12
- }
13
- export type PackageCssId = {
14
- packageName: string;
15
- cssPath: string;
16
- };
17
- export type PackageCssLoadResult = {
18
- code: string;
19
- watchFiles: Array<string>;
20
- };
21
- export declare class ModuleCssGraph {
22
- private readonly config;
23
- private readonly workspaceRoot;
24
- private readonly packagesDir;
25
- private readonly loadAukletConfig;
26
- constructor(options: ModuleCssGraphOptions);
27
- parsePackageCssId(id: string): PackageCssId | null;
28
- isWorkspaceSourceGraphFile(file: string): boolean;
29
- isCssConfigFile(file: string): boolean;
30
- isStyleFile(file: string): boolean;
31
- getWorkspacePackageNames(): string[];
32
- getWatchRoots(): string[];
33
- createPackageCssCode(parsed: PackageCssId): Promise<PackageCssLoadResult>;
34
- private createContext;
35
- private createStyleCssCode;
36
- private createStyleDependencyCssCode;
37
- private createExternalCssCode;
38
- private createThemeCssCode;
39
- private getThemeStyleFiles;
40
- private createModuleCssCode;
41
- private createSourceModuleCssCode;
42
- private getStyleFiles;
43
- private toDevModuleImportSpecifier;
44
- private toDevExternalStyleSpecifier;
45
- private isWorkspacePackageName;
46
- private getWorkspacePackages;
47
- }
48
- export declare function parsePackageCssId(
49
- id: string,
50
- packageNames: Array<string>,
51
- ): PackageCssId | null;