Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tree shaking: react-ui fix #837

Merged
merged 3 commits into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 packages/client/ui/react-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"types": "./dist/index.d.ts",
"files": ["dist", "src", "LICENSE"],
"scripts": {
"build": "tsup",
"build": "NODE_OPTIONS='--max-old-space-size=8192' tsup",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

building locally wouldn't work until i increased the old-space memory size.

"dev": "tsup --watch",
"test": "vitest run"
},
Expand Down
7 changes: 6 additions & 1 deletion packages/client/ui/react-ui/src/hooks/useCrossmint.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { type ReactNode, createContext, useCallback, useContext, useMemo, useRef, useState } from "react";

import { type Crossmint, createCrossmint } from "@crossmint/common-sdk-base";
import { TwindProvider } from "@/providers/TwindProvider";

export interface CrossmintContext {
crossmint: Crossmint;
Expand Down Expand Up @@ -56,7 +57,11 @@ export function CrossmintProvider({
[setJwt, setRefreshToken, version]
);

return <CrossmintContext.Provider value={value}>{children}</CrossmintContext.Provider>;
return (
<CrossmintContext.Provider value={value}>
mPaella marked this conversation as resolved.
Show resolved Hide resolved
<TwindProvider>{children}</TwindProvider>
</CrossmintContext.Provider>
);
}

export function useCrossmint(missingContextMessage?: string) {
Expand Down
8 changes: 0 additions & 8 deletions packages/client/ui/react-ui/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
import { install } from "@twind/core";

import twindConfig from "./twind.config";

// Initialize twind with custom configuration
// This sets up the CSS-in-JS styling solution for the entire application
install(twindConfig);

export * from "./components";
export * from "./hooks";
export * from "./providers";
Expand Down
14 changes: 14 additions & 0 deletions packages/client/ui/react-ui/src/providers/TwindProvider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type React from "react";
import twindConfig from "@/twind.config";
import { install } from "@twind/core";
import { useEffect } from "react";

export function TwindProvider({ children }: { children: React.ReactNode }) {
useEffect(() => {
// Initialize twind with custom configuration
// This sets up the CSS-in-JS styling solution for the entire application
install(twindConfig);
}, []);

return <>{children}</>;
}
1 change: 0 additions & 1 deletion packages/client/ui/react-ui/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { treeShakableConfig } from "../../../../tsup.config.base";
const config: Options = {
...treeShakableConfig,
external: ["react", "react-dom"],
entry: ["src/index.ts"],
};

export default config;
Loading