Skip to content

Commit

Permalink
chore: use shared chunks (#1116)
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusmarminge authored Jan 3, 2025
1 parent 36b0df6 commit 5d132bb
Show file tree
Hide file tree
Showing 46 changed files with 104 additions and 160 deletions.
5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,5 @@
"typescript": "^5.5.2",
"uploadthing": "workspace:*",
"vitest": "^2.1.8"
},
"pnpm": {
"patchedDependencies": {
"bunchee@6.1.2": "patches/bunchee@6.1.2.patch"
}
}
}
2 changes: 1 addition & 1 deletion packages/expo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"@types/react": "18.3.3",
"@uploadthing/eslint-config": "workspace:*",
"@uploadthing/tsconfig": "workspace:*",
"bunchee": "^6.1.2",
"bunchee": "^6.2.0",
"eslint": "^8.57.0",
"expo-constants": "^15.4.5",
"expo-document-picker": "^12.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/mime-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"devDependencies": {
"@uploadthing/eslint-config": "workspace:*",
"@uploadthing/tsconfig": "workspace:*",
"bunchee": "^6.1.2",
"bunchee": "^6.2.0",
"eslint": "^8.57.0",
"typescript": "^5.5.2"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"@types/react-dom": "18.3.0",
"@uploadthing/eslint-config": "workspace:*",
"@uploadthing/tsconfig": "workspace:*",
"bunchee": "^6.1.2",
"bunchee": "^6.2.0",
"concurrently": "^8.2.2",
"eslint": "^8.57.0",
"next": "14.2.11",
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"@types/react": "18.3.3",
"@uploadthing/eslint-config": "workspace:",
"@uploadthing/tsconfig": "workspace:",
"bunchee": "^6.1.2",
"bunchee": "^6.2.0",
"eslint": "^8.57.0",
"react": "18.3.1",
"solid-js": "^1.8.23",
Expand Down
16 changes: 3 additions & 13 deletions packages/uploadthing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,25 +113,15 @@
"./types": {
"types": "./types/index.d.ts",
"default": "./types/index.js"
},
"./internal/types": {
"import": {
"types": "./internal/types.d.ts",
"default": "./internal/types.js"
},
"require": {
"types": "./internal/types.d.cts",
"default": "./internal/types.cjs"
}
}
},
"files": [
"client",
"dist",
"effect-platform",
"express",
"fastify",
"h3",
"internal",
"next",
"next-legacy",
"remix",
Expand All @@ -144,7 +134,7 @@
},
"scripts": {
"lint": "eslint src test --max-warnings 0",
"build": "echo $NODE_ENV && bunchee --tsconfig tsconfig.build.json",
"build": "bunchee --tsconfig tsconfig.build.json",
"clean": "git clean -xdf client express fastify h3 internal next next-legacy server tw node_modules",
"dev": "wait-on ../shared/dist/index.d.ts && bunchee -w --tsconfig tsconfig.build.json --no-clean",
"prepack": "bun ../../.github/replace-workspace-protocol.ts",
Expand All @@ -166,7 +156,7 @@
"@uploadthing/eslint-config": "workspace:*",
"@uploadthing/tsconfig": "workspace:*",
"body-parser": "^1.20.2",
"bunchee": "^6.1.2",
"bunchee": "^6.2.0",
"eslint": "^8.57.0",
"express": "^4.18.2",
"fastify": "^4.26.1",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions packages/uploadthing/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import {
} from "@uploadthing/shared";

import * as pkgJson from "../package.json";
import type { Deferred } from "./internal/deferred";
import { createDeferred } from "./internal/deferred";
import { uploadFile, uploadFilesInternal } from "./internal/upload.browser";
import { createUTReporter } from "./internal/ut-reporter";
import type { Deferred } from "./_internal/deferred";
import { createDeferred } from "./_internal/deferred";
import { uploadFile, uploadFilesInternal } from "./_internal/upload-browser";
import { createUTReporter } from "./_internal/ut-reporter";
import type {
ClientUploadedFileData,
CreateUploadOptions,
Expand Down
10 changes: 5 additions & 5 deletions packages/uploadthing/src/effect-platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import * as Layer from "effect/Layer";

import type { Json } from "@uploadthing/shared";

import { configProvider } from "./internal/config";
import { AdapterArguments, createRequestHandler } from "./internal/handler";
import type { CreateBuilderOptions } from "./internal/upload-builder";
import { createBuilder } from "./internal/upload-builder";
import { configProvider } from "./_internal/config";
import { AdapterArguments, createRequestHandler } from "./_internal/handler";
import type { CreateBuilderOptions } from "./_internal/upload-builder";
import { createBuilder } from "./_internal/upload-builder";
import type { FileRouter, RouteHandlerConfig } from "./types";

export { UTFiles } from "./internal/types";
export { UTFiles } from "./_internal/types";
export type { FileRouter };

type AdapterArgs = {
Expand Down
10 changes: 5 additions & 5 deletions packages/uploadthing/src/express.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import { Router as ExpressRouter } from "express";

import type { Json } from "@uploadthing/shared";

import { makeAdapterHandler } from "./internal/handler";
import { getPostBody, toWebRequest } from "./internal/to-web-request";
import type { CreateBuilderOptions } from "./internal/upload-builder";
import { createBuilder } from "./internal/upload-builder";
import { makeAdapterHandler } from "./_internal/handler";
import { getPostBody, toWebRequest } from "./_internal/to-web-request";
import type { CreateBuilderOptions } from "./_internal/upload-builder";
import { createBuilder } from "./_internal/upload-builder";
import type { FileRouter, RouteHandlerOptions } from "./types";

export { UTFiles } from "./internal/types";
export { UTFiles } from "./_internal/types";
export type { FileRouter };

type AdapterArgs = {
Expand Down
10 changes: 5 additions & 5 deletions packages/uploadthing/src/fastify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import type { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";

import type { Json } from "@uploadthing/shared";

import { makeAdapterHandler } from "./internal/handler";
import { toWebRequest } from "./internal/to-web-request";
import type { CreateBuilderOptions } from "./internal/upload-builder";
import { createBuilder } from "./internal/upload-builder";
import { makeAdapterHandler } from "./_internal/handler";
import { toWebRequest } from "./_internal/to-web-request";
import type { CreateBuilderOptions } from "./_internal/upload-builder";
import { createBuilder } from "./_internal/upload-builder";
import type { FileRouter, RouteHandlerOptions } from "./types";

export { UTFiles } from "./internal/types";
export { UTFiles } from "./_internal/types";
export type { FileRouter };

type AdapterArgs = {
Expand Down
8 changes: 4 additions & 4 deletions packages/uploadthing/src/h3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { defineEventHandler, toWebRequest } from "h3";

import type { Json } from "@uploadthing/shared";

import { makeAdapterHandler } from "./internal/handler";
import type { CreateBuilderOptions } from "./internal/upload-builder";
import { createBuilder } from "./internal/upload-builder";
import { makeAdapterHandler } from "./_internal/handler";
import type { CreateBuilderOptions } from "./_internal/upload-builder";
import { createBuilder } from "./_internal/upload-builder";
import type { FileRouter, RouteHandlerOptions } from "./types";

export { UTFiles } from "./internal/types";
export { UTFiles } from "./_internal/types";
export type { FileRouter };

type AdapterArgs = {
Expand Down
10 changes: 5 additions & 5 deletions packages/uploadthing/src/next-legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import * as Effect from "effect/Effect";

import type { Json } from "@uploadthing/shared";

import { makeAdapterHandler } from "./internal/handler";
import { toWebRequest } from "./internal/to-web-request";
import type { CreateBuilderOptions } from "./internal/upload-builder";
import { createBuilder } from "./internal/upload-builder";
import { makeAdapterHandler } from "./_internal/handler";
import { toWebRequest } from "./_internal/to-web-request";
import type { CreateBuilderOptions } from "./_internal/upload-builder";
import { createBuilder } from "./_internal/upload-builder";
import type { FileRouter, RouteHandlerOptions } from "./types";

export { UTFiles } from "./internal/types";
export { UTFiles } from "./_internal/types";
export type { FileRouter };

type AdapterArgs = {
Expand Down
8 changes: 4 additions & 4 deletions packages/uploadthing/src/next.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import * as Effect from "effect/Effect";

import type { Json } from "@uploadthing/shared";

import { makeAdapterHandler } from "./internal/handler";
import type { CreateBuilderOptions } from "./internal/upload-builder";
import { createBuilder } from "./internal/upload-builder";
import { makeAdapterHandler } from "./_internal/handler";
import type { CreateBuilderOptions } from "./_internal/upload-builder";
import { createBuilder } from "./_internal/upload-builder";
import type { FileRouter, RouteHandlerOptions } from "./types";

export type { FileRouter };
export { UTFiles } from "./internal/types";
export { UTFiles } from "./_internal/types";

type AdapterArgs = {
req: NextRequest;
Expand Down
8 changes: 4 additions & 4 deletions packages/uploadthing/src/remix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import * as Effect from "effect/Effect";

import type { Json } from "@uploadthing/shared";

import { makeAdapterHandler } from "./internal/handler";
import type { CreateBuilderOptions } from "./internal/upload-builder";
import { createBuilder } from "./internal/upload-builder";
import { makeAdapterHandler } from "./_internal/handler";
import type { CreateBuilderOptions } from "./_internal/upload-builder";
import { createBuilder } from "./_internal/upload-builder";
import type { FileRouter, RouteHandlerOptions } from "./types";

export type { FileRouter };
export { UTFiles } from "./internal/types";
export { UTFiles } from "./_internal/types";

type AdapterArgs = {
req: undefined;
Expand Down
6 changes: 3 additions & 3 deletions packages/uploadthing/src/sdk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import * as S from "effect/Schema";
import type { ACL, FetchEsque, MaybeUrl } from "@uploadthing/shared";
import { parseTimeToSeconds, UploadThingError } from "@uploadthing/shared";

import { ApiUrl, UPLOADTHING_VERSION, UTToken } from "../internal/config";
import { logHttpClientError, logHttpClientResponse } from "../internal/logger";
import { makeRuntime } from "../internal/runtime";
import { ApiUrl, UPLOADTHING_VERSION, UTToken } from "../_internal/config";
import { logHttpClientError, logHttpClientResponse } from "../_internal/logger";
import { makeRuntime } from "../_internal/runtime";
import type {
ACLUpdateOptions,
DeleteFilesOptions,
Expand Down
2 changes: 1 addition & 1 deletion packages/uploadthing/src/sdk/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type {
Time,
} from "@uploadthing/shared";

import type { LogFormat } from "../internal/logger";
import type { LogFormat } from "../_internal/logger";
import type { UploadedFileData } from "../types";

export interface UTApiOptions {
Expand Down
4 changes: 2 additions & 2 deletions packages/uploadthing/src/sdk/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import type {
SerializedUploadThingError,
} from "@uploadthing/shared";

import { IngestUrl, UTToken } from "../internal/config";
import { uploadWithoutProgress } from "../internal/upload.server";
import { IngestUrl, UTToken } from "../_internal/config";
import { uploadWithoutProgress } from "../_internal/upload-server";
import type { UploadedFileData } from "../types";
import type { FileEsque, UrlWithOverrides } from "./types";
import { UTFile } from "./ut-file";
Expand Down
10 changes: 5 additions & 5 deletions packages/uploadthing/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import * as Effect from "effect/Effect";
import type { Json } from "@uploadthing/shared";
import { UploadThingError } from "@uploadthing/shared";

import { makeAdapterHandler } from "./internal/handler";
import { extractRouterConfig as extractEffect } from "./internal/route-config";
import type { CreateBuilderOptions } from "./internal/upload-builder";
import { createBuilder } from "./internal/upload-builder";
import { makeAdapterHandler } from "./_internal/handler";
import { extractRouterConfig as extractEffect } from "./_internal/route-config";
import type { CreateBuilderOptions } from "./_internal/upload-builder";
import { createBuilder } from "./_internal/upload-builder";
import type { FileRouter, RouteHandlerOptions } from "./types";

export { UTFiles } from "./internal/types";
export { UTFiles } from "./_internal/types";
export { UTApi } from "./sdk";
export { UTFile } from "./sdk/ut-file";
export { UploadThingError, type FileRouter };
Expand Down
8 changes: 4 additions & 4 deletions packages/uploadthing/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import type {
MaybePromise,
} from "@uploadthing/shared";

import type { LogFormat } from "./internal/logger";
import type { AnyFileRoute, FileRoute } from "./internal/types";
import type { LogFormat } from "./_internal/logger";
import type { AnyFileRoute, FileRoute } from "./_internal/types";

export * from "./sdk/types";

Expand All @@ -23,8 +23,8 @@ export type {
UploadedFileData,
ClientUploadedFileData,
NewPresignedUrl,
} from "./internal/shared-schemas";
export { UploadThingToken } from "./internal/shared-schemas";
} from "./_internal/shared-schemas";
export { UploadThingToken } from "./_internal/shared-schemas";

export type { FileRoute, AnyFileRoute };
export type FileRouter = Record<string, AnyFileRoute>;
Expand Down
8 changes: 4 additions & 4 deletions packages/uploadthing/test/__test-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import type { StrictRequest } from "msw";
import { http, HttpResponse } from "msw";
import { vi } from "vitest";

import { UPLOADTHING_VERSION } from "../src/internal/config";
import { ParsedToken, UploadThingToken } from "../src/internal/shared-schemas";
import type { ActionType } from "../src/internal/shared-schemas";
import type { UploadPutResult } from "../src/internal/types";
import { UPLOADTHING_VERSION } from "../src/_internal/config";
import { ParsedToken, UploadThingToken } from "../src/_internal/shared-schemas";
import type { ActionType } from "../src/_internal/shared-schemas";
import type { UploadPutResult } from "../src/_internal/types";

export const requestSpy = vi.fn<(url: string, req: RequestInit) => void>();
export const requestsToDomain = (domain: string) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ import { afterEach, beforeEach, describe, expect } from "vitest";

import { UploadThingError } from "@uploadthing/shared";

import { configProvider, IngestUrl, IsDevelopment, UTToken } from "./config";
import { ParsedToken, UploadThingToken } from "./shared-schemas";
import {
configProvider,
IngestUrl,
IsDevelopment,
UTToken,
} from "../src/_internal/config";
import { ParsedToken, UploadThingToken } from "../src/_internal/shared-schemas";

const app1TokenData = {
apiKey: Redacted.make("sk_foo"),
Expand Down
2 changes: 1 addition & 1 deletion packages/uploadthing/test/gen-uploader.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { describe, expectTypeOf, it } from "vitest";
import { z } from "zod";

import { createBuilder } from "../src/_internal/upload-builder";
import { genUploader } from "../src/client";
import { createBuilder } from "../src/internal/upload-builder";
import type { ClientUploadedFileData, FileRouter } from "../src/types";
import { doNotExecute } from "./__test-helpers";

Expand Down
4 changes: 2 additions & 2 deletions packages/uploadthing/test/input.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import * as z from "zod";

import { noop } from "@uploadthing/shared";

import { getParseFn, ParserError } from "../src/internal/parser";
import { createBuilder } from "../src/internal/upload-builder";
import { getParseFn, ParserError } from "../src/_internal/parser";
import { createBuilder } from "../src/_internal/upload-builder";
import type { inferEndpointInput } from "../src/types";

const f = createBuilder<{ req: Request; res: undefined; event: undefined }>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { beforeEach, describe, expect, vi } from "vitest";

import { signPayload } from "@uploadthing/shared";

import { handleJsonLineStream } from "./jsonl";
import { MetadataFetchStreamPart } from "./shared-schemas";
import { handleJsonLineStream } from "../src/_internal/jsonl";
import { MetadataFetchStreamPart } from "../src/_internal/shared-schemas";

const te = new TextEncoder();

Expand Down
2 changes: 1 addition & 1 deletion packages/uploadthing/test/request-handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { z } from "zod";

import { signPayload } from "@uploadthing/shared";

import { UploadedFileData } from "../src/internal/shared-schemas";
import { UploadedFileData } from "../src/_internal/shared-schemas";
import { createRouteHandler, createUploadthing } from "../src/server";
import {
baseHeaders,
Expand Down
6 changes: 3 additions & 3 deletions packages/uploadthing/test/upload-builder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import { expect, expectTypeOf, it } from "vitest";
import { z } from "zod";

import { getParseFn } from "../src/internal/parser";
import { UTFiles } from "../src/internal/types";
import { createBuilder } from "../src/internal/upload-builder";
import { getParseFn } from "../src/_internal/parser";
import { UTFiles } from "../src/_internal/types";
import { createBuilder } from "../src/_internal/upload-builder";

it("typeerrors for invalid input", () => {
const f = createBuilder<{ req: Request; res: undefined; event: undefined }>();
Expand Down
Loading

0 comments on commit 5d132bb

Please sign in to comment.