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.
- package/README.md +81 -42
- package/bin/entry.cjs +33 -11
- package/dist/build/runTsdown.js +2 -3
- package/dist/build/tsdownConfig.d.ts +138 -2
- package/dist/build/tsdownConfig.js +108 -63
- package/dist/config.d.ts +38 -6
- package/dist/config.js +43 -7
- package/dist/configLoader.js +1 -2
- package/dist/css/config.d.ts +2 -0
- package/dist/css/config.js +10 -0
- package/dist/css/constants.d.ts +6 -0
- package/dist/css/constants.js +6 -0
- package/dist/css/core/moduleGraph.d.ts +55 -0
- package/dist/css/core/moduleGraph.js +362 -0
- package/dist/css/core/moduleGraphRequestCache.d.ts +80 -0
- package/dist/css/core/moduleGraphRequestCache.js +92 -0
- package/dist/css/core/moduleStyleImportCollector.d.ts +5 -3
- package/dist/css/core/moduleStyleImportCollector.js +27 -45
- package/dist/css/core/style/dependencies.d.ts +20 -0
- package/dist/css/core/style/dependencies.js +55 -0
- package/dist/css/core/style/files.d.ts +8 -0
- package/dist/css/core/style/files.js +19 -0
- package/dist/css/core/style/plan.d.ts +59 -0
- package/dist/css/core/style/plan.js +27 -0
- package/dist/css/core/style/specifier.d.ts +14 -0
- package/dist/css/core/style/specifier.js +27 -0
- package/dist/css/core/styleModuleEntryPlanner.d.ts +29 -0
- package/dist/css/core/styleModuleEntryPlanner.js +66 -0
- package/dist/css/core/stylePackageContext.d.ts +27 -0
- package/dist/css/core/stylePackageContext.js +57 -0
- package/dist/css/core/styleProcessor.d.ts +3 -3
- package/dist/css/core/styleProcessor.js +18 -35
- package/dist/css/core/workspaceStyleResolver.d.ts +4 -5
- package/dist/css/core/workspaceStyleResolver.js +12 -28
- package/dist/css/production/builder.d.ts +18 -0
- package/dist/css/production/builder.js +68 -0
- package/dist/css/production/format/componentWriter.d.ts +12 -0
- package/dist/css/production/format/componentWriter.js +67 -0
- package/dist/css/production/format/entryWriter.d.ts +12 -0
- package/dist/css/production/format/entryWriter.js +54 -0
- package/dist/css/production/format/externalWriter.d.ts +9 -0
- package/dist/css/production/format/externalWriter.js +39 -0
- package/dist/css/production/format/moduleWriter.d.ts +8 -0
- package/dist/css/production/format/moduleWriter.js +31 -0
- package/dist/css/production/format/shared.d.ts +20 -0
- package/dist/css/production/format/shared.js +8 -0
- package/dist/css/production/format/sourceWriter.d.ts +6 -0
- package/dist/css/production/format/sourceWriter.js +16 -0
- package/dist/css/production/format/themeWriter.d.ts +16 -0
- package/dist/css/production/format/themeWriter.js +80 -0
- package/dist/css/production/moduleOutputWriter.d.ts +26 -0
- package/dist/css/production/moduleOutputWriter.js +83 -0
- package/dist/css/production/packageEntryWriter.d.ts +20 -0
- package/dist/css/production/packageEntryWriter.js +55 -0
- package/dist/css/vite/hmr.d.ts +4 -4
- package/dist/css/vite/hmr.js +14 -27
- package/dist/css/vite/vitePlugin.d.ts +5 -5
- package/dist/css/vite/vitePlugin.js +21 -30
- package/dist/css/watch/{moduleCssWatcher.d.ts → watcher.d.ts} +7 -4
- package/dist/css/watch/watcher.js +82 -0
- package/dist/index.d.ts +15 -12
- package/dist/index.js +6 -5
- package/dist/types.d.ts +40 -20
- package/dist/utils.d.ts +5 -1
- package/dist/utils.js +37 -12
- package/package.json +19 -14
- package/dist/css/core/config.d.ts +0 -2
- package/dist/css/core/config.js +0 -11
- package/dist/css/core/constants.d.ts +0 -3
- package/dist/css/core/constants.js +0 -3
- package/dist/css/core/moduleCssGraph.d.ts +0 -51
- package/dist/css/core/moduleCssGraph.js +0 -416
- package/dist/css/core/path.d.ts +0 -4
- package/dist/css/core/path.js +0 -26
- package/dist/css/core/styleEntry.d.ts +0 -45
- package/dist/css/core/styleEntry.js +0 -108
- package/dist/css/production/moduleCssBuilder.d.ts +0 -33
- package/dist/css/production/moduleCssBuilder.js +0 -445
- package/dist/css/watch/moduleCssWatcher.js +0 -106
package/dist/types.d.ts
CHANGED
|
@@ -1,23 +1,43 @@
|
|
|
1
|
-
export type
|
|
2
|
-
|
|
1
|
+
export type StyleDependencyGroup = {
|
|
2
|
+
entry?: string | Array<string>;
|
|
3
3
|
themes?: Record<string, string>;
|
|
4
|
-
|
|
4
|
+
components?: string | Array<string>;
|
|
5
5
|
};
|
|
6
|
-
export
|
|
7
|
-
cssDependencies?: Record<string, CssDependencyGroup>;
|
|
6
|
+
export type StyleOptions = {
|
|
8
7
|
themes?: Record<string, string>;
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
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
|
|
52
|
+
export interface ModuleStyleBuildContext {
|
|
33
53
|
packageRoot?: string;
|
|
34
54
|
aukletConfig?: AukletConfig;
|
|
35
55
|
logger?: AukletLogger;
|
|
36
|
-
|
|
37
|
-
|
|
56
|
+
source?: string;
|
|
57
|
+
output?: string;
|
|
38
58
|
}
|
|
39
|
-
export interface
|
|
59
|
+
export interface ResolvedModuleStyleBuildContext {
|
|
40
60
|
packageRoot: string;
|
|
41
61
|
sourceDir: string;
|
|
42
62
|
outputDir: string;
|
|
43
63
|
}
|
|
44
|
-
export type
|
|
64
|
+
export type ModuleStyleBuildOptions = {
|
|
45
65
|
aukletConfig?: AukletConfig;
|
|
46
66
|
logger?: AukletLogger;
|
|
47
67
|
};
|
|
48
|
-
export interface
|
|
68
|
+
export interface ModuleStyleBuildOutputConfig {
|
|
49
69
|
outputFormats: Array<string>;
|
|
50
70
|
styleDir: string;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
71
|
+
indexStyleFile: string;
|
|
72
|
+
externalStyleFile: string;
|
|
73
|
+
moduleStyleFile: string;
|
|
54
74
|
}
|
|
55
|
-
export interface
|
|
56
|
-
output:
|
|
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):
|
|
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
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
34
|
-
|
|
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
|
-
|
|
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
|
+
"version": "0.0.4",
|
|
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
|
-
"
|
|
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
|
+
}
|
package/dist/css/core/config.js
DELETED
|
@@ -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,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;
|