Skip to content

Commit

Permalink
Merge pull request #308 from nrkno/use-dtsLiteral
Browse files Browse the repository at this point in the history
Use dts literal
  • Loading branch information
torgeilo authored Aug 21, 2024
2 parents c151a18 + f16a04b commit 5ee92e4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
15 changes: 4 additions & 11 deletions bin/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,10 @@ function buildIcons (groupName) {
createZipArchive(staticDest, '**/*.pdf', staticFolder, `${bundleName}-pdf`)

// svgToJs
const customOutputs = [
{
parser: ({ camelCase, svg }) => `export declare const ${camelCase}: '${svg}'`,
},
]
const icons = svgToJS({
input: staticDest,
banner: `@nrk/core-icons ${groupName} v${version}`,
scale: 16,
customOutputs
scale: 16
})
// Generate iife
fse.writeFileSync(
Expand All @@ -145,7 +139,7 @@ function buildIcons (groupName) {
// Generate js and mjs with types for icons and logos
fse.writeFileSync(path.join(npmPath, `${bundleName}.js`), icons.cjs)
fse.writeFileSync(path.join(npmPath, `${bundleName}.mjs`), icons.esm)
fse.writeFileSync(path.join(npmPath, `${bundleName}.d.ts`), icons.custom_1)
fse.writeFileSync(path.join(npmPath, `${bundleName}.d.ts`), icons.dtsLiteral)

// Generate jsx and mjsx with types for icons and logos
fse.writeFileSync(path.join(npmJsxFolder, npmPath, `${bundleName}.js`), icons.cjsx)
Expand All @@ -160,8 +154,7 @@ function buildIcons (groupName) {
const largeIcons = svgToJS({
input: staticLargeDest,
banner: `@nrk/core-icons ${groupName} v${version}`,
scale: 16,
customOutputs
scale: 16
})
const npmLargePath = path.join(npmPath, 'large')
const largeBundleName = `${bundleName}-large`
Expand All @@ -177,7 +170,7 @@ function buildIcons (groupName) {
// Generate js and mjs with types for icons and logos
fse.writeFileSync(path.join(npmLargePath, `${largeBundleName}.js`), largeIcons.cjs)
fse.writeFileSync(path.join(npmLargePath, `${largeBundleName}.mjs`), largeIcons.esm)
fse.writeFileSync(path.join(npmLargePath, `${largeBundleName}.d.ts`), largeIcons.custom_1)
fse.writeFileSync(path.join(npmLargePath, `${largeBundleName}.d.ts`), largeIcons.dtsLiteral)

// Generate jsx and mjsx with types for icons and logos
fse.writeFileSync(path.join(npmJsxFolder, npmLargePath, `${largeBundleName}.js`), largeIcons.cjsx)
Expand Down
17 changes: 9 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
},
"devDependencies": {
"@arethetypeswrong/cli": "0.15.2",
"@nrk/svg-to-js": "3.0.1",
"@nrk/svg-to-js": "3.1.0",
"@types/fs-extra": "11.0.4",
"archiver": "6.0.1",
"chokidar-cli": "3.0.0",
Expand Down

0 comments on commit 5ee92e4

Please sign in to comment.