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

fix: .d.ts type error #83

Open
wants to merge 1 commit 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
5 changes: 2 additions & 3 deletions packages/trpc-panel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@
"description": "UI for testing tRPC backends",
"main": "lib/index.js",
"module": "lib/index.mjs",
"typings": "lib/src/index.d.ts",
"scripts": {
"test": "jest",
"test:watch": "jest --watchAll",
"build": "npx rollup --bundleConfigAsCjs --config rollup.config.js",
"build": "npx rollup --config rollup.config.mjs",
"dev": "rollup --config rollup.config.js --watch --bundleConfigAsCjs"
},
"author": "",
"license": "ISC",
"exports": {
".": {
"types": "./lib/src/index.d.ts",
"import": "./lib/index.mjs",
"require": "./lib/index.js",
"default": "./lib/index.js"
Expand Down Expand Up @@ -74,6 +72,7 @@
"react-hotkeys-hook": "^4.0.6",
"rollup": "^3.7.4",
"rollup-plugin-copy": "^3.4.0",
"rollup-plugin-dts": "^5.3.0",
"rollup-plugin-livereload": "^2.0.5",
"rollup-plugin-postcss": "^4.0.2",
"rollup-plugin-serve": "^2.0.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-check
import dts from 'rollup-plugin-dts';
import typescript from "@rollup/plugin-typescript";
import json from "@rollup/plugin-json";
import babel from "@rollup/plugin-babel";
Expand All @@ -7,9 +9,23 @@ import copy from "rollup-plugin-copy";
import replace from "@rollup/plugin-replace";
import terser from "@rollup/plugin-terser";
import postcss from "rollup-plugin-postcss";
import path from "path";
import * as fs from "node:fs";
import * as path from "node:path";
const isWatching = process.env.ROLLUP_WATCH;

/**
* @type {{
* peerDependencies: Record<string, string>;
* dependencies: Record<string, string>;
* exports: { ".": { "import": string, "require": string }}
* }}
*/
const { peerDependencies, dependencies, exports } = JSON.parse(
fs.readFileSync('./package.json', { encoding: 'utf-8' }),
);

const external = [...Object.keys(peerDependencies ?? {}), ...Object.keys(dependencies ?? {})];
/** @type { Array<import('rollup').RollupOptions> } */
export default [
{
input: "src/index.ts",
Expand All @@ -28,6 +44,25 @@ export default [
{ file: "lib/index.mjs", format: "es" },
],
},
{
input: "src/index.ts",
plugins: [
dts({
respectExternal: true,
tsconfig: './tsconfig.json',
compilerOptions: {
// see https://github.com/unjs/unbuild/pull/57/files
preserveSymlinks: false,
skipLibCheck: true,
} ,
}),
],
external,
output: [
{ file: "./lib/index.d.ts" },
{ file: "./lib/index.d.mts" },
],
},
{
input: "src/react-app/index.tsx",
output: {
Expand Down
2 changes: 1 addition & 1 deletion packages/trpc-panel/src/render.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Router } from "@trpc/server";
import fs from "fs";
import * as fs from "node:fs";
import { fileURLToPath } from "node:url";
import { dirname } from "node:path";
import {
Expand Down
4 changes: 4 additions & 0 deletions packages/trpc-panel/tsconfig.buildPanel.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"extends": "./tsconfig.build.json",
"compilerOptions": {
"declaration": false,
"noEmit": true
},
"exclude": [
"src/react-app",
],
Expand Down
18 changes: 17 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@
resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24"
integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==

"@jridgewell/sourcemap-codec@^1.4.10", "@jridgewell/sourcemap-codec@^1.4.13":
"@jridgewell/sourcemap-codec@^1.4.10", "@jridgewell/sourcemap-codec@^1.4.13", "@jridgewell/sourcemap-codec@^1.4.15":
version "1.4.15"
resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz#d7c6e6755c78567a951e04ab52ef0fd26de59f32"
integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==
Expand Down Expand Up @@ -5937,6 +5937,13 @@ magic-string@^0.27.0:
dependencies:
"@jridgewell/sourcemap-codec" "^1.4.13"

magic-string@^0.30.0:
version "0.30.1"
resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.30.1.tgz#ce5cd4b0a81a5d032bd69aab4522299b2166284d"
integrity sha512-mbVKXPmS0z0G4XqFDCTllmDQ6coZzn94aMlb0o/A4HEHJCKcanlDZwYJgwnkmgD3jyWhUgj9VsPrfd972yPffA==
dependencies:
"@jridgewell/sourcemap-codec" "^1.4.15"

make-dir@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f"
Expand Down Expand Up @@ -7676,6 +7683,15 @@ rollup-plugin-copy@^3.4.0:
globby "10.0.1"
is-plain-object "^3.0.0"

rollup-plugin-dts@^5.3.0:
version "5.3.0"
resolved "https://registry.yarnpkg.com/rollup-plugin-dts/-/rollup-plugin-dts-5.3.0.tgz#80a95988002f188e376f6db3b7e2f53679168957"
integrity sha512-8FXp0ZkyZj1iU5klkIJYLjIq/YZSwBoERu33QBDxm/1yw5UU4txrEtcmMkrq+ZiKu3Q4qvPCNqc3ovX6rjqzbQ==
dependencies:
magic-string "^0.30.0"
optionalDependencies:
"@babel/code-frame" "^7.18.6"

rollup-plugin-livereload@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/rollup-plugin-livereload/-/rollup-plugin-livereload-2.0.5.tgz#4747fa292a2cceb0c972c573d71b3d66b4252b37"
Expand Down