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

chore(perf): use dts files for trpc #225

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion apps/expo/metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ if (config.resolver) {
config.resolver.disableHierarchicalLookup = true;
}

// @ts-expect-error - FIXME: type is mismatching?
module.exports = withNativeWind(config, {
input: "./src/styles.css",
configPath: "./tailwind.config.ts",
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/next.config.mjs → apps/nextjs/next.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import "./src/env.mjs";
import "./src/env.js";
import "@acme/api/env";
import "@acme/stripe/env";

Expand Down
1 change: 1 addition & 0 deletions apps/nextjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@acme/nextjs",
"version": "0.1.0",
"type": "module",
"private": true,
"scripts": {
"build": "pnpm with-env next build",
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/src/app/api/webhooks/stripe/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { NextRequest } from "next/server";

import { handleEvent, stripe } from "@acme/stripe";

import { env } from "~/env.mjs";
import { env } from "~/env";

export async function POST(req: NextRequest) {
const payload = await req.text();
Expand Down
File renamed without changes.
51 changes: 38 additions & 13 deletions packages/api/package.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,53 @@
{
"name": "@acme/api",
"private": true,
"type": "module",
"version": "0.1.0",
"exports": {
".": "./src/index.ts",
"./env": "./src/env.mjs",
"./edge": "./src/edge.ts",
"./lambda": "./src/lambda.ts",
"./transformer": "./src/transformer.ts",
"./validators": "./src/validators.ts"
},
"typesVersions": {
"*": {
"*": [
"src/*"
]
".": {
"import": {
"types": "./dist/index.d.ts",
"default": "./src/index.ts"
}
},
"./env": {
"import": {
"types": "./dist/env.d.ts",
"default": "./src/env.js"
}
},
"./edge": {
"import": {
"types": "./dist/edge.d.ts",
"default": "./src/edge.ts"
}
},
"./lambda": {
"import": {
"types": "./dist/lambda.d.ts",
"default": "./src/lambda.ts"
}
},
"./transformer": {
"import": {
"types": "./dist/transformer.d.ts",
"default": "./src/transformer.ts"
}
},
"./validators": {
"import": {
"types": "./dist/validators.d.ts",
"default": "./src/validators.ts"
}
}
},
"license": "MIT",
"scripts": {
"dev": "tsc --watch",
"clean": "rm -rf .turbo node_modules",
"lint": "eslint .",
"format": "prettier --check \"**/*.{mjs,ts,json}\"",
"typecheck": "tsc --noEmit"
"typecheck": "tsc --noEmit --emitDeclarationOnly false"
},
"dependencies": {
"@acme/db": "^0.1.0",
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/api/src/router/stripe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as z from "zod";

import { PLANS, stripe } from "@acme/stripe";

import { env } from "../env.mjs";
import { env } from "../env";
import { createTRPCRouter, protectedProcedure, publicProcedure } from "../trpc";
import { purchaseOrgSchema } from "../validators";

Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/transformer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { dinero } from "dinero.js";
import type { Dinero, DineroSnapshot } from "dinero.js";
import superjson from "superjson";
import type { JSONValue } from "superjson/dist/types";

/**
* TODO: Maybe put this in a shared package that can be safely shared between `api`, `nextjs` and `expo` packages
Expand All @@ -18,7 +17,8 @@ superjson.registerCustom(
}
},
serialize: (val) => {
return val.toJSON() as JSONValue;
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-explicit-any
return val.toJSON() as any;
},
deserialize: (val) => {
return dinero(val as DineroSnapshot<number>);
Expand Down
4 changes: 4 additions & 0 deletions packages/api/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
"extends": "@acme/tsconfig/base.json",
"compilerOptions": {
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json",
"noEmit": false,
"emitDeclarationOnly": true,
"declaration": true,
"declarationDir": "dist",
},
"include": ["src"],
"exclude": ["node_modules"],
Expand Down
7 changes: 0 additions & 7 deletions packages/stripe/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@
"./plans": "./src/plans.ts",
"./env": "./src/env.mjs"
},
"typesVersions": {
"*": {
"*": [
"src/*"
]
}
},
"license": "MIT",
"scripts": {
"clean": "rm -rf .turbo node_modules",
Expand Down
7 changes: 0 additions & 7 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,5 @@
"./tabs": "./src/tabs.tsx",
"./toaster": "./src/toaster.tsx",
"./use-toast": "./src/use-toast.tsx"
},
"typesVersions": {
"*": {
"*": [
"src/*"
]
}
}
}
11 changes: 6 additions & 5 deletions tooling/typescript/base.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"target": "ES2017",
"lib": ["dom", "dom.iterable", "esnext"],
"target": "ES2022",
"lib": ["dom", "dom.iterable", "ES2022"],
"allowJs": true,
"checkJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"moduleResolution": "Bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"moduleDetection": "force",
"jsx": "preserve",
"incremental": true,
"noUncheckedIndexedAccess": true
"noUncheckedIndexedAccess": true,
"disableSourceOfProjectReferenceRedirect": true
},
"exclude": ["node_modules", "build", "dist", ".next", ".expo"]
}
7 changes: 0 additions & 7 deletions turbo/generators/templates/package.json.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@
"exports": {
".": "./index.ts"
},
"typesVersions": {
"*": {
"*": [
"src/*"
]
}
}
"license": "MIT",
"scripts": {
"clean": "rm -rf .turbo node_modules",
Expand Down