auklet 0.0.16 → 0.0.18

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/README.md +37 -1
  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.js +1 -4
  24. package/dist/config.d.ts +37 -37
  25. package/dist/config.js +38 -41
  26. package/dist/configLoader.d.ts +2 -7
  27. package/dist/configLoader.js +59 -64
  28. package/dist/css/config.js +8 -8
  29. package/dist/css/constants.d.ts +7 -7
  30. package/dist/css/constants.js +1 -1
  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 +22 -33
  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 +41 -8
  44. package/dist/css/core/style/specifier.js +107 -18
  45. package/dist/css/core/styleImports/autoImportRules.d.ts +13 -0
  46. package/dist/css/core/styleImports/autoImportRules.js +68 -0
  47. package/dist/css/core/styleImports/collector.d.ts +12 -25
  48. package/dist/css/core/styleImports/collector.js +101 -206
  49. package/dist/css/core/styleImports/sourceImportExportAnalyzer.d.ts +11 -0
  50. package/dist/css/core/styleImports/sourceImportExportAnalyzer.js +173 -0
  51. package/dist/css/core/styleModuleEntryPlanner.d.ts +21 -24
  52. package/dist/css/core/styleModuleEntryPlanner.js +45 -62
  53. package/dist/css/core/stylePackageContext.d.ts +16 -20
  54. package/dist/css/core/stylePackageContext.js +33 -49
  55. package/dist/css/core/styleProcessor.js +105 -104
  56. package/dist/css/core/workspaceStyleResolver.d.ts +8 -15
  57. package/dist/css/core/workspaceStyleResolver.js +34 -76
  58. package/dist/css/production/builder.d.ts +9 -16
  59. package/dist/css/production/builder.js +51 -57
  60. package/dist/css/production/format/entryWriter.js +36 -49
  61. package/dist/css/production/format/externalWriter.js +21 -33
  62. package/dist/css/production/format/{componentWriter.d.ts → moduleEntryWriter.d.ts} +1 -1
  63. package/dist/css/production/format/moduleEntryWriter.js +48 -0
  64. package/dist/css/production/format/moduleWriter.js +23 -26
  65. package/dist/css/production/format/shared.d.ts +8 -15
  66. package/dist/css/production/format/shared.js +4 -9
  67. package/dist/css/production/format/sourceWriter.js +11 -11
  68. package/dist/css/production/format/themeWriter.js +56 -71
  69. package/dist/css/production/moduleOutputWriter.d.ts +18 -21
  70. package/dist/css/production/moduleOutputWriter.js +58 -67
  71. package/dist/css/production/packageEntryWriter.d.ts +12 -15
  72. package/dist/css/production/packageEntryWriter.js +42 -45
  73. package/dist/css/vite/hmr.d.ts +11 -11
  74. package/dist/css/vite/hmr.js +93 -109
  75. package/dist/css/vite/moduleGraph/devDependency.d.ts +7 -12
  76. package/dist/css/vite/moduleGraph/devDependency.js +8 -8
  77. package/dist/css/vite/moduleGraph/graph.d.ts +20 -23
  78. package/dist/css/vite/moduleGraph/graph.js +51 -50
  79. package/dist/css/vite/moduleGraph/loadResult.d.ts +3 -5
  80. package/dist/css/vite/moduleGraph/loadResult.js +7 -9
  81. package/dist/css/vite/moduleGraph/packageSource/monorepo.d.ts +16 -7
  82. package/dist/css/vite/moduleGraph/packageSource/monorepo.js +60 -68
  83. package/dist/css/vite/moduleGraph/packageSource/singlePackage.d.ts +21 -0
  84. package/dist/css/vite/moduleGraph/packageSource/singlePackage.js +63 -0
  85. package/dist/css/vite/moduleGraph/packageSource/types.d.ts +7 -7
  86. package/dist/css/vite/moduleGraph/requestCache.d.ts +46 -57
  87. package/dist/css/vite/moduleGraph/requestCache.js +53 -51
  88. package/dist/css/vite/moduleGraph/styleCodeFactory.d.ts +15 -18
  89. package/dist/css/vite/moduleGraph/styleCodeFactory.js +173 -264
  90. package/dist/css/vite/moduleGraph/styleId.d.ts +3 -6
  91. package/dist/css/vite/moduleGraph/styleId.js +12 -11
  92. package/dist/css/vite/moduleGraph/types.d.ts +11 -14
  93. package/dist/css/vite/vitePlugin.d.ts +16 -20
  94. package/dist/css/vite/vitePlugin.js +117 -109
  95. package/dist/css/watch/watcher.d.ts +15 -21
  96. package/dist/css/watch/watcher.js +84 -81
  97. package/dist/index.d.ts +3 -25
  98. package/dist/index.js +2 -9
  99. package/dist/types.d.ts +59 -62
  100. package/dist/utils.d.ts +3 -7
  101. package/dist/utils.js +50 -47
  102. package/package.json +31 -33
  103. package/dist/css/core/styleImports/sourceReference.d.ts +0 -19
  104. package/dist/css/core/styleImports/sourceReference.js +0 -193
  105. package/dist/css/production/format/componentWriter.js +0 -71
package/dist/utils.js CHANGED
@@ -5,10 +5,10 @@ const WINDOWS_ABSOLUTE_PATH_RE = /^[a-zA-Z]:[\\/]/;
5
5
  export const POSIX_SEPARATOR = '/';
6
6
  export const IMPORT_LIST_SEPARATOR = ',';
7
7
  export const TEST_DIR_NAMES = new Set([
8
- '__test__',
9
- '__tests__',
10
- 'test',
11
- 'tests',
8
+ '__test__',
9
+ '__tests__',
10
+ 'test',
11
+ 'tests',
12
12
  ]);
13
13
  export const SOURCE_TEST_RE = /\.(spec|test)\.[cm]?(ts|tsx|js|jsx)$/;
14
14
  export const SOURCE_MODULE_RE = /\.(ts|tsx)$/;
@@ -16,69 +16,72 @@ export const SOURCE_DECLARATION_RE = /\.d\.[cm]?ts$/;
16
16
  export const TYPE_IMPORT_PREFIX = /^type\s+/;
17
17
  export const IMPORT_ALIAS_SEPARATOR = /\s+as\s+/;
18
18
  export function isTestDir(name) {
19
- return TEST_DIR_NAMES.has(name);
19
+ return TEST_DIR_NAMES.has(name);
20
20
  }
21
21
  export function isTestFile(name) {
22
- return SOURCE_TEST_RE.test(name);
22
+ return SOURCE_TEST_RE.test(name);
23
23
  }
24
24
  export function fileWalker(dir) {
25
- const files = [];
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);
37
- }
38
- };
39
- walk(dir);
40
- return files;
25
+ const files = [];
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))
30
+ continue;
31
+ const fullPath = path.join(currentDir, entry.name);
32
+ if (entry.isDirectory()) {
33
+ walk(fullPath);
34
+ continue;
35
+ }
36
+ if (isTestFile(entry.name))
37
+ continue;
38
+ files.push(fullPath);
39
+ }
40
+ };
41
+ walk(dir);
42
+ return files;
41
43
  }
42
44
  export function toPosixPath(value) {
43
- return slash(value);
45
+ return slash(value);
44
46
  }
45
47
  export function isWindowsAbsolutePath(file) {
46
- return WINDOWS_ABSOLUTE_PATH_RE.test(file);
48
+ return WINDOWS_ABSOLUTE_PATH_RE.test(file);
47
49
  }
48
50
  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);
51
+ if (process.platform !== 'win32' && isWindowsAbsolutePath(file)) {
52
+ return toPosixPath(file);
53
+ }
54
+ const resolved = path.resolve(file);
55
+ const realpath = fs.existsSync(resolved)
56
+ ? fs.realpathSync.native(resolved)
57
+ : resolved;
58
+ return toPosixPath(realpath);
57
59
  }
58
60
  export function toFsSpecifier(file) {
59
- return path.posix.join('/@fs', normalizeFileKey(file));
61
+ return path.posix.join('/@fs', normalizeFileKey(file));
60
62
  }
61
63
  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));
64
+ if (parts[0] && isWindowsAbsolutePath(parts[0])) {
65
+ return toPosixPath(path.win32.join(...parts));
66
+ }
67
+ return toPosixPath(path.join(...parts));
66
68
  }
67
69
  export function removeExtension(file) {
68
- return file.slice(0, -path.extname(file).length);
70
+ return file.slice(0, -path.extname(file).length);
69
71
  }
70
72
  export function getSourceModuleDir(file) {
71
- const filename = path.basename(file);
72
- if (filename.startsWith('index.')) {
73
- return path.dirname(file);
74
- }
75
- return removeExtension(file);
73
+ const filename = path.basename(file);
74
+ if (filename.startsWith('index.')) {
75
+ return path.dirname(file);
76
+ }
77
+ return removeExtension(file);
76
78
  }
77
79
  export function escapeRegExp(value) {
78
- return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
80
+ return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
79
81
  }
80
82
  export function appendUniqueMapValue(map, key, value) {
81
- const values = map.get(key) ?? [];
82
- if (!values.includes(value)) values.push(value);
83
- map.set(key, values);
83
+ const values = map.get(key) ?? [];
84
+ if (!values.includes(value))
85
+ values.push(value);
86
+ map.set(key, values);
84
87
  }
package/package.json CHANGED
@@ -1,9 +1,8 @@
1
1
  {
2
2
  "name": "auklet",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "type": "module",
5
5
  "author": "chentao.arthur",
6
- "packageManager": "pnpm@10.27.0",
7
6
  "description": "Build utilities for TypeScript packages and module CSS output.",
8
7
  "engines": {
9
8
  "node": ">=22",
@@ -13,18 +12,6 @@
13
12
  "auk": "./bin/entry.cjs",
14
13
  "auklet": "./bin/entry.cjs"
15
14
  },
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
- "dev:examples": "pnpm --filter './examples/*' --if-present dev",
24
- "build:examples": "pnpm --filter './examples/*' build",
25
- "format:md": "prettier --write \"*.md\" \"examples/**/*.md\"",
26
- "format": "prettier --write \"package.json\" \"pnpm-workspace.yaml\" \"(bin|src|dist|examples)/**/*.{js,mjs,cjs,ts,tsx,json,md,yaml,css}\""
27
- },
28
15
  "exports": {
29
16
  ".": {
30
17
  "types": "./dist/index.d.ts",
@@ -64,26 +51,26 @@
64
51
  "tsdown"
65
52
  ],
66
53
  "dependencies": {
67
- "unrun": "catalog:",
68
- "execa": "catalog:",
69
- "aidly": "catalog:",
70
- "rimraf": "catalog:",
71
- "tsdown": "catalog:",
72
- "postcss": "catalog:",
73
- "chokidar": "catalog:",
74
- "minimist": "catalog:",
75
- "typescript": "catalog:",
76
- "conditional-export": "catalog:"
54
+ "unrun": "0.3.0",
55
+ "execa": "9.6.1",
56
+ "aidly": "1.37.0",
57
+ "rimraf": "6.1.3",
58
+ "tsdown": "0.22.0",
59
+ "postcss": "8.5.15",
60
+ "chokidar": "5.0.0",
61
+ "minimist": "1.2.8",
62
+ "typescript": "6.0.3",
63
+ "conditional-export": "1.1.0"
77
64
  },
78
65
  "devDependencies": {
79
- "@types/node": "catalog:",
80
- "@types/minimist": "catalog:",
81
- "@vitest/coverage-v8": "catalog:",
82
- "husky": "catalog:",
83
- "prettier": "catalog:",
84
- "lint-staged": "catalog:",
85
- "vite": "catalog:",
86
- "vitest": "catalog:"
66
+ "@types/node": "22.17.0",
67
+ "@types/minimist": "1.2.5",
68
+ "@vitest/coverage-v8": "4.1.7",
69
+ "husky": "9.1.7",
70
+ "prettier": "3.8.3",
71
+ "lint-staged": "17.0.5",
72
+ "vite": "8.0.14",
73
+ "vitest": "4.1.7"
87
74
  },
88
75
  "lint-staged": {
89
76
  "*.js": [
@@ -95,5 +82,16 @@
95
82
  "*.{json,md}": [
96
83
  "prettier --write"
97
84
  ]
85
+ },
86
+ "scripts": {
87
+ "build": "rimraf dist && tsc -p tsconfig.json",
88
+ "test": "vitest run src/__tests__",
89
+ "test:examples": "pnpm build:examples && vitest run examples/__tests__",
90
+ "test:coverage": "vitest run src/__tests__ --coverage",
91
+ "typecheck": "tsc --noEmit --skipLibCheck",
92
+ "dev:examples": "pnpm --filter './examples/*' --if-present dev",
93
+ "build:examples": "pnpm --filter './examples/*' build",
94
+ "format:md": "prettier --write \"*.md\" \"examples/**/*.md\"",
95
+ "format": "prettier --write \"package.json\" \"pnpm-workspace.yaml\" \"(bin|src|dist|examples)/**/*.{js,mjs,cjs,ts,tsx,json,md,yaml,css}\""
98
96
  }
99
- }
97
+ }
@@ -1,19 +0,0 @@
1
- import ts from 'typescript';
2
- export type ModuleStyleSourceReference = {
3
- importPath: string;
4
- importClause?: ts.ImportClause;
5
- importedNames?: Array<string>;
6
- isTypeOnly?: boolean;
7
- hasNamespaceImport?: boolean;
8
- };
9
- export declare function collectModuleStyleSourceReferences(
10
- file: string,
11
- code: string,
12
- ): ModuleStyleSourceReference[];
13
- export declare function isTypeOnlySourceReference(
14
- item: ModuleStyleSourceReference,
15
- ): boolean | undefined;
16
- export declare function getSourceReferenceImportedNames(
17
- file: string,
18
- item: ModuleStyleSourceReference,
19
- ): string[];
@@ -1,193 +0,0 @@
1
- import ts from 'typescript';
2
- export function collectModuleStyleSourceReferences(file, code) {
3
- const imports = [];
4
- const importBindings = new Map();
5
- const localDeclarations = new Set();
6
- const sourceFile = ts.createSourceFile(
7
- file,
8
- code,
9
- ts.ScriptTarget.Latest,
10
- false,
11
- file.endsWith('.tsx') ? ts.ScriptKind.TSX : ts.ScriptKind.TS,
12
- );
13
- sourceFile.forEachChild((node) => {
14
- collectLocalDeclarationNames(node, localDeclarations);
15
- if (ts.isImportDeclaration(node)) {
16
- collectImportBindings(node, importBindings);
17
- }
18
- });
19
- sourceFile.forEachChild((node) => {
20
- if (ts.isImportDeclaration(node)) {
21
- if (!ts.isStringLiteral(node.moduleSpecifier)) {
22
- return;
23
- }
24
- imports.push({
25
- importPath: node.moduleSpecifier.text,
26
- importClause: node.importClause,
27
- });
28
- return;
29
- }
30
- if (ts.isExportDeclaration(node)) {
31
- collectExportDeclaration(
32
- file,
33
- node,
34
- imports,
35
- importBindings,
36
- localDeclarations,
37
- );
38
- }
39
- });
40
- return imports;
41
- }
42
- export function isTypeOnlySourceReference(item) {
43
- return isTypeOnlyImportClause(item.importClause) || item.isTypeOnly;
44
- }
45
- export function getSourceReferenceImportedNames(file, item) {
46
- if (item.importedNames) {
47
- if (item.isTypeOnly) return [];
48
- if (item.hasNamespaceImport) {
49
- throw createNamespaceImportError(file, item.importPath);
50
- }
51
- return item.importedNames;
52
- }
53
- const importClause = item.importClause;
54
- if (!importClause || isTypeOnlyImportClause(importClause)) {
55
- return [];
56
- }
57
- const names = [];
58
- if (importClause.name) {
59
- names.push(importClause.name.text);
60
- }
61
- const namedBindings = importClause.namedBindings;
62
- if (!namedBindings) {
63
- return names;
64
- }
65
- if (ts.isNamespaceImport(namedBindings)) {
66
- throw createNamespaceImportError(file, item.importPath);
67
- }
68
- for (const element of namedBindings.elements) {
69
- if (element.isTypeOnly) continue;
70
- names.push((element.propertyName ?? element.name).text);
71
- }
72
- return names;
73
- }
74
- const collectLocalDeclarationNames = (node, localDeclarations) => {
75
- if (
76
- (ts.isFunctionDeclaration(node) ||
77
- ts.isClassDeclaration(node) ||
78
- ts.isInterfaceDeclaration(node) ||
79
- ts.isTypeAliasDeclaration(node) ||
80
- ts.isEnumDeclaration(node)) &&
81
- node.name
82
- ) {
83
- localDeclarations.add(node.name.text);
84
- return;
85
- }
86
- if (!ts.isVariableStatement(node)) return;
87
- for (const declaration of node.declarationList.declarations) {
88
- if (ts.isIdentifier(declaration.name)) {
89
- localDeclarations.add(declaration.name.text);
90
- }
91
- }
92
- };
93
- const collectImportBindings = (node, importBindings) => {
94
- if (!ts.isStringLiteral(node.moduleSpecifier) || !node.importClause) {
95
- return;
96
- }
97
- const importPath = node.moduleSpecifier.text;
98
- const isTypeOnly = isTypeOnlyImportClause(node.importClause);
99
- if (node.importClause.name) {
100
- const importedName = node.importClause.name.text;
101
- importBindings.set(importedName, {
102
- importPath,
103
- importedName,
104
- isTypeOnly,
105
- hasNamespaceImport: false,
106
- });
107
- }
108
- const namedBindings = node.importClause.namedBindings;
109
- if (!namedBindings) return;
110
- if (ts.isNamespaceImport(namedBindings)) {
111
- importBindings.set(namedBindings.name.text, {
112
- importPath,
113
- importedName: namedBindings.name.text,
114
- isTypeOnly,
115
- hasNamespaceImport: true,
116
- });
117
- return;
118
- }
119
- for (const element of namedBindings.elements) {
120
- const importedName = (element.propertyName ?? element.name).text;
121
- importBindings.set(element.name.text, {
122
- importPath,
123
- importedName,
124
- isTypeOnly: isTypeOnly || element.isTypeOnly,
125
- hasNamespaceImport: false,
126
- });
127
- }
128
- };
129
- const collectExportDeclaration = (
130
- file,
131
- node,
132
- imports,
133
- importBindings,
134
- localDeclarations,
135
- ) => {
136
- if (node.moduleSpecifier) {
137
- if (!ts.isStringLiteral(node.moduleSpecifier)) return;
138
- if (!node.exportClause || !ts.isNamedExports(node.exportClause)) {
139
- throw new Error(
140
- `[auklet:css] Export-all declarations are not supported for CSS auto import: ${node.moduleSpecifier.text}\n` +
141
- `Use named exports instead, for example: export { Component } from '${node.moduleSpecifier.text}'.\n` +
142
- `File: ${file}`,
143
- );
144
- }
145
- imports.push({
146
- importPath: node.moduleSpecifier.text,
147
- importedNames: getExportedNames(node),
148
- isTypeOnly: node.isTypeOnly,
149
- });
150
- return;
151
- }
152
- if (!node.exportClause || !ts.isNamedExports(node.exportClause)) {
153
- return;
154
- }
155
- for (const element of node.exportClause.elements) {
156
- if (node.isTypeOnly || element.isTypeOnly) continue;
157
- const localName = (element.propertyName ?? element.name).text;
158
- const binding = importBindings.get(localName);
159
- if (binding) {
160
- imports.push({
161
- importPath: binding.importPath,
162
- importedNames: [binding.importedName],
163
- isTypeOnly: binding.isTypeOnly,
164
- hasNamespaceImport: binding.hasNamespaceImport,
165
- });
166
- continue;
167
- }
168
- if (!localDeclarations.has(localName)) {
169
- throw new Error(
170
- `[auklet:css] Unable to resolve exported symbol "${localName}" for CSS auto import.\n` +
171
- `File: ${file}`,
172
- );
173
- }
174
- }
175
- };
176
- const getExportedNames = (node) => {
177
- if (!node.exportClause || !ts.isNamedExports(node.exportClause)) {
178
- return [];
179
- }
180
- return node.exportClause.elements
181
- .filter((element) => !element.isTypeOnly)
182
- .map((element) => (element.propertyName ?? element.name).text);
183
- };
184
- const isTypeOnlyImportClause = (importClause) => {
185
- return importClause?.phaseModifier === ts.SyntaxKind.TypeKeyword;
186
- };
187
- const createNamespaceImportError = (file, importPath) => {
188
- return new Error(
189
- `Namespace import is not supported for CSS auto import: ${importPath}\n` +
190
- `Use named imports instead, for example: import { Component } from '${importPath}'.\n` +
191
- `File: ${file}`,
192
- );
193
- };
@@ -1,71 +0,0 @@
1
- import path from 'node:path';
2
- import { writeStyleFile } from '#auklet/css/production/format/shared';
3
- import { toPosixPath } from '#auklet/utils';
4
- export class ComponentStyleEntryWriter {
5
- config;
6
- sourceRoot;
7
- resolver;
8
- styleProcessor;
9
- constructor(options) {
10
- this.config = options.config;
11
- this.sourceRoot = options.packageContext.sourceRoot;
12
- this.resolver = options.packageContext.resolver;
13
- this.styleProcessor = options.packageContext.styleProcessor;
14
- }
15
- write(outRoot, entries) {
16
- const outputs = [];
17
- for (const entry of entries) {
18
- const styleDir = path.join(
19
- outRoot,
20
- entry.sourceDir,
21
- this.config.output.styleDir,
22
- );
23
- const target = path.join(styleDir, this.config.output.indexStyleFile);
24
- const ownImports = this.styleProcessor.collectStyleImportSpecifiers(
25
- entry.ownStyleFiles,
26
- );
27
- const sourceStyleSpecifiers = [
28
- ...this.getModuleStyleSpecifiers(
29
- entry.moduleStyleImports.filter(
30
- (specifier) => !ownImports.has(specifier),
31
- ),
32
- styleDir,
33
- ),
34
- ...this.getOwnStyleSpecifiers(entry.ownStyleFiles, styleDir, outRoot),
35
- ];
36
- const root = this.styleProcessor.createRoot();
37
- const seen = new Set();
38
- for (const specifier of sourceStyleSpecifiers) {
39
- if (seen.has(specifier)) continue;
40
- seen.add(specifier);
41
- this.styleProcessor.appendImportRule(
42
- root,
43
- this.resolver.toOutputStyleSpecifier(specifier, outRoot),
44
- );
45
- }
46
- writeStyleFile(
47
- target,
48
- root.nodes?.length ? this.styleProcessor.stringify(root) : '',
49
- );
50
- outputs.push(target);
51
- }
52
- return outputs;
53
- }
54
- getModuleStyleSpecifiers(specifiers, styleDir) {
55
- return specifiers.map((specifier) => {
56
- if (specifier.startsWith('.')) return specifier;
57
- if (!path.isAbsolute(specifier)) return specifier;
58
- return toPosixPath(path.relative(styleDir, specifier));
59
- });
60
- }
61
- getOwnStyleSpecifiers(ownStyleFiles, styleDir, outRoot) {
62
- return ownStyleFiles.map((styleFile) =>
63
- toPosixPath(
64
- path.relative(
65
- styleDir,
66
- path.join(outRoot, path.relative(this.sourceRoot, styleFile)),
67
- ),
68
- ),
69
- );
70
- }
71
- }