Skip to content

Commit

Permalink
Merge pull request #110 from evoactivity/patch-1
Browse files Browse the repository at this point in the history
Output named exports
  • Loading branch information
activeguild authored Dec 24, 2024
2 parents 920e7ff + abbb79c commit aa1fae6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ export const writeToFile = async (
) => {
const typeName = getTypeName(path.basename(fileName), options)
let exportTypes = ''
let namedExports = ''
const exportStyle = options?.esmExport
? 'export default classNames;'
: 'export = classNames;'
for (const classNameKey of classNameKeys.keys()) {
exportTypes = `${exportTypes}\n${formatExportType(classNameKey, typeName)}`
namedExports = `${namedExports}\nexport const ${classNameKey}: '${
typeName ?? classNameKey
}';`
}

let outputFileString = ''
Expand All @@ -34,9 +38,9 @@ export const writeToFile = async (
options.global.outputFilePath
)
outputFileString = `import globalClassNames from '${relativePath}${exportTypeFileName}'\n`
outputFileString = `${outputFileString}declare const classNames: typeof globalClassNames & {${exportTypes}\n};\n${exportStyle}`
outputFileString = `${outputFileString}\n${namedExports}\n\ndeclare const classNames: typeof globalClassNames & {${exportTypes}\n};\n${exportStyle}`
} else {
outputFileString = `declare const classNames: {${exportTypes}\n};\n${exportStyle}`
outputFileString = `${namedExports}\n\ndeclare const classNames: {${exportTypes}\n};\n${exportStyle}`
}

const prettierdOutputFileString = await format(
Expand Down

1 comment on commit aa1fae6

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bundled size for the package is listed below:

dist: 46.88 KB

Please sign in to comment.