Skip to content

Commit aa1fae6

Browse files
authored
Merge pull request #110 from evoactivity/patch-1
Output named exports
2 parents 920e7ff + abbb79c commit aa1fae6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/write.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@ export const writeToFile = async (
1717
) => {
1818
const typeName = getTypeName(path.basename(fileName), options)
1919
let exportTypes = ''
20+
let namedExports = ''
2021
const exportStyle = options?.esmExport
2122
? 'export default classNames;'
2223
: 'export = classNames;'
2324
for (const classNameKey of classNameKeys.keys()) {
2425
exportTypes = `${exportTypes}\n${formatExportType(classNameKey, typeName)}`
26+
namedExports = `${namedExports}\nexport const ${classNameKey}: '${
27+
typeName ?? classNameKey
28+
}';`
2529
}
2630

2731
let outputFileString = ''
@@ -34,9 +38,9 @@ export const writeToFile = async (
3438
options.global.outputFilePath
3539
)
3640
outputFileString = `import globalClassNames from '${relativePath}${exportTypeFileName}'\n`
37-
outputFileString = `${outputFileString}declare const classNames: typeof globalClassNames & {${exportTypes}\n};\n${exportStyle}`
41+
outputFileString = `${outputFileString}\n${namedExports}\n\ndeclare const classNames: typeof globalClassNames & {${exportTypes}\n};\n${exportStyle}`
3842
} else {
39-
outputFileString = `declare const classNames: {${exportTypes}\n};\n${exportStyle}`
43+
outputFileString = `${namedExports}\n\ndeclare const classNames: {${exportTypes}\n};\n${exportStyle}`
4044
}
4145

4246
const prettierdOutputFileString = await format(

0 commit comments

Comments
 (0)