Skip to content

Commit 4cfa6d8

Browse files
authored
New exports (#29)
* Publish themes as ESM wrapper modules for npm consumers Instead of requiring raw JSON imports (which break in Node ESM without import attributes), the build now generates dist/*.mjs wrappers that inline each theme as `export default Object.freeze(JSON.parse(...))`, following the same pattern as @shikijs/themes. * Bump version * Add build step to npm publish job and verify dist in CI The npm publish job was missing install + build steps, so dist/ would not exist when publishing. Also adds a verification step to the test workflow to confirm all ESM wrapper modules are generated.
1 parent b338c94 commit 4cfa6d8

9 files changed

Lines changed: 84 additions & 7 deletions

File tree

.github/workflows/publish.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ jobs:
5656
cache: 'npm'
5757
registry-url: 'https://registry.npmjs.org'
5858

59+
- name: Install dependencies
60+
run: npm ci
61+
62+
- name: Build theme
63+
run: npm run build
64+
5965
- name: Publish to npm
6066
env:
6167
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/test.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ jobs:
4444
fi
4545
echo "✅ All theme files generated successfully"
4646
47+
- name: Verify ESM wrapper modules exist
48+
run: |
49+
for theme in pierre-dark pierre-light pierre-dark-vibrant pierre-light-vibrant; do
50+
if [ ! -f "dist/${theme}.mjs" ]; then
51+
echo "❌ dist/${theme}.mjs not generated"
52+
exit 1
53+
fi
54+
done
55+
if [ ! -f "dist/index.mjs" ]; then
56+
echo "❌ dist/index.mjs not generated"
57+
exit 1
58+
fi
59+
echo "✅ All ESM wrapper modules generated successfully"
60+
4761
- name: Check file sizes
4862
run: |
4963
light_size=$(wc -c < themes/pierre-light.json)

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.DS_Store
22
node_modules/
33
build
4+
dist
45
*.vsix

.vscodeignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
/package-lock.json
88
/src/
99
/build/
10+
/dist/

README.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,30 @@ OPEN POSITIONS: [Systems Engineer](https://pierre.computer/careers/systems-engin
1111
1212
~~~
1313
14-
Overview:
15-
- Light and dark themes for Visual Studio Code, Cursor, Zed, and Shiki.
14+
Overview:
15+
- Light and dark themes for Visual Studio Code, Cursor, Zed, and Shiki.
1616
- Built for [Diffs.com](https://diffs.com)
17+
18+
~~~
19+
20+
Usage:
21+
22+
VS Code / Cursor:
23+
1. Install "Pierre Theme" from the Extensions marketplace
24+
2. Cmd+Shift+P > "Color Theme" > select Pierre Light or Pierre Dark
25+
26+
Shiki / npm:
27+
npm install @pierre/theme
28+
29+
import pierreDark from '@pierre/theme/pierre-dark'
30+
import pierreLight from '@pierre/theme/pierre-light'
31+
32+
Available themes:
33+
- @pierre/theme/pierre-dark
34+
- @pierre/theme/pierre-light
35+
- @pierre/theme/pierre-dark-vibrant (Display P3)
36+
- @pierre/theme/pierre-light-vibrant (Display P3)
37+
38+
Zed:
39+
Install "Pierre" from the Zed extension registry
40+
```

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@pierre/theme",
33
"displayName": "Pierre Theme",
44
"description": "Pierre theme for Shiki, VS Code, and more",
5-
"version": "0.0.24",
5+
"version": "0.0.25",
66
"publisher": "pierrecomputer",
77
"icon": "icon.png",
88
"galleryBanner": {
@@ -47,14 +47,24 @@
4747
"build": "ts-node src/build.ts",
4848
"test": "npm run build && ts-node src/test.ts",
4949
"start": "nodemon --watch src --ext ts --exec npm run build",
50-
"package": "ts-node src/package-vsix.ts"
50+
"package": "ts-node src/package-vsix.ts",
51+
"prepublishOnly": "npm run build"
5152
},
5253
"devDependencies": {
5354
"@vscode/vsce": "^3.2.2",
5455
"nodemon": "^3.1.11",
5556
"ts-node": "^10.9.2",
5657
"typescript": "^5.9.3"
5758
},
59+
"sideEffects": false,
60+
"exports": {
61+
".": "./dist/index.mjs",
62+
"./pierre-dark": "./dist/pierre-dark.mjs",
63+
"./pierre-light": "./dist/pierre-light.mjs",
64+
"./pierre-dark-vibrant": "./dist/pierre-dark-vibrant.mjs",
65+
"./pierre-light-vibrant": "./dist/pierre-light-vibrant.mjs",
66+
"./themes/*": "./themes/*"
67+
},
5868
"publishConfig": {
5969
"access": "public"
6070
}

src/build.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,24 @@ const zedTheme = makeZedThemeFamily("Pierre", "pierrecomputer", [
3737

3838
writeFileSync("zed/themes/pierre.json", JSON.stringify(zedTheme, null, 2), "utf8");
3939
console.log("Wrote zed/themes/pierre.json");
40+
41+
// ============================================
42+
// ESM wrapper modules (for npm / Shiki consumers)
43+
// ============================================
44+
mkdirSync("dist", { recursive: true });
45+
46+
const themeNames: string[] = [];
47+
48+
for (const { file, theme } of vscodeThemes) {
49+
const name = file.replace("themes/", "").replace(".json", "");
50+
themeNames.push(name);
51+
const json = JSON.stringify(theme);
52+
const escaped = json.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
53+
const mjs = `export default Object.freeze(JSON.parse('${escaped}'))\n`;
54+
writeFileSync(`dist/${name}.mjs`, mjs, "utf8");
55+
console.log("Wrote", `dist/${name}.mjs`);
56+
}
57+
58+
const indexMjs = `export const themeNames = ${JSON.stringify(themeNames)}\n`;
59+
writeFileSync("dist/index.mjs", indexMjs, "utf8");
60+
console.log("Wrote dist/index.mjs");

zed/extension.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
id = "pierre-theme"
22
name = "Pierre"
33
description = "A warm, orange-accented color theme with light and dark variants"
4-
version = "0.0.24"
4+
version = "0.0.25"
55
schema_version = 1
66
authors = ["pierrecomputer"]
77
repository = "https://github.com/pierrecomputer/pierre-theme"

0 commit comments

Comments
 (0)