Skip to content

Commit

Permalink
Updated exports/imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Neo-Ciber94 committed Sep 25, 2023
1 parent 1303ae7 commit c8efff8
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 11 deletions.
4 changes: 2 additions & 2 deletions examples/next-mal-auth/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "./globals.css";
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import { SessionProvider } from "@animelist/auth-next";
import Providers from "./providers";

const inter = Inter({ subsets: ["latin"] });

Expand All @@ -18,7 +18,7 @@ export default function RootLayout({
return (
<html lang="en">
<body className={inter.className}>
<SessionProvider>{children}</SessionProvider>
<Providers>{children}</Providers>
</body>
</html>
);
Expand Down
6 changes: 4 additions & 2 deletions examples/next-mal-auth/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"use client";

import { useSession } from "@animelist/auth-next";
import { signIn, signOut } from "@animelist/auth";
import { signIn, signOut } from "@animelist/auth/client";

export default function Home() {
const { user, isLoading } = useSession();
Expand All @@ -9,7 +11,7 @@ export default function Home() {
{isLoading && <p>Loading...</p>}
{!isLoading && user == null && <button onClick={signIn}>Login</button>}
{!isLoading && user != null && <button onClick={signOut}>Logout</button>}
{user && <p>{`Welcome ${user.username}`}</p>}
{user && <p>{`Welcome ${user.name}`}</p>}
</div>
);
}
7 changes: 7 additions & 0 deletions examples/next-mal-auth/src/app/providers.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"use client";

import { SessionProvider } from "@animelist/auth-next";

export default function Providers({ children }: { children: React.ReactNode }) {
return <SessionProvider>{children}</SessionProvider>;
}
2 changes: 1 addition & 1 deletion packages/animelist-auth-next/esbuild.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { fileURLToPath } from "url";
const packageDir = path.dirname(fileURLToPath(import.meta.url));

await esbuildProject({
inputs: ["src/**/*.ts"],
inputs: ["src/**/*.ts", "src/**/*.tsx"],
exclude: ["**/*.test.ts"],
packageDir,
});
8 changes: 4 additions & 4 deletions packages/animelist-auth-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
"access": "public"
},
"./package.json": "./package.json",
"./client": {
"import": "./dist/client/index.mjs",
"require": "./dist/client/index.js",
"default": "./dist/client/index.js"
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.js",
"default": "./dist/index.js"
},
"./server": {
"import": "./dist/server/index.mjs",
Expand Down
3 changes: 3 additions & 0 deletions packages/animelist-auth-next/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use client';

export { SessionProvider, useSession } from "./client/session";
7 changes: 5 additions & 2 deletions scripts/entrypoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,20 @@ function writeFileSync(filePath: string, contents: string) {
fse.writeFileSync(filePath, contents)
}

export function generateEntrypoints(packageDir: string) {
export function generateEntrypoints(packageDir: string, additionalInputs?: string[]) {
const srcDir = path.resolve(packageDir, 'src');

if (!fse.existsSync(srcDir)) {
throw new Error(`'src' directory does not exist on ${srcDir}`);
}

cleanUpEntrypoints(packageDir);

const additionalFiles = (additionalInputs || []).map(file => path.resolve(packageDir, file));

const indexFiles = [
...glob.sync(`${srcDir}/**/index.ts`),
...glob.sync(`${srcDir}/**/index.tsx`)
...additionalFiles
];

for (const indexFile of indexFiles) {
Expand Down

0 comments on commit c8efff8

Please sign in to comment.