Skip to content

Commit

Permalink
Merge pull request #92 from pavlovalor/feature/esm-export-option
Browse files Browse the repository at this point in the history
ESM export option added
  • Loading branch information
activeguild authored Apr 26, 2024
2 parents 478db86 + 14bb906 commit 51e5e54
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ npm i -D vite-plugin-sass-dts
| typeName.replacement | string \| (fileName: string) => string | Type name can be changed to any value. (default is the classname key as a string. e.g. `theClassName: 'theClassName';`) |
| outputDir | string | An absolute path to the output directory. If undefined, declaration files will be generated in the source directories. `) |
| sourceDir | string | An absolute path to your source code directory. The plugin will replace this path with `outputDir` option when writing declaration files. `) |
| esmExport | boolean | Specify dts export type. If enabled, going to use ESM style export `export default ...`. Otherwise `export = ...`.
| prettierFilePath | string | Specify the path to the prettier configuration file. |

## Add it to vite.config.ts
Expand Down
1 change: 1 addition & 0 deletions src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type PluginOptions = {
enabledMode?: ('development' | 'production')[]
global?: { generate: boolean; outputFilePath: string }
typeName?: { replacement: string | ((fileName: string) => string) }
esmExport?: boolean
outputDir?: string
sourceDir?: string
prettierFilePath?: string
Expand Down
4 changes: 3 additions & 1 deletion src/write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ export const writeToFile = async (
) => {
const typeName = getTypeName(path.basename(fileName), options)
let exportTypes = ''
const exportStyle = 'export = classNames;'
const exportStyle = options?.esmExport
? 'export default classNames;'
: 'export = classNames;'
for (const classNameKey of classNameKeys.keys()) {
exportTypes = `${exportTypes}\n${formatExportType(classNameKey, typeName)}`
}
Expand Down

1 comment on commit 51e5e54

@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: 42.97 KB

Please sign in to comment.