From a0d651d64dfd766157324fd86791da2168028cf2 Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Sun, 06 Aug 2023 00:53:29 +0000
Subject: [PATCH] reverse query param hack to re-add sourcemap support

---
 quartz/build.ts |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/quartz/build.ts b/quartz/build.ts
index b395f73..9f38882 100644
--- a/quartz/build.ts
+++ b/quartz/build.ts
@@ -1,4 +1,19 @@
-import "source-map-support/register.js"
+import sourceMapSupport from "source-map-support"
+sourceMapSupport.install({
+  retrieveSourceMap(source) {
+    // source map hack to get around query param
+    // import cache busting
+    if (source.includes(".quartz-cache")) {
+      let realSource = fileURLToPath(source.split("?", 2)[0] + '.map')
+      return {
+        map: fs.readFileSync(realSource, 'utf8')
+      }
+    } else {
+      return null
+    }
+  }
+})
+
 import path from "path"
 import { PerfTimer } from "./perf"
 import { rimraf } from "rimraf"
@@ -14,6 +29,8 @@
 import { Argv, BuildCtx } from "./ctx"
 import { glob, toPosixPath } from "./glob"
 import { trace } from "./trace"
+import { fileURLToPath } from "url"
+import fs from "fs"
 
 async function buildQuartz(argv: Argv, clientRefresh: () => void) {
   const ctx: BuildCtx = {

--
Gitblit v1.10.0