Skip to content

Commit

Permalink
Add a @cubing/icons/js entry point, transpiled via TypeScript.
Browse files Browse the repository at this point in the history
For a discussion of tradeoffs, see: #146
  • Loading branch information
lgarron committed Jan 23, 2025
1 parent a8bc8ce commit 57e8e3b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions js/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "../dist/lib/@cubing/icons/js/ts/index.d.ts";
1 change: 1 addition & 0 deletions js/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "../dist/lib/@cubing/icons/js/ts/index.js";
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"@types/bun": "^1.1.14",
"@types/jsdom": "^21.1.7",
"fantasticon": "^3.0.0",
"jsdom": "^25.0.1"
"jsdom": "^25.0.1",
"typescript": "^5.7.3"
},
"exports": {
".": {
Expand All @@ -28,6 +29,10 @@
"./css": {
"default": "./dist/lib/@cubing/icons/cubing-icons.css"
},
"./js": {
"types": "./dist/lib/@cubing/icons/js/ts/index.d.ts",
"default": "./dist/lib/@cubing/icons/js/ts/index.js"
},
"./ts": {
"default": "./ts/index.ts"
}
Expand Down
11 changes: 11 additions & 0 deletions script/build-lib.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { mkdir, readFile, writeFile } from "node:fs/promises";
import { join } from "node:path";
import { $ } from "bun";
import { FontAssetType, OtherAssetType, generateFonts } from "fantasticon";

const LIB_OUTPUT_DIR = "dist/lib/@cubing/icons";
Expand Down Expand Up @@ -29,4 +30,14 @@ await writeFile(
),
);

// This places output files in an awkward directory structure, but it keeps our
// transpilation setup as simple as possible. The alternatives come with
// potentially heavy tradeoffs: https://github.com/cubing/icons/issues/146
await $`bun x tsc \
--skipLibCheck \
--declaration \
--target es2022 \
--outdir ./dist/lib/@cubing/icons/js \
./ts/index.ts`;

console.log(`The library has been built at: ${LIB_OUTPUT_DIR}`);

0 comments on commit 57e8e3b

Please sign in to comment.