auklet 0.0.15 → 0.0.17

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 (105) hide show
  1. package/bin/entry.cjs +4 -6
  2. package/dist/build/bundleConfig.d.ts +1 -4
  3. package/dist/build/bundleConfig.js +59 -71
  4. package/dist/build/cleanOutput.d.ts +2 -8
  5. package/dist/build/cleanOutput.js +7 -7
  6. package/dist/build/moduleConfig.d.ts +1 -3
  7. package/dist/build/moduleConfig.js +21 -40
  8. package/dist/build/runTsdown.d.ts +2 -5
  9. package/dist/build/runTsdown.js +18 -23
  10. package/dist/build/tsdown/common.d.ts +17 -28
  11. package/dist/build/tsdown/common.js +22 -25
  12. package/dist/build/tsdown/context.d.ts +16 -20
  13. package/dist/build/tsdown/context.js +41 -45
  14. package/dist/build/tsdown/define.d.ts +2 -7
  15. package/dist/build/tsdown/define.js +13 -22
  16. package/dist/build/tsdown/dependencies.d.ts +4 -12
  17. package/dist/build/tsdown/dependencies.js +47 -51
  18. package/dist/build/tsdown/entries.d.ts +4 -6
  19. package/dist/build/tsdown/entries.js +39 -38
  20. package/dist/build/tsdown/parseModuleId.d.ts +4 -4
  21. package/dist/build/tsdown/parseModuleId.js +92 -77
  22. package/dist/build/tsdown/types.d.ts +24 -31
  23. package/dist/build/tsdownConfig.d.ts +2 -6
  24. package/dist/build/tsdownConfig.js +1 -4
  25. package/dist/config.d.ts +37 -37
  26. package/dist/config.js +38 -41
  27. package/dist/configLoader.d.ts +2 -7
  28. package/dist/configLoader.js +59 -64
  29. package/dist/css/config.js +8 -8
  30. package/dist/css/constants.d.ts +6 -6
  31. package/dist/css/core/resolvers/packageImports.d.ts +1 -5
  32. package/dist/css/core/resolvers/packageImports.js +35 -40
  33. package/dist/css/core/resolvers/relative.d.ts +1 -4
  34. package/dist/css/core/resolvers/relative.js +3 -2
  35. package/dist/css/core/resolvers/tsconfigPaths.d.ts +1 -5
  36. package/dist/css/core/resolvers/tsconfigPaths.js +59 -66
  37. package/dist/css/core/style/dependencies.d.ts +6 -16
  38. package/dist/css/core/style/dependencies.js +35 -38
  39. package/dist/css/core/style/entries.d.ts +35 -58
  40. package/dist/css/core/style/entries.js +20 -31
  41. package/dist/css/core/style/files.d.ts +2 -7
  42. package/dist/css/core/style/files.js +11 -11
  43. package/dist/css/core/style/specifier.d.ts +5 -8
  44. package/dist/css/core/style/specifier.js +21 -18
  45. package/dist/css/core/styleImports/collector.d.ts +17 -25
  46. package/dist/css/core/styleImports/collector.js +162 -201
  47. package/dist/css/core/styleImports/sourceReference.d.ts +8 -16
  48. package/dist/css/core/styleImports/sourceReference.js +153 -173
  49. package/dist/css/core/styleModuleEntryPlanner.d.ts +21 -24
  50. package/dist/css/core/styleModuleEntryPlanner.js +44 -61
  51. package/dist/css/core/stylePackageContext.d.ts +16 -20
  52. package/dist/css/core/stylePackageContext.js +33 -49
  53. package/dist/css/core/styleProcessor.d.ts +12 -12
  54. package/dist/css/core/styleProcessor.js +105 -104
  55. package/dist/css/core/workspaceStyleResolver.d.ts +9 -15
  56. package/dist/css/core/workspaceStyleResolver.js +62 -72
  57. package/dist/css/production/builder.d.ts +9 -16
  58. package/dist/css/production/builder.js +51 -57
  59. package/dist/css/production/format/componentWriter.d.ts +8 -8
  60. package/dist/css/production/format/componentWriter.js +45 -66
  61. package/dist/css/production/format/entryWriter.d.ts +5 -9
  62. package/dist/css/production/format/entryWriter.js +36 -49
  63. package/dist/css/production/format/externalWriter.d.ts +6 -6
  64. package/dist/css/production/format/externalWriter.js +21 -33
  65. package/dist/css/production/format/moduleWriter.d.ts +5 -5
  66. package/dist/css/production/format/moduleWriter.js +23 -26
  67. package/dist/css/production/format/shared.d.ts +8 -15
  68. package/dist/css/production/format/shared.js +5 -6
  69. package/dist/css/production/format/sourceWriter.d.ts +3 -3
  70. package/dist/css/production/format/sourceWriter.js +11 -11
  71. package/dist/css/production/format/themeWriter.d.ts +8 -14
  72. package/dist/css/production/format/themeWriter.js +56 -71
  73. package/dist/css/production/moduleOutputWriter.d.ts +18 -21
  74. package/dist/css/production/moduleOutputWriter.js +56 -65
  75. package/dist/css/production/packageEntryWriter.d.ts +12 -15
  76. package/dist/css/production/packageEntryWriter.js +42 -45
  77. package/dist/css/vite/hmr.d.ts +11 -11
  78. package/dist/css/vite/hmr.js +93 -109
  79. package/dist/css/vite/moduleGraph/devDependency.d.ts +7 -12
  80. package/dist/css/vite/moduleGraph/devDependency.js +8 -8
  81. package/dist/css/vite/moduleGraph/graph.d.ts +20 -24
  82. package/dist/css/vite/moduleGraph/graph.js +49 -64
  83. package/dist/css/vite/moduleGraph/loadResult.d.ts +3 -5
  84. package/dist/css/vite/moduleGraph/loadResult.js +7 -9
  85. package/dist/css/vite/moduleGraph/packageSource/monorepo.d.ts +7 -0
  86. package/dist/css/vite/moduleGraph/packageSource/monorepo.js +72 -0
  87. package/dist/css/vite/moduleGraph/packageSource/types.d.ts +11 -0
  88. package/dist/css/vite/moduleGraph/packageSource/types.js +0 -0
  89. package/dist/css/vite/moduleGraph/requestCache.d.ts +47 -61
  90. package/dist/css/vite/moduleGraph/requestCache.js +51 -84
  91. package/dist/css/vite/moduleGraph/styleCodeFactory.d.ts +15 -18
  92. package/dist/css/vite/moduleGraph/styleCodeFactory.js +182 -263
  93. package/dist/css/vite/moduleGraph/styleId.d.ts +3 -6
  94. package/dist/css/vite/moduleGraph/styleId.js +12 -11
  95. package/dist/css/vite/moduleGraph/types.d.ts +11 -13
  96. package/dist/css/vite/vitePlugin.d.ts +16 -20
  97. package/dist/css/vite/vitePlugin.js +111 -110
  98. package/dist/css/watch/watcher.d.ts +15 -21
  99. package/dist/css/watch/watcher.js +83 -80
  100. package/dist/index.d.ts +3 -25
  101. package/dist/index.js +2 -9
  102. package/dist/types.d.ts +59 -62
  103. package/dist/utils.d.ts +3 -7
  104. package/dist/utils.js +50 -47
  105. package/package.json +31 -32
@@ -2,16 +2,16 @@ import postcss, { type Root } from 'postcss';
2
2
  import type { ModuleStyleBuildConfig } from '#auklet/types';
3
3
  import type { WorkspaceStyleResolver } from '#auklet/css/core/workspaceStyleResolver';
4
4
  export declare class StyleProcessor {
5
- private readonly config;
6
- private readonly resolver;
7
- constructor(config: ModuleStyleBuildConfig, resolver: WorkspaceStyleResolver);
8
- createRoot(): postcss.Root;
9
- appendImportRule(root: Root, specifier: string): void;
10
- stringify(root: Root): string;
11
- appendStyleContent(target: Root, content: string, from: string): void;
12
- readStyleFile(stylePath: string, seen?: Set<string>): string;
13
- collectImportedStyleFiles(styleFiles: Array<string>): Set<string>;
14
- collectStyleImportSpecifiers(styleFiles: Array<string>): Set<string>;
15
- private parse;
16
- private parseImportSpecifier;
5
+ private readonly config;
6
+ private readonly resolver;
7
+ constructor(config: ModuleStyleBuildConfig, resolver: WorkspaceStyleResolver);
8
+ createRoot(): postcss.Root;
9
+ appendImportRule(root: Root, specifier: string): void;
10
+ stringify(root: Root): string;
11
+ appendStyleContent(target: Root, content: string, from: string): void;
12
+ readStyleFile(stylePath: string, seen?: Set<string>): string;
13
+ collectImportedStyleFiles(styleFiles: Array<string>): Set<string>;
14
+ collectStyleImportSpecifiers(styleFiles: Array<string>): Set<string>;
15
+ private parse;
16
+ private parseImportSpecifier;
17
17
  }
@@ -2,117 +2,118 @@ import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import postcss from 'postcss';
4
4
  export class StyleProcessor {
5
- config;
6
- resolver;
7
- constructor(config, resolver) {
8
- this.config = config;
9
- this.resolver = resolver;
10
- }
11
- createRoot() {
12
- return postcss.root();
13
- }
14
- appendImportRule(root, specifier) {
15
- const rule = postcss.atRule({
16
- name: 'import',
17
- params: `"${specifier}"`,
18
- });
19
- if (root.nodes?.length) rule.raws.before = '\n';
20
- root.append(rule);
21
- root.raws.semicolon = true;
22
- }
23
- stringify(root) {
24
- root.raws.semicolon = true;
25
- return `${root}\n`;
26
- }
27
- appendStyleContent(target, content, from) {
28
- const root = this.parse(content, from);
29
- if (target.nodes?.length && root.nodes?.[0]) {
30
- root.nodes[0].raws.before = '\n';
5
+ config;
6
+ resolver;
7
+ constructor(config, resolver) {
8
+ this.config = config;
9
+ this.resolver = resolver;
31
10
  }
32
- target.append(...(root.nodes ?? []));
33
- }
34
- readStyleFile(stylePath, seen = new Set()) {
35
- if (!fs.existsSync(stylePath)) {
36
- return '';
11
+ createRoot() {
12
+ return postcss.root();
37
13
  }
38
- const normalizedPath = path.resolve(stylePath);
39
- if (seen.has(normalizedPath)) return '';
40
- seen.add(normalizedPath);
41
- const css = fs.readFileSync(stylePath, 'utf8');
42
- const root = this.parse(css, stylePath);
43
- const imports = [];
44
- root.walkAtRules('import', (rule) => {
45
- const specifier = this.parseImportSpecifier(rule.params);
46
- if (specifier) imports.push({ rule, specifier });
47
- });
48
- for (const { rule, specifier } of imports) {
49
- const importedPath = this.resolver.resolveStyleDependency(
50
- specifier,
51
- path.dirname(stylePath),
52
- );
53
- if (!importedPath) continue;
54
- const content = this.readStyleFile(importedPath, seen);
55
- if (!content.trim()) {
56
- rule.remove();
57
- continue;
58
- }
59
- rule.replaceWith(...(this.parse(content, importedPath).nodes ?? []));
14
+ appendImportRule(root, specifier) {
15
+ const rule = postcss.atRule({
16
+ name: 'import',
17
+ params: `"${specifier}"`,
18
+ });
19
+ if (root.nodes?.length)
20
+ rule.raws.before = '\n';
21
+ root.append(rule);
22
+ root.raws.semicolon = true;
60
23
  }
61
- return root.toString();
62
- }
63
- collectImportedStyleFiles(styleFiles) {
64
- const imported = new Set();
65
- for (const styleFile of styleFiles) {
66
- const css = fs.readFileSync(styleFile, 'utf8');
67
- const root = this.parse(css, styleFile);
68
- root.walkAtRules('import', (rule) => {
69
- const specifier = this.parseImportSpecifier(rule.params);
70
- if (
71
- !specifier?.startsWith('.') ||
72
- !this.config.styleExtensions.includes(path.extname(specifier))
73
- ) {
74
- return;
24
+ stringify(root) {
25
+ root.raws.semicolon = true;
26
+ return `${root}\n`;
27
+ }
28
+ appendStyleContent(target, content, from) {
29
+ const root = this.parse(content, from);
30
+ if (target.nodes?.length && root.nodes?.[0]) {
31
+ root.nodes[0].raws.before = '\n';
75
32
  }
76
- imported.add(path.resolve(path.dirname(styleFile), specifier));
77
- });
33
+ target.append(...(root.nodes ?? []));
78
34
  }
79
- return imported;
80
- }
81
- collectStyleImportSpecifiers(styleFiles) {
82
- const specifiers = new Set();
83
- for (const styleFile of styleFiles) {
84
- const css = fs.readFileSync(styleFile, 'utf8');
85
- const root = this.parse(css, styleFile);
86
- root.walkAtRules('import', (rule) => {
87
- const specifier = this.parseImportSpecifier(rule.params);
88
- if (specifier) specifiers.add(specifier);
89
- });
35
+ readStyleFile(stylePath, seen = new Set()) {
36
+ if (!fs.existsSync(stylePath)) {
37
+ return '';
38
+ }
39
+ const normalizedPath = path.resolve(stylePath);
40
+ if (seen.has(normalizedPath))
41
+ return '';
42
+ seen.add(normalizedPath);
43
+ const css = fs.readFileSync(stylePath, 'utf8');
44
+ const root = this.parse(css, stylePath);
45
+ const imports = [];
46
+ root.walkAtRules('import', (rule) => {
47
+ const specifier = this.parseImportSpecifier(rule.params);
48
+ if (specifier)
49
+ imports.push({ rule, specifier });
50
+ });
51
+ for (const { rule, specifier } of imports) {
52
+ const importedPath = this.resolver.resolveStyleDependency(specifier, path.dirname(stylePath));
53
+ if (!importedPath)
54
+ continue;
55
+ const content = this.readStyleFile(importedPath, seen);
56
+ if (!content.trim()) {
57
+ rule.remove();
58
+ continue;
59
+ }
60
+ rule.replaceWith(...(this.parse(content, importedPath).nodes ?? []));
61
+ }
62
+ return root.toString();
90
63
  }
91
- return specifiers;
92
- }
93
- parse(code, from) {
94
- // Keep parsing behind one method so future style languages can transform
95
- // to CSS before PostCSS reads the final stylesheet.
96
- return postcss.parse(code, { from });
97
- }
98
- parseImportSpecifier(params) {
99
- const value = params.trim();
100
- const first = value[0];
101
- if (first === '"' || first === "'") {
102
- const end = value.indexOf(first, 1);
103
- return end > 0 ? value.slice(1, end) : null;
64
+ collectImportedStyleFiles(styleFiles) {
65
+ const imported = new Set();
66
+ for (const styleFile of styleFiles) {
67
+ const css = fs.readFileSync(styleFile, 'utf8');
68
+ const root = this.parse(css, styleFile);
69
+ root.walkAtRules('import', (rule) => {
70
+ const specifier = this.parseImportSpecifier(rule.params);
71
+ if (!specifier?.startsWith('.') ||
72
+ !this.config.styleExtensions.includes(path.extname(specifier))) {
73
+ return;
74
+ }
75
+ imported.add(path.resolve(path.dirname(styleFile), specifier));
76
+ });
77
+ }
78
+ return imported;
104
79
  }
105
- if (!value.startsWith('url(')) {
106
- return null;
80
+ collectStyleImportSpecifiers(styleFiles) {
81
+ const specifiers = new Set();
82
+ for (const styleFile of styleFiles) {
83
+ const css = fs.readFileSync(styleFile, 'utf8');
84
+ const root = this.parse(css, styleFile);
85
+ root.walkAtRules('import', (rule) => {
86
+ const specifier = this.parseImportSpecifier(rule.params);
87
+ if (specifier)
88
+ specifiers.add(specifier);
89
+ });
90
+ }
91
+ return specifiers;
107
92
  }
108
- const end = value.indexOf(')', 4);
109
- if (end < 0) return null;
110
- const url = value.slice(4, end).trim();
111
- const quote = url[0];
112
- if (quote === '"' || quote === "'") {
113
- const quoteEnd = url.indexOf(quote, 1);
114
- return quoteEnd > 0 ? url.slice(1, quoteEnd) : null;
93
+ parse(code, from) {
94
+ // Keep parsing behind one method so future style languages can transform
95
+ // to CSS before PostCSS reads the final stylesheet.
96
+ return postcss.parse(code, { from });
97
+ }
98
+ parseImportSpecifier(params) {
99
+ const value = params.trim();
100
+ const first = value[0];
101
+ if (first === '"' || first === "'") {
102
+ const end = value.indexOf(first, 1);
103
+ return end > 0 ? value.slice(1, end) : null;
104
+ }
105
+ if (!value.startsWith('url(')) {
106
+ return null;
107
+ }
108
+ const end = value.indexOf(')', 4);
109
+ if (end < 0)
110
+ return null;
111
+ const url = value.slice(4, end).trim();
112
+ const quote = url[0];
113
+ if (quote === '"' || quote === "'") {
114
+ const quoteEnd = url.indexOf(quote, 1);
115
+ return quoteEnd > 0 ? url.slice(1, quoteEnd) : null;
116
+ }
117
+ return url || null;
115
118
  }
116
- return url || null;
117
- }
118
119
  }
@@ -1,17 +1,11 @@
1
- import type {
2
- ModuleStyleBuildConfig,
3
- ResolvedModuleStyleBuildContext,
4
- } from '#auklet/types';
1
+ import type { ModuleStyleBuildConfig, ResolvedModuleStyleBuildContext } from '#auklet/types';
5
2
  export declare class WorkspaceStyleResolver {
6
- private readonly config;
7
- private readonly context;
8
- private readonly require;
9
- constructor(
10
- config: ModuleStyleBuildConfig,
11
- context: ResolvedModuleStyleBuildContext,
12
- );
13
- resolveStyleDependency(specifier: string, fromDir?: string): string;
14
- toOutputStyleSpecifier(specifier: string, outRoot: string): string;
15
- toExternalStyleSpecifier(specifier: string, outRoot: string): string;
16
- private getStylePathOutputFormat;
3
+ private readonly config;
4
+ private readonly context;
5
+ private readonly require;
6
+ constructor(config: ModuleStyleBuildConfig, context: ResolvedModuleStyleBuildContext);
7
+ resolveStyleDependency(specifier: string, fromDir?: string): string;
8
+ toOutputStyleSpecifier(specifier: string, outRoot: string): string;
9
+ toExternalStyleSpecifier(specifier: string, outRoot: string): string;
10
+ private getStylePathOutputFormat;
17
11
  }
@@ -4,81 +4,71 @@ import { NODE_MODULES_DIR, STYLE_ENTRY } from '#auklet/css/constants';
4
4
  import { POSIX_SEPARATOR } from '#auklet/utils';
5
5
  import { parsePackageStyleSpecifier } from '#auklet/css/core/style/specifier';
6
6
  export class WorkspaceStyleResolver {
7
- config;
8
- context;
9
- require;
10
- constructor(config, context) {
11
- this.config = config;
12
- this.context = context;
13
- this.require = createRequire(
14
- path.join(this.context.packageRoot, 'package.json'),
15
- );
16
- }
17
- resolveStyleDependency(specifier, fromDir = this.context.packageRoot) {
18
- if (specifier.startsWith('.')) {
19
- return path.resolve(fromDir, specifier);
7
+ config;
8
+ context;
9
+ require;
10
+ constructor(config, context) {
11
+ this.config = config;
12
+ this.context = context;
13
+ this.require = createRequire(path.join(this.context.packageRoot, 'package.json'));
20
14
  }
21
- try {
22
- return this.require.resolve(specifier, {
23
- paths: [this.context.packageRoot],
24
- });
25
- } catch {
26
- return path.resolve(
27
- this.context.packageRoot,
28
- NODE_MODULES_DIR,
29
- specifier,
30
- );
15
+ resolveStyleDependency(specifier, fromDir = this.context.packageRoot) {
16
+ if (specifier.startsWith('.')) {
17
+ return path.resolve(fromDir, specifier);
18
+ }
19
+ try {
20
+ return this.require.resolve(specifier, {
21
+ paths: [this.context.packageRoot],
22
+ });
23
+ }
24
+ catch {
25
+ return path.resolve(this.context.packageRoot, NODE_MODULES_DIR, specifier);
26
+ }
31
27
  }
32
- }
33
- toOutputStyleSpecifier(specifier, outRoot) {
34
- const parsed = parsePackageStyleSpecifier(specifier);
35
- if (!parsed) return specifier;
36
- const { packageName, stylePath } = parsed;
37
- const currentOutputFormat = path.basename(outRoot);
38
- const outputFormat = this.getStylePathOutputFormat(stylePath);
39
- if (outputFormat) {
40
- return [packageName, currentOutputFormat, outputFormat.path].join(
41
- POSIX_SEPARATOR,
42
- );
28
+ toOutputStyleSpecifier(specifier, outRoot) {
29
+ const parsed = parsePackageStyleSpecifier(specifier);
30
+ if (!parsed)
31
+ return specifier;
32
+ const { packageName, stylePath } = parsed;
33
+ const currentOutputFormat = path.basename(outRoot);
34
+ const outputFormat = this.getStylePathOutputFormat(stylePath);
35
+ if (outputFormat) {
36
+ return [packageName, currentOutputFormat, outputFormat.path].join(POSIX_SEPARATOR);
37
+ }
38
+ return specifier;
43
39
  }
44
- return specifier;
45
- }
46
- toExternalStyleSpecifier(specifier, outRoot) {
47
- const parsed = parsePackageStyleSpecifier(specifier);
48
- if (!parsed) return specifier;
49
- const { packageName, stylePath } = parsed;
50
- const currentOutputFormat = path.basename(outRoot);
51
- const outputFormat = this.getStylePathOutputFormat(stylePath);
52
- if (stylePath === STYLE_ENTRY) {
53
- return [packageName, this.config.output.externalStyleFile].join(
54
- POSIX_SEPARATOR,
55
- );
40
+ toExternalStyleSpecifier(specifier, outRoot) {
41
+ const parsed = parsePackageStyleSpecifier(specifier);
42
+ if (!parsed)
43
+ return specifier;
44
+ const { packageName, stylePath } = parsed;
45
+ const currentOutputFormat = path.basename(outRoot);
46
+ const outputFormat = this.getStylePathOutputFormat(stylePath);
47
+ if (stylePath === STYLE_ENTRY) {
48
+ return [packageName, this.config.output.externalStyleFile].join(POSIX_SEPARATOR);
49
+ }
50
+ if (outputFormat &&
51
+ outputFormat.path ===
52
+ [this.config.output.styleDir, this.config.output.indexStyleFile].join(POSIX_SEPARATOR)) {
53
+ return [
54
+ packageName,
55
+ currentOutputFormat,
56
+ this.config.output.styleDir,
57
+ this.config.output.externalStyleFile,
58
+ ].join(POSIX_SEPARATOR);
59
+ }
60
+ return specifier;
56
61
  }
57
- if (
58
- outputFormat &&
59
- outputFormat.path ===
60
- [this.config.output.styleDir, this.config.output.indexStyleFile].join(
61
- POSIX_SEPARATOR,
62
- )
63
- ) {
64
- return [
65
- packageName,
66
- currentOutputFormat,
67
- this.config.output.styleDir,
68
- this.config.output.externalStyleFile,
69
- ].join(POSIX_SEPARATOR);
62
+ getStylePathOutputFormat(stylePath) {
63
+ for (const format of this.config.output.outputFormats) {
64
+ const prefix = `${format}${POSIX_SEPARATOR}`;
65
+ if (!stylePath.startsWith(prefix))
66
+ continue;
67
+ return {
68
+ format,
69
+ path: stylePath.slice(prefix.length),
70
+ };
71
+ }
72
+ return null;
70
73
  }
71
- return specifier;
72
- }
73
- getStylePathOutputFormat(stylePath) {
74
- for (const format of this.config.output.outputFormats) {
75
- const prefix = `${format}${POSIX_SEPARATOR}`;
76
- if (!stylePath.startsWith(prefix)) continue;
77
- return {
78
- format,
79
- path: stylePath.slice(prefix.length),
80
- };
81
- }
82
- return null;
83
- }
84
74
  }
@@ -1,18 +1,11 @@
1
- import type {
2
- ModuleStyleBuildConfig,
3
- ModuleStyleBuildContext,
4
- ModuleStyleBuildOptions,
5
- } from '#auklet/types';
1
+ import type { ModuleStyleBuildConfig, ModuleStyleBuildContext, ModuleStyleBuildOptions } from '#auklet/types';
6
2
  export declare class ModuleStyleBuilder {
7
- private readonly config;
8
- private readonly context;
9
- private readonly logger?;
10
- constructor(
11
- context?: ModuleStyleBuildContext,
12
- config?: ModuleStyleBuildConfig,
13
- );
14
- build(options?: ModuleStyleBuildOptions): Promise<void>;
15
- private logOutputs;
16
- private createBuildContext;
17
- private createPackageContext;
3
+ private readonly config;
4
+ private readonly context;
5
+ private readonly logger?;
6
+ constructor(context?: ModuleStyleBuildContext, config?: ModuleStyleBuildConfig);
7
+ build(options?: ModuleStyleBuildOptions): Promise<void>;
8
+ private logOutputs;
9
+ private createBuildContext;
10
+ private createPackageContext;
18
11
  }
@@ -6,63 +6,57 @@ import { ModuleStyleOutputWriter } from '#auklet/css/production/moduleOutputWrit
6
6
  import { PackageStyleEntryWriter } from '#auklet/css/production/packageEntryWriter';
7
7
  import { toPosixPath } from '#auklet/utils';
8
8
  export class ModuleStyleBuilder {
9
- config;
10
- context;
11
- logger;
12
- constructor(context = {}, config = moduleStyleBuildConfig) {
13
- this.config = config;
14
- this.context = {
15
- packageRoot: process.cwd(),
16
- source: context.source,
17
- output: context.output,
18
- ...context,
19
- };
20
- this.logger = context.logger;
21
- }
22
- async build(options = {}) {
23
- const rawConfig = options.aukletConfig ?? this.context.aukletConfig ?? {};
24
- const normalizedConfig = normalizeAukletConfig(rawConfig);
25
- const logger = options.logger ?? this.logger;
26
- const context = this.createBuildContext(normalizedConfig);
27
- const packageContext = this.createPackageContext(context, normalizedConfig);
28
- const writerOptions = {
29
- config: this.config,
30
- context,
31
- packageContext,
32
- };
33
- const packageWriter = new PackageStyleEntryWriter(writerOptions);
34
- const packageOutput = packageWriter.write();
35
- const outputs = packageOutput ? [packageOutput] : [];
36
- logger?.log?.(`[auklet:css] build ${path.basename(context.packageRoot)}`);
37
- if (normalizedConfig.modules) {
38
- outputs.push(...new ModuleStyleOutputWriter(writerOptions).write());
9
+ config;
10
+ context;
11
+ logger;
12
+ constructor(context = {}, config = moduleStyleBuildConfig) {
13
+ this.config = config;
14
+ this.context = {
15
+ packageRoot: process.cwd(),
16
+ source: context.source,
17
+ output: context.output,
18
+ ...context,
19
+ };
20
+ this.logger = context.logger;
39
21
  }
40
- this.logOutputs(context, packageContext.styleFiles, outputs, logger);
41
- }
42
- logOutputs(context, styleFiles, outputs, logger) {
43
- logger?.log?.(
44
- `[auklet:css] ${styleFiles.length} source style file(s), ${outputs.length} output entry file(s)`,
45
- );
46
- for (const output of outputs) {
47
- logger?.log?.(
48
- `[auklet:css] + ${toPosixPath(
49
- path.relative(context.packageRoot, output),
50
- )}`,
51
- );
22
+ async build(options = {}) {
23
+ const rawConfig = options.aukletConfig ?? this.context.aukletConfig ?? {};
24
+ const normalizedConfig = normalizeAukletConfig(rawConfig);
25
+ const logger = options.logger ?? this.logger;
26
+ const context = this.createBuildContext(normalizedConfig);
27
+ const packageContext = this.createPackageContext(context, normalizedConfig);
28
+ const writerOptions = {
29
+ config: this.config,
30
+ context,
31
+ packageContext,
32
+ };
33
+ const packageWriter = new PackageStyleEntryWriter(writerOptions);
34
+ const packageOutput = packageWriter.write();
35
+ const outputs = packageOutput ? [packageOutput] : [];
36
+ logger?.log?.(`[auklet:css] build ${path.basename(context.packageRoot)}`);
37
+ if (normalizedConfig.modules) {
38
+ outputs.push(...new ModuleStyleOutputWriter(writerOptions).write());
39
+ }
40
+ this.logOutputs(context, packageContext.styleFiles, outputs, logger);
41
+ }
42
+ logOutputs(context, styleFiles, outputs, logger) {
43
+ logger?.log?.(`[auklet:css] ${styleFiles.length} source style file(s), ${outputs.length} output entry file(s)`);
44
+ for (const output of outputs) {
45
+ logger?.log?.(`[auklet:css] + ${toPosixPath(path.relative(context.packageRoot, output))}`);
46
+ }
47
+ }
48
+ createBuildContext(config) {
49
+ return {
50
+ packageRoot: this.context.packageRoot,
51
+ sourceDir: this.context.source ?? config.source,
52
+ outputDir: this.context.output ?? config.output,
53
+ };
54
+ }
55
+ createPackageContext(context, normalizedConfig) {
56
+ return new StylePackageContext({
57
+ config: this.config,
58
+ context,
59
+ normalizedConfig,
60
+ });
52
61
  }
53
- }
54
- createBuildContext(config) {
55
- return {
56
- packageRoot: this.context.packageRoot,
57
- sourceDir: this.context.source ?? config.source,
58
- outputDir: this.context.output ?? config.output,
59
- };
60
- }
61
- createPackageContext(context, normalizedConfig) {
62
- return new StylePackageContext({
63
- config: this.config,
64
- context,
65
- normalizedConfig,
66
- });
67
- }
68
62
  }
@@ -1,12 +1,12 @@
1
1
  import type { ModuleStyleEntryPlan } from '#auklet/css/core/styleModuleEntryPlanner';
2
2
  import { type FormatWriterOptions } from '#auklet/css/production/format/shared';
3
3
  export declare class ComponentStyleEntryWriter {
4
- private readonly config;
5
- private readonly sourceRoot;
6
- private readonly resolver;
7
- private readonly styleProcessor;
8
- constructor(options: FormatWriterOptions);
9
- write(outRoot: string, entries: Array<ModuleStyleEntryPlan>): string[];
10
- private getModuleStyleSpecifiers;
11
- private getOwnStyleSpecifiers;
4
+ private readonly config;
5
+ private readonly sourceRoot;
6
+ private readonly resolver;
7
+ private readonly styleProcessor;
8
+ constructor(options: FormatWriterOptions);
9
+ write(outRoot: string, entries: Array<ModuleStyleEntryPlan>): string[];
10
+ private getModuleStyleSpecifiers;
11
+ private getOwnStyleSpecifiers;
12
12
  }