Skip to content

Commit e6a2181

Browse files
committed
Fix tree-shaking
1 parent 92c1b0d commit e6a2181

File tree

3 files changed

+108
-48
lines changed

3 files changed

+108
-48
lines changed

packages/solid-styled/src/core.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,15 @@ if (!isServer) {
2828
}
2929
}
3030

31-
function insert(id: string, sheet: string): void {
31+
function noopInsert(_id: string, _sheet: string): void {
32+
// no-op
33+
}
34+
35+
function noopRemove(_id: string): void {
36+
// no-op
37+
}
38+
39+
function clientInsert(id: string, sheet: string): void {
3240
if (!tracked.has(id)) {
3341
tracked.add(id);
3442

@@ -40,7 +48,7 @@ function insert(id: string, sheet: string): void {
4048
references.set(id, (references.get(id) ?? 0) + 1);
4149
}
4250

43-
function remove(id: string): void {
51+
function clientRemove(id: string): void {
4452
const count = references.get(id) ?? 0;
4553
if (count > 1) {
4654
references.set(id, count - 1);
@@ -56,6 +64,9 @@ function remove(id: string): void {
5664
}
5765
}
5866

67+
const insert = isServer ? noopInsert : clientInsert;
68+
const remove = isServer ? noopRemove : clientRemove;
69+
5970
interface StyleRegistryContextValue {
6071
insert(id: string, sheet: string): void;
6172
remove(id: string): void;
@@ -74,10 +85,6 @@ export interface StyleRegistryProps {
7485
children?: JSX.Element;
7586
}
7687

77-
function noopRemove(_id: string): void {
78-
// no-op
79-
}
80-
8188
function ServerStyleRegistry(props: StyleRegistryProps): JSX.Element {
8289
let styles = props.styles;
8390

packages/vite/package.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22
"name": "vite-plugin-solid-styled",
33
"version": "0.11.1",
44
"type": "module",
5-
"files": ["dist", "babel", "core"],
5+
"files": [
6+
"dist",
7+
"babel",
8+
"core"
9+
],
610
"engines": {
711
"node": ">=10"
812
},
913
"license": "MIT",
10-
"keywords": ["pridepack"],
14+
"keywords": [
15+
"pridepack"
16+
],
1117
"devDependencies": {
1218
"@types/node": "^22.13.1",
1319
"pridepack": "2.6.4",
@@ -52,13 +58,13 @@
5258
"module": "./dist/esm/production/index.mjs",
5359
"exports": {
5460
".": {
61+
"types": "./dist/types/index.d.ts",
5562
"development": {
5663
"require": "./dist/cjs/development/index.cjs",
5764
"import": "./dist/esm/development/index.mjs"
5865
},
5966
"require": "./dist/cjs/production/index.cjs",
60-
"import": "./dist/esm/production/index.mjs",
61-
"types": "./dist/types/index.d.ts"
67+
"import": "./dist/esm/production/index.mjs"
6268
}
6369
},
6470
"typesVersions": {

0 commit comments

Comments
 (0)