Skip to content

Commit

Permalink
fix: export collectionNames
Browse files Browse the repository at this point in the history
  • Loading branch information
hyoban committed Jan 31, 2024
1 parent 1e85007 commit 33c1684
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions gen-types.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ const collections = req("@iconify/json/collections.json")

fs.writeFileSync(
"types.ts",
`export const availableCollectionNames = [${Object.keys(collections)
`export const collectionNames = [${Object.keys(collections)
.map((v) => JSON.stringify(v))
.join(", ")}] as const
/** All the available icon collections when you have \`@iconify/json\` installed */\nexport type CollectionNames = typeof availableCollectionNames[number]
/** All the available icon collections when you have \`@iconify/json\` installed */\nexport type CollectionNames = typeof collectionNames[number]
`,
)
4 changes: 2 additions & 2 deletions src/dynamic.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { availableCollectionNames } from "../types"
import { collectionNames } from "../types"
import { generateComponent, getIconCollections } from "./core"

import type { CollectionNames } from "../types"
Expand Down Expand Up @@ -27,7 +27,7 @@ export function getDynamicCSSRules(

const prefix = nameParts[0]
const name = nameParts[1]!
if (!availableCollectionNames.includes(prefix as CollectionNames)) {
if (!collectionNames.includes(prefix as CollectionNames)) {
throw new Error(`Invalid collection name: "${prefix}"`)
}

Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { parseIconSet } from "@iconify/utils"
import plugin from "tailwindcss/plugin.js"

import { availableCollectionNames } from "../types"
import { collectionNames } from "../types"
import {
generateIconComponent,
getIconCollections,
Expand All @@ -14,7 +14,7 @@ import type { GenerateOptions } from "./core"
import type { Optional } from "./utils"
import type { IconifyJSONIconsData } from "@iconify/types"

export { getIconCollections, type CollectionNames }
export { getIconCollections, collectionNames, type CollectionNames }

type CollectionNamesAlias = {
[key in CollectionNames]?: string
Expand Down Expand Up @@ -47,7 +47,7 @@ export const iconsPlugin = (iconsPluginOptions?: IconsPluginOptions) => {
const collections =
propsCollections ??
getIconCollections(
availableCollectionNames.filter((name) =>
collectionNames.filter((name) =>
isPackageExists(`@iconify-json/${name}`),
),
)
Expand Down

0 comments on commit 33c1684

Please sign in to comment.