Skip to content
This repository was archived by the owner on Jul 20, 2022. It is now read-only.

Commit 24aa138

Browse files
fix & add type declaration
1 parent 560222e commit 24aa138

File tree

5 files changed

+55
-5
lines changed

5 files changed

+55
-5
lines changed

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,20 @@
77
],
88
"main": "./dist/remix-crash.umd.js",
99
"module": "./dist/remix-crash.es.js",
10+
"types": "./dist/index.d.ts",
1011
"exports": {
1112
".": {
1213
"import": "./dist/remix-crash.es.js",
13-
"require": "./dist/remix-crash.umd.js"
14+
"require": "./dist/remix-crash.umd.js",
15+
"types": "./dist/remix-crash.d.ts"
1416
}
1517
},
1618
"scripts": {
1719
"dev": "vite build --watch",
1820
"build": "tsc && vite build"
1921
},
2022
"devDependencies": {
23+
"@types/babel__core": "^7.1.18",
2124
"@types/node": "^17.0.14",
2225
"@types/react": "^17.0.33",
2326
"@types/react-dom": "^17.0.10",

pnpm-lock.yaml

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ErrorBoundary.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,25 @@ export type SanitizedStacktrace = Array<{
2323
} | null>;
2424

2525
export type ErrorState = {
26+
loading: boolean;
2627
stacktrace: Stacktrace;
2728
sanitizedStacktrace: SanitizedStacktrace;
29+
convertedStacktrace: Array<{
30+
file: string;
31+
sourceContent: string;
32+
line: number;
33+
}>;
34+
selectedIndex: number | null;
35+
setSelectedIndex: (value: number | null) => void;
2836
};
2937

3038
export const defaultErrorState: ErrorState = {
3139
stacktrace: [],
3240
sanitizedStacktrace: [],
41+
loading: true,
42+
convertedStacktrace: [],
43+
setSelectedIndex: () => {},
44+
selectedIndex: null,
3345
};
3446

3547
export const ErrorContext = createContext(defaultErrorState);
@@ -249,7 +261,8 @@ const CodeFrame = () => {
249261
const { convertedStacktrace, selectedIndex } = useError();
250262
// const selectedLine = useRef(null)
251263

252-
const convertedStacktraceLine = convertedStacktrace[selectedIndex];
264+
const convertedStacktraceLine =
265+
selectedIndex !== null ? convertedStacktrace[selectedIndex] : null;
253266

254267
useLayoutEffect(() => {
255268
document.querySelector(".selected")?.scrollIntoView({ block: "center" });

tsconfig.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
"moduleResolution": "Node",
1414
"resolveJsonModule": true,
1515
"isolatedModules": true,
16-
"noEmit": true,
17-
"jsx": "react-jsx"
16+
"jsx": "react-jsx",
17+
"declaration": true,
18+
"outDir": "dist",
19+
"emitDeclarationOnly": true
1820
},
19-
"include": ["./src", "vite.config.ts"]
21+
"include": ["./src/index.ts", "./src/vite-env.d.ts"]
2022
}

vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import path from "path";
66
export default defineConfig({
77
plugins: [react()],
88
build: {
9+
emptyOutDir: false,
910
lib: {
1011
entry: path.resolve(__dirname, "src/index.ts"),
1112
name: "RemixCrash",

0 commit comments

Comments
 (0)