auklet 0.3.2 → 0.3.3
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/dist/build/cliOverrides.d.ts +1 -0
- package/dist/cli/help.js +4 -0
- package/dist/cli/parse/build.js +10 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.js +2 -0
- package/dist/css/inspect.d.ts +1 -0
- package/dist/css/vite/hmr.d.ts +1 -0
- package/dist/css/vite/hmr.js +24 -3
- package/dist/css/vite/moduleGraph/graph.d.ts +1 -0
- package/dist/css/vite/moduleGraph/graph.js +3 -0
- package/dist/css/vite/moduleGraph/requestCache.d.ts +2 -0
- package/dist/css/vite/moduleGraph/requestCache.js +4 -0
- package/dist/css/watch/watcher.d.ts +2 -1
- package/dist/css/watch/watcher.js +7 -0
- package/dist/types.d.ts +2 -0
- package/package.json +1 -1
|
@@ -15,6 +15,7 @@ export declare function mergeAukletConfigOverrides(config: AukletConfig, overrid
|
|
|
15
15
|
configureTsdown?: import("#auklet/types").ConfigureTsdown;
|
|
16
16
|
tsconfig?: string;
|
|
17
17
|
} | undefined;
|
|
18
|
+
debug?: boolean;
|
|
18
19
|
source?: string;
|
|
19
20
|
output?: string;
|
|
20
21
|
modules?: boolean;
|
package/dist/cli/help.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export const buildOverrideOptions = [
|
|
2
|
+
[
|
|
3
|
+
'--debug [value]',
|
|
4
|
+
'Enable debug logging for package CSS build, watch, and HMR flows',
|
|
5
|
+
],
|
|
2
6
|
['--source <dir>', 'Source directory'],
|
|
3
7
|
['--output <dir>', 'Output directory'],
|
|
4
8
|
['--modules [value]', 'Enable unbundled module output'],
|
package/dist/cli/parse/build.js
CHANGED
|
@@ -54,6 +54,16 @@ export function parseBuildOverrideArgs(args, envContext) {
|
|
|
54
54
|
index += 1;
|
|
55
55
|
continue;
|
|
56
56
|
}
|
|
57
|
+
if (name === '--debug') {
|
|
58
|
+
const value = readOptionalFlagValue(args, index, inlineValue);
|
|
59
|
+
config.debug =
|
|
60
|
+
value === undefined
|
|
61
|
+
? true
|
|
62
|
+
: resolveCliBoolean(value, { label: name, context: envContext });
|
|
63
|
+
if (inlineValue === undefined && value !== undefined)
|
|
64
|
+
index += 1;
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
57
67
|
if (name === '--output') {
|
|
58
68
|
config.output = getResolvedFlagValue(args, index, inlineValue, name, envContext);
|
|
59
69
|
if (inlineValue === undefined)
|
package/dist/config.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { AukletConfig } from '#auklet/types';
|
|
|
2
2
|
export declare const aukletConfigFiles: string[];
|
|
3
3
|
export declare function isAukletConfigFile(file: string): boolean;
|
|
4
4
|
export declare const aukletDefaultOptions: {
|
|
5
|
+
debug: false;
|
|
5
6
|
source: string;
|
|
6
7
|
output: string;
|
|
7
8
|
modules: false;
|
|
@@ -17,6 +18,7 @@ export declare const aukletDefaultOptions: {
|
|
|
17
18
|
};
|
|
18
19
|
};
|
|
19
20
|
export declare function normalizeAukletConfig(config?: AukletConfig): {
|
|
21
|
+
debug: boolean;
|
|
20
22
|
source: string;
|
|
21
23
|
output: string;
|
|
22
24
|
modules: boolean;
|
package/dist/config.js
CHANGED
|
@@ -4,6 +4,7 @@ export function isAukletConfigFile(file) {
|
|
|
4
4
|
return aukletConfigFiles.includes(file);
|
|
5
5
|
}
|
|
6
6
|
export const aukletDefaultOptions = {
|
|
7
|
+
debug: false,
|
|
7
8
|
source: 'src',
|
|
8
9
|
output: 'dist',
|
|
9
10
|
modules: false,
|
|
@@ -40,6 +41,7 @@ const normalizeStyleShared = (shared) => {
|
|
|
40
41
|
export function normalizeAukletConfig(config = {}) {
|
|
41
42
|
const dependencies = config.styles?.dependencies ?? aukletDefaultOptions.styles.dependencies;
|
|
42
43
|
return {
|
|
44
|
+
debug: config.debug ?? aukletDefaultOptions.debug,
|
|
43
45
|
source: config.source ?? aukletDefaultOptions.source,
|
|
44
46
|
output: config.output ?? aukletDefaultOptions.output,
|
|
45
47
|
modules: config.modules ?? aukletDefaultOptions.modules,
|
package/dist/css/inspect.d.ts
CHANGED
|
@@ -47,6 +47,7 @@ export declare function resolveInspectCssOptions(args: Array<string>): Promise<{
|
|
|
47
47
|
configureTsdown?: import("#auklet/types").ConfigureTsdown;
|
|
48
48
|
tsconfig?: string;
|
|
49
49
|
} | undefined;
|
|
50
|
+
debug?: boolean;
|
|
50
51
|
source?: string;
|
|
51
52
|
output?: string;
|
|
52
53
|
modules?: boolean;
|
package/dist/css/vite/hmr.d.ts
CHANGED
package/dist/css/vite/hmr.js
CHANGED
|
@@ -129,12 +129,18 @@ export class AukletStyleHmr {
|
|
|
129
129
|
if (!graph.isStyleFile(context.file)) {
|
|
130
130
|
return undefined;
|
|
131
131
|
}
|
|
132
|
+
const totalStartedAt = Date.now();
|
|
132
133
|
const isSourceGraphFile = graph.isSourceGraphFile(context.file);
|
|
133
134
|
const trackedEntries = this.getTrackedStyleFileEntries(context.file, context.server.moduleGraph);
|
|
135
|
+
const debug = trackedEntries.length
|
|
136
|
+
? await graph.isDebugEnabled(trackedEntries[0].parsed)
|
|
137
|
+
: false;
|
|
138
|
+
this.logDebug(debug, `package css hmr start ${getRelativeFile(context.file)} tracked=${trackedEntries.length}`);
|
|
134
139
|
if (!trackedEntries.length) {
|
|
135
140
|
if (isSourceGraphFile) {
|
|
136
141
|
graph.invalidateFile(context.file);
|
|
137
142
|
}
|
|
143
|
+
this.logDebug(debug, `package css hmr skip ${getRelativeFile(context.file)} total=${Date.now() - totalStartedAt}ms`);
|
|
138
144
|
return undefined;
|
|
139
145
|
}
|
|
140
146
|
const entryEntries = isSourceGraphFile
|
|
@@ -160,10 +166,11 @@ export class AukletStyleHmr {
|
|
|
160
166
|
? this.createTrackedVirtualStyleUpdates(context.server, dependencyEntries, context.timestamp)
|
|
161
167
|
: []),
|
|
162
168
|
...(entryEntries.length
|
|
163
|
-
? await this.refreshTrackedVirtualStyleUpdates(context.server, entryEntries, previousResults, context.timestamp)
|
|
169
|
+
? await this.refreshTrackedVirtualStyleUpdates(context.server, entryEntries, previousResults, context.timestamp, debug)
|
|
164
170
|
: []),
|
|
165
171
|
];
|
|
166
172
|
if (!updates.length) {
|
|
173
|
+
this.logDebug(debug, `package css hmr no-update ${getRelativeFile(context.file)} total=${Date.now() - totalStartedAt}ms`);
|
|
167
174
|
return undefined;
|
|
168
175
|
}
|
|
169
176
|
this.suppressFullReload();
|
|
@@ -172,6 +179,7 @@ export class AukletStyleHmr {
|
|
|
172
179
|
updates,
|
|
173
180
|
});
|
|
174
181
|
logger.info(`package css hmr ${getRelativeFile(context.file)} tracked=${trackedEntries.length} updates=${updates.length}`);
|
|
182
|
+
this.logDebug(debug, `package css hmr done ${getRelativeFile(context.file)} tracked=${trackedEntries.length} updates=${updates.length} total=${Date.now() - totalStartedAt}ms`);
|
|
175
183
|
return [];
|
|
176
184
|
}
|
|
177
185
|
async handleSourceModuleChange(server, file) {
|
|
@@ -179,20 +187,25 @@ export class AukletStyleHmr {
|
|
|
179
187
|
if (!graph.isSourceGraphFile(file) || !graph.isSourceModuleFile(file)) {
|
|
180
188
|
return false;
|
|
181
189
|
}
|
|
190
|
+
const totalStartedAt = Date.now();
|
|
182
191
|
const virtualIds = this.getDependencyVirtualIds(file, server.moduleGraph);
|
|
183
192
|
if (!virtualIds.length) {
|
|
184
193
|
graph.invalidateFile(file);
|
|
194
|
+
this.logDebug(false, `package css source hmr skip ${getRelativeFile(file)} reason=untracked total=${Date.now() - totalStartedAt}ms`);
|
|
185
195
|
return false;
|
|
186
196
|
}
|
|
187
197
|
const parsedVirtualIds = this.parseTrackedVirtualIds(graph, virtualIds);
|
|
188
198
|
if (!parsedVirtualIds.length) {
|
|
189
199
|
graph.invalidateFile(file);
|
|
200
|
+
this.logDebug(false, `package css source hmr skip ${getRelativeFile(file)} reason=unparsed total=${Date.now() - totalStartedAt}ms`);
|
|
190
201
|
return false;
|
|
191
202
|
}
|
|
203
|
+
const debug = await graph.isDebugEnabled(parsedVirtualIds[0].parsed);
|
|
192
204
|
const previousResults = this.createTrackedVirtualStyleResults(graph, parsedVirtualIds);
|
|
193
205
|
graph.invalidateFile(file);
|
|
194
|
-
const updates = await this.refreshTrackedVirtualStyleUpdates(server, parsedVirtualIds, previousResults, Date.now());
|
|
206
|
+
const updates = await this.refreshTrackedVirtualStyleUpdates(server, parsedVirtualIds, previousResults, Date.now(), debug);
|
|
195
207
|
if (!updates.length) {
|
|
208
|
+
this.logDebug(debug, `package css source hmr no-update ${getRelativeFile(file)} tracked=${parsedVirtualIds.length} total=${Date.now() - totalStartedAt}ms`);
|
|
196
209
|
return false;
|
|
197
210
|
}
|
|
198
211
|
this.suppressFullReload();
|
|
@@ -201,6 +214,7 @@ export class AukletStyleHmr {
|
|
|
201
214
|
updates,
|
|
202
215
|
});
|
|
203
216
|
logger.info(`package css source hmr ${getRelativeFile(file)} tracked=${parsedVirtualIds.length} updates=${updates.length}`);
|
|
217
|
+
this.logDebug(debug, `package css source hmr done ${getRelativeFile(file)} tracked=${parsedVirtualIds.length} updates=${updates.length} total=${Date.now() - totalStartedAt}ms`);
|
|
204
218
|
return true;
|
|
205
219
|
}
|
|
206
220
|
parseTrackedVirtualIds(graph, virtualIds) {
|
|
@@ -295,11 +309,13 @@ export class AukletStyleHmr {
|
|
|
295
309
|
kind,
|
|
296
310
|
};
|
|
297
311
|
}
|
|
298
|
-
async refreshTrackedVirtualStyleUpdates(server, parsedVirtualIds, previousResults, timestamp) {
|
|
312
|
+
async refreshTrackedVirtualStyleUpdates(server, parsedVirtualIds, previousResults, timestamp, debug) {
|
|
299
313
|
const graph = this.graph();
|
|
300
314
|
const changedVirtualIds = [];
|
|
301
315
|
for (const item of parsedVirtualIds) {
|
|
316
|
+
const buildStartedAt = Date.now();
|
|
302
317
|
const nextResult = await graph.createPackageStyleCode(item.parsed);
|
|
318
|
+
this.logDebug(debug, `package css hmr rebuild ${item.id} took=${Date.now() - buildStartedAt}ms`);
|
|
303
319
|
const previousResult = previousResults.get(item.id);
|
|
304
320
|
if (!previousResult ||
|
|
305
321
|
!this.sameStyleLoadResult(previousResult, nextResult)) {
|
|
@@ -323,6 +339,11 @@ export class AukletStyleHmr {
|
|
|
323
339
|
shouldSuppressFullReload() {
|
|
324
340
|
return Date.now() <= this.suppressFullReloadUntil;
|
|
325
341
|
}
|
|
342
|
+
logDebug(enabled, message) {
|
|
343
|
+
if (!enabled)
|
|
344
|
+
return;
|
|
345
|
+
logger.info(message);
|
|
346
|
+
}
|
|
326
347
|
isDuplicateUpdate(file) {
|
|
327
348
|
const now = Date.now();
|
|
328
349
|
const normalizedFile = normalizeFileKey(file);
|
|
@@ -17,6 +17,7 @@ export declare class ModuleStyleGraph {
|
|
|
17
17
|
getWatchRoots(): Promise<string[]>;
|
|
18
18
|
createPackageStyleCode(parsed: PackageStyleId): Promise<import("#auklet/css/vite/moduleGraph/types").PackageStyleLoadResult>;
|
|
19
19
|
peekPackageStyleCode(parsed: PackageStyleId): import("#auklet/css/vite/moduleGraph/types").PackageStyleLoadResult | null;
|
|
20
|
+
isDebugEnabled(parsed: PackageStyleId): Promise<boolean>;
|
|
20
21
|
invalidatePackage(packageName: string): void;
|
|
21
22
|
invalidateFile(file: string): string | null;
|
|
22
23
|
isSourceModuleFile(file: string): boolean;
|
|
@@ -63,6 +63,9 @@ export class ModuleStyleGraph {
|
|
|
63
63
|
peekPackageStyleCode(parsed) {
|
|
64
64
|
return this.requestCache.peekLoadResult(parsed);
|
|
65
65
|
}
|
|
66
|
+
isDebugEnabled(parsed) {
|
|
67
|
+
return this.requestCache.isDebugEnabled(parsed);
|
|
68
|
+
}
|
|
66
69
|
invalidatePackage(packageName) {
|
|
67
70
|
this.requestCache.invalidatePackage(packageName);
|
|
68
71
|
}
|
|
@@ -45,6 +45,7 @@ export declare class ModuleStyleGraphRequestCache {
|
|
|
45
45
|
configPaths: string[];
|
|
46
46
|
packageContext: StylePackageContext;
|
|
47
47
|
normalizedConfig: {
|
|
48
|
+
debug: boolean;
|
|
48
49
|
source: string;
|
|
49
50
|
output: string;
|
|
50
51
|
modules: boolean;
|
|
@@ -80,6 +81,7 @@ export declare class ModuleStyleGraphRequestCache {
|
|
|
80
81
|
getLoadResult(parsed: PackageStyleId, create: () => Promise<LoadResultEntry>): Promise<PackageStyleLoadResult>;
|
|
81
82
|
invalidatePackage(packageName: string): void;
|
|
82
83
|
readPersistentLoadResult(parsed: PackageStyleId, context: PackageStyleContext): PackageStyleLoadResult | null;
|
|
84
|
+
isDebugEnabled(parsed: PackageStyleId): Promise<boolean>;
|
|
83
85
|
writePersistentLoadResult(parsed: PackageStyleId, context: PackageStyleContext, result: PackageStyleLoadResult): {
|
|
84
86
|
cacheInputFiles: string[];
|
|
85
87
|
code: string;
|
|
@@ -96,6 +96,10 @@ export class ModuleStyleGraphRequestCache {
|
|
|
96
96
|
readPersistentLoadResult(parsed, context) {
|
|
97
97
|
return this.persistentCache.read(this.createPersistentKey(parsed, context));
|
|
98
98
|
}
|
|
99
|
+
async isDebugEnabled(parsed) {
|
|
100
|
+
const context = await this.getContext(parsed);
|
|
101
|
+
return context?.normalizedConfig.debug ?? false;
|
|
102
|
+
}
|
|
99
103
|
writePersistentLoadResult(parsed, context, result) {
|
|
100
104
|
const cacheInputFiles = this.getPersistentInputFiles(context, result);
|
|
101
105
|
const cacheResult = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type AukletLogger } from '#auklet/logger';
|
|
2
2
|
import type { ModuleStyleBuildConfig, ModuleStyleBuildContext } from '#auklet/types';
|
|
3
|
-
type ModuleStyleWatcherLogger = Pick<AukletLogger, 'error'
|
|
3
|
+
type ModuleStyleWatcherLogger = Pick<AukletLogger, 'error'> & Partial<Pick<AukletLogger, 'info'>>;
|
|
4
4
|
export declare class ModuleStyleWatcher {
|
|
5
5
|
private readonly context;
|
|
6
6
|
private readonly config;
|
|
@@ -14,6 +14,7 @@ export declare class ModuleStyleWatcher {
|
|
|
14
14
|
constructor(context?: ModuleStyleBuildContext, config?: ModuleStyleBuildConfig, logger?: ModuleStyleWatcherLogger | null);
|
|
15
15
|
watch(): Promise<void>;
|
|
16
16
|
private rebuild;
|
|
17
|
+
private logDebug;
|
|
17
18
|
private refreshWatcher;
|
|
18
19
|
private logError;
|
|
19
20
|
private scheduleBuild;
|
|
@@ -39,10 +39,12 @@ export class ModuleStyleWatcher {
|
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
41
|
this.isBuilding = true;
|
|
42
|
+
const startedAt = Date.now();
|
|
42
43
|
try {
|
|
43
44
|
try {
|
|
44
45
|
const builder = new ModuleStyleBuilder(this.context, this.config);
|
|
45
46
|
await builder.build();
|
|
47
|
+
this.logDebug(`CSS build finished in ${Date.now() - startedAt}ms`);
|
|
46
48
|
}
|
|
47
49
|
catch (error) {
|
|
48
50
|
this.logError('build', 'CSS build failed; waiting for changes.', error);
|
|
@@ -64,6 +66,11 @@ export class ModuleStyleWatcher {
|
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
68
|
}
|
|
69
|
+
logDebug(message) {
|
|
70
|
+
if (this.context.aukletConfig?.debug !== true)
|
|
71
|
+
return;
|
|
72
|
+
this.logger.info?.(message);
|
|
73
|
+
}
|
|
67
74
|
async refreshWatcher() {
|
|
68
75
|
if (this.closed)
|
|
69
76
|
return;
|
package/dist/types.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export type NormalizedStyleDependencyGroup = {
|
|
|
15
15
|
components?: string | Array<string>;
|
|
16
16
|
};
|
|
17
17
|
export interface NormalizedAukletConfig {
|
|
18
|
+
debug: boolean;
|
|
18
19
|
source: string;
|
|
19
20
|
output: string;
|
|
20
21
|
modules: boolean;
|
|
@@ -49,6 +50,7 @@ export type PackageBuildOptions = {
|
|
|
49
50
|
tsconfig?: string;
|
|
50
51
|
};
|
|
51
52
|
export interface AukletConfig {
|
|
53
|
+
debug?: boolean;
|
|
52
54
|
source?: string;
|
|
53
55
|
output?: string;
|
|
54
56
|
modules?: boolean;
|