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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "purestack-repo",
"version": "1.1.11",
"version": "1.1.12",
"packageManager": "yarn@4.18.1",
"type": "module",
"sideEffects": false,
Expand Down
2 changes: 1 addition & 1 deletion packages/purestack/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "purestack",
"version": "1.1.11",
"version": "1.1.12",
"packageManager": "yarn@4.9.2",
"module": "./dist/purestack.mjs",
"types": "./dist/purestack.d.mts",
Expand Down
2 changes: 1 addition & 1 deletion packages/purestack/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const version: string = '1.1.11'
export const version: string = '1.1.12'

export * from '@purestack/ts-ssg'
2 changes: 1 addition & 1 deletion packages/ts-common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@purestack/ts-common",
"version": "1.1.11",
"version": "1.1.12",
"packageManager": "yarn@4.9.2",
"module": "./dist/ts-common.mjs",
"types": "./dist/ts-common.d.mts",
Expand Down
2 changes: 1 addition & 1 deletion packages/ts-components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@purestack/ts-components",
"version": "1.1.11",
"version": "1.1.12",
"packageManager": "yarn@4.9.2",
"module": "./dist/ts-components.mjs",
"types": "./dist/ts-components.d.mts",
Expand Down
2 changes: 1 addition & 1 deletion packages/ts-css/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@purestack/ts-css",
"version": "1.1.11",
"version": "1.1.12",
"packageManager": "yarn@4.9.2",
"module": "./dist/ts-css.mjs",
"types": "./dist/ts-css.d.mts",
Expand Down
2 changes: 1 addition & 1 deletion packages/ts-html/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@purestack/ts-html",
"version": "1.1.11",
"version": "1.1.12",
"packageManager": "yarn@4.9.2",
"module": "./dist/ts-html.mjs",
"types": "./dist/ts-html.d.mts",
Expand Down
2 changes: 1 addition & 1 deletion packages/ts-minidom/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@purestack/ts-minidom",
"version": "1.1.11",
"version": "1.1.12",
"packageManager": "yarn@4.9.2",
"module": "./dist/ts-minidom.mjs",
"types": "./dist/ts-minidom.d.mts",
Expand Down
2 changes: 1 addition & 1 deletion packages/ts-page-scripts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@purestack/ts-page-scripts",
"version": "1.1.11",
"version": "1.1.12",
"packageManager": "yarn@4.9.2",
"module": "./dist/ts-page-scripts.mjs",
"types": "./dist/ts-page-scripts.d.mts",
Expand Down
2 changes: 1 addition & 1 deletion packages/ts-render/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@purestack/ts-render",
"version": "1.1.11",
"version": "1.1.12",
"packageManager": "yarn@4.9.2",
"module": "./dist/ts-render.mjs",
"types": "./dist/ts-render.d.mts",
Expand Down
2 changes: 1 addition & 1 deletion packages/ts-ssg-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "purestack-component-navigation",
"displayName": "PureStack Component Tools",
"description": "Component navigation, prop IntelliSense, lit-html syntax highlighting, and template formatting for Markdown, Regor MDX, and TypeScript templates.",
"version": "1.1.11",
"version": "1.1.12",
"private": true,
"publisher": "purestack",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/ts-ssg/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@purestack/ts-ssg",
"version": "1.1.11",
"version": "1.1.12",
"packageManager": "yarn@4.9.2",
"module": "./dist/ts-ssg.mjs",
"types": "./dist/ts-ssg.d.mts",
Expand Down
85 changes: 85 additions & 0 deletions packages/ts-ssg/src/build/svg-icons.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { fileURLToPath } from 'node:url'
import { build } from 'esbuild'
import { describe, expect, it } from 'vitest'
import {
getSvgIcon,
iconoir_cube,
lucide_chevron_down,
phosphor_acorn,
tabler_world,
} from '../../../ts-svg-icons/src/index'

describe('SVG icon exports', () => {
it('resolves server lookup names to the direct export for each provider', () => {
expect(getSvgIcon('iconoir:cube')).toBe(iconoir_cube)
expect(getSvgIcon('lucide:chevron-down')).toBe(lucide_chevron_down)
expect(getSvgIcon('phosphor:acorn')).toBe(phosphor_acorn)
expect(getSvgIcon('tabler:world')).toBe(tabler_world)
})

it('passes inline SVG through unchanged', () => {
expect(getSvgIcon(tabler_world)).toBe(tabler_world)
})

it('reports unknown icon names', () => {
expect(() => getSvgIcon('missing:icon')).toThrow(
'Unknown icon: missing:icon',
)
})

it('tree-shakes named imports after the package exports are bundled together', async () => {
// Reproduce a package build followed by a browser build. The catalog lookup
// remains exported in the first stage, but must disappear in the second.
const published = await build({
entryPoints: [
fileURLToPath(
new URL('../../../ts-svg-icons/src/index.ts', import.meta.url),
),
],
bundle: true,
format: 'esm',
platform: 'node',
treeShaking: true,
write: false,
})
const browser = await build({
stdin: {
contents: `import { iconoir_cube, lucide_chevron_down, phosphor_acorn, tabler_world } from 'published-icons';
export const icons = [iconoir_cube, lucide_chevron_down, phosphor_acorn, tabler_world];`,
},
bundle: true,
format: 'esm',
platform: 'browser',
treeShaking: true,
write: false,
plugins: [
{
name: 'published-icon-package',
setup(builder) {
builder.onResolve({ filter: /^published-icons$/ }, () => ({
path: 'published-icons',
namespace: 'icon-package',
}))
builder.onLoad({ filter: /.*/, namespace: 'icon-package' }, () => ({
contents: published.outputFiles[0].text,
loader: 'js',
}))
},
},
],
})
const output = browser.outputFiles[0]
expect(output.contents.byteLength).toBeLessThan(20_000)
expect(output.text).not.toContain('SVG_ICONS')
expect(output.text).not.toContain('iconoir_accessibility')
const result = await import(
/* @vite-ignore */ `data:text/javascript;base64,${Buffer.from(output.contents).toString('base64')}`
)
expect(result.icons).toEqual([
iconoir_cube,
lucide_chevron_down,
phosphor_acorn,
tabler_world,
])
})
})
2 changes: 1 addition & 1 deletion packages/ts-ssg/src/config/head.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function getHead(config?: BasicHeadConfig) {
const head = createHead(getHeadConfig(merge(DEFAULTS, config))).push(
h('meta').attr({
name: 'generator',
content: 'PureStack v1.1.11',
content: 'PureStack v1.1.12',
}),
h('meta').attr({
name: 'color-scheme',
Expand Down
2 changes: 1 addition & 1 deletion packages/ts-style/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@purestack/ts-style",
"version": "1.1.11",
"version": "1.1.12",
"packageManager": "yarn@4.9.2",
"module": "./dist/ts-style.mjs",
"types": "./dist/ts-style.d.mts",
Expand Down
2 changes: 1 addition & 1 deletion packages/ts-svg-icons/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@purestack/ts-svg-icons",
"version": "1.1.11",
"version": "1.1.12",
"packageManager": "yarn@4.9.2",
"module": "./dist/ts-svg-icons.mjs",
"types": "./dist/ts-svg-icons.d.mts",
Expand Down
13 changes: 5 additions & 8 deletions packages/ts-svg-icons/src/getSvgIcon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@ export type AvailableIconNames =
| TablerIconName
| (string & {})

const SVG_ICONS: Record<AvailableIconNames, string> = {
...ICONOIR_ICONS,
...LUCIDE_ICONS,
...PHOSPHOR_ICONS,
...TABLER_ICONS,
}

/**
* Returns an SVG string for a generated icon name or passes through raw SVG input.
*
Expand All @@ -32,7 +25,11 @@ const SVG_ICONS: Record<AvailableIconNames, string> = {
*/
export function getSvgIcon(name: AvailableIconNames): string {
if (name?.includes('<svg')) return name
const icon = SVG_ICONS[name]
const icon =
ICONOIR_ICONS[name as IconoirIconName] ??
LUCIDE_ICONS[name as LucideIconName] ??
PHOSPHOR_ICONS[name as PhosphorIconName] ??
TABLER_ICONS[name as TablerIconName]
if (!icon) throw new Error(`Unknown icon: ${name}`)
return icon
}
Loading
Loading