From f80d9fa0ee8d420a9d5947f20a1a6c3bc7482d10 Mon Sep 17 00:00:00 2001 From: Stan Wohlwend Date: Mon, 8 Apr 2024 06:59:33 +0200 Subject: [PATCH] Fix #5 --- examples/web-demo/package-lock.json | 3 ++- examples/web-demo/src/app/layout.tsx | 2 ++ examples/web-demo/src/app/polyfills-on-client.tsx | 8 ++++++++ examples/web-demo/src/polyfills.tsx | 12 ++++++++++++ 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 examples/web-demo/src/app/polyfills-on-client.tsx create mode 100644 examples/web-demo/src/polyfills.tsx diff --git a/examples/web-demo/package-lock.json b/examples/web-demo/package-lock.json index f8189bf..01cd465 100644 --- a/examples/web-demo/package-lock.json +++ b/examples/web-demo/package-lock.json @@ -29,10 +29,11 @@ } }, "../..": { - "version": "1.0.0", + "version": "1.0.2", "license": "MIT", "devDependencies": { "@types/node": "^20.12.2", + "rimraf": "^5.0.5", "tsup": "^8.0.2", "typescript": "^5.4.3" } diff --git a/examples/web-demo/src/app/layout.tsx b/examples/web-demo/src/app/layout.tsx index 1126373..9e6cdce 100644 --- a/examples/web-demo/src/app/layout.tsx +++ b/examples/web-demo/src/app/layout.tsx @@ -1,5 +1,6 @@ import type { Metadata } from "next"; import { Inter } from "next/font/google"; +import { PolyfillsOnClient } from "./polyfills-on-client"; const inter = Inter({ subsets: ["latin"] }); @@ -14,6 +15,7 @@ export default function RootLayout({ }>) { return ( + {children} ); diff --git a/examples/web-demo/src/app/polyfills-on-client.tsx b/examples/web-demo/src/app/polyfills-on-client.tsx new file mode 100644 index 0000000..3c048d0 --- /dev/null +++ b/examples/web-demo/src/app/polyfills-on-client.tsx @@ -0,0 +1,8 @@ +"use client"; + +import { applyPolyfills } from "@/polyfills"; +applyPolyfills(); + +export function PolyfillsOnClient() { + return <>; +} diff --git a/examples/web-demo/src/polyfills.tsx b/examples/web-demo/src/polyfills.tsx new file mode 100644 index 0000000..d38716d --- /dev/null +++ b/examples/web-demo/src/polyfills.tsx @@ -0,0 +1,12 @@ +export function applyPolyfills() { + console.log("Applying polyfills..."); + + /** + * The `node-postgres` module uses `Error.captureStackTrace`, which isn't supported on all modules. This is a polyfill for that. + * + * constructorOpt is not supported by this polyfill. + */ + Error.captureStackTrace ||= (error: Error, constructorOpt?: any) => { + error.stack = new Error().stack; + }; +}