mirror of
https://github.com/better-auth/better-auth.git
synced 2026-10-19 11:24:57 -05:00
e2e: add vite client build (#4643)
This commit is contained in:
+13
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "vite",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "vite build"
|
||||
},
|
||||
"dependencies": {
|
||||
"better-auth": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"vite": "^7.1.5"
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
/// <reference types="vite/client" />
|
||||
export * from "better-auth/client/plugins";
|
||||
import { createAuthClient } from "better-auth/client";
|
||||
|
||||
export const authClient = createAuthClient({
|
||||
baseURL: import.meta.env.VITE_BASE_URL || "http://localhost:3000",
|
||||
plugins: [],
|
||||
});
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "esnext",
|
||||
"module": "esnext",
|
||||
"moduleResolution": "bundler",
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"skipLibCheck": true
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import { defineConfig } from "vite";
|
||||
import { resolve } from "node:path";
|
||||
|
||||
export default defineConfig({
|
||||
build: {
|
||||
rollupOptions: {
|
||||
input: {
|
||||
client: resolve(__dirname, "src", "client.ts"),
|
||||
},
|
||||
output: {
|
||||
entryFileNames: "[name].js",
|
||||
format: "es",
|
||||
},
|
||||
treeshake: false,
|
||||
},
|
||||
minify: false,
|
||||
sourcemap: "inline",
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,52 @@
|
||||
import { describe, it } from "node:test";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { join } from "node:path";
|
||||
import { spawn } from "node:child_process";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import * as assert from "node:assert";
|
||||
|
||||
const fixturesDir = fileURLToPath(new URL("./fixtures", import.meta.url));
|
||||
|
||||
describe("(vite) client build", () => {
|
||||
it("builds client without better-call imports", async () => {
|
||||
const viteDir = join(fixturesDir, "vite");
|
||||
|
||||
// Run vite build
|
||||
const buildProcess = spawn("npx", ["vite", "build"], {
|
||||
cwd: viteDir,
|
||||
stdio: "pipe",
|
||||
});
|
||||
|
||||
// Wait for build to complete
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
buildProcess.on("close", (code) => {
|
||||
if (code === 0) {
|
||||
resolve();
|
||||
} else {
|
||||
reject(new Error(`Vite build failed with code ${code}`));
|
||||
}
|
||||
});
|
||||
|
||||
buildProcess.on("error", (error) => {
|
||||
reject(error);
|
||||
});
|
||||
|
||||
// Log build output for debugging
|
||||
buildProcess.stdout.on("data", (data) => {
|
||||
console.log(data.toString());
|
||||
});
|
||||
|
||||
buildProcess.stderr.on("data", (data) => {
|
||||
console.error(data.toString());
|
||||
});
|
||||
});
|
||||
|
||||
const clientFile = join(viteDir, "dist", "client.js");
|
||||
const clientContent = await readFile(clientFile, "utf-8");
|
||||
|
||||
assert.ok(
|
||||
!clientContent.includes("createEndpoint"),
|
||||
"Built output should not contain 'better-call' imports",
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -8,5 +8,6 @@
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"moduleResolution": "node16"
|
||||
}
|
||||
},
|
||||
"include": ["./test/**/*"]
|
||||
}
|
||||
|
||||
Generated
+10
-2
@@ -644,6 +644,16 @@ importers:
|
||||
specifier: 4.33.2
|
||||
version: 4.33.2(@cloudflare/workers-types@4.20250903.0)
|
||||
|
||||
e2e/smoke/test/fixtures/vite:
|
||||
dependencies:
|
||||
better-auth:
|
||||
specifier: workspace:*
|
||||
version: link:../../../../../packages/better-auth
|
||||
devDependencies:
|
||||
vite:
|
||||
specifier: ^7.1.5
|
||||
version: 7.1.5(@types/node@24.4.0)(jiti@2.6.0)(less@4.4.1)(lightningcss@1.30.1)(sass@1.90.0)(terser@5.44.0)(tsx@4.20.5)(yaml@2.8.1)
|
||||
|
||||
packages/better-auth:
|
||||
dependencies:
|
||||
'@better-auth/utils':
|
||||
@@ -15971,9 +15981,7 @@ snapshots:
|
||||
metro-runtime: 0.83.1
|
||||
transitivePeerDependencies:
|
||||
- '@babel/core'
|
||||
- bufferutil
|
||||
- supports-color
|
||||
- utf-8-validate
|
||||
optional: true
|
||||
|
||||
'@react-native/normalize-colors@0.79.6': {}
|
||||
|
||||
Reference in New Issue
Block a user