Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@atom-learning/icons",
"main": "dist/index.cjs.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"version": "1.21.0",
"description": "",
"files": [
Expand Down
14 changes: 14 additions & 0 deletions scripts/build-export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@ const outputESEntry = async (icons) => {
await fs.writeFile(path.resolve(DIRECTORY_OUTPUT, 'index.js'), template)
}

const outputTypeDeclarations = async (icons: Record<string, string>) => {
for (const [name] of Object.entries(icons)) {
const componentName = changeCase.pascalCase(name)
const declaration = `import { FC, SVGProps } from 'react';\nexport declare const ${componentName}: FC<SVGProps<SVGSVGElement>>;\n`
await fs.writeFile(path.resolve(DIRECTORY_OUTPUT, `${name}.d.ts`), declaration)
}

const indexDeclaration = Object.entries(icons)
.map(([name]) => `export * from './${name}';\n`)
.join('')
await fs.writeFile(path.resolve(DIRECTORY_OUTPUT, 'index.d.ts'), indexDeclaration)
}

const outputCJSBundle = async () => {
await buildSync({
entryPoints: [path.resolve(DIRECTORY_OUTPUT, 'index.js')],
Expand Down Expand Up @@ -137,6 +150,7 @@ const run = async () => {
await fs.writeFile(path.resolve(DIRECTORY_OUTPUT, `${name}.js`), code)
}

await outputTypeDeclarations(icons)
await outputCJSBundle()
}

Expand Down
Loading