mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-22 03:26:22 +00:00
reverse query param hack to re-add sourcemap support
This commit is contained in:
parent
1da467d214
commit
a0d651d64d
4 changed files with 33 additions and 3 deletions
10
package-lock.json
generated
10
package-lock.json
generated
|
@ -73,6 +73,7 @@
|
||||||
"@types/node": "^20.1.2",
|
"@types/node": "^20.1.2",
|
||||||
"@types/pretty-time": "^1.1.2",
|
"@types/pretty-time": "^1.1.2",
|
||||||
"@types/serve-handler": "^6.1.1",
|
"@types/serve-handler": "^6.1.1",
|
||||||
|
"@types/source-map-support": "^0.5.6",
|
||||||
"@types/workerpool": "^6.4.0",
|
"@types/workerpool": "^6.4.0",
|
||||||
"@types/ws": "^8.5.5",
|
"@types/ws": "^8.5.5",
|
||||||
"@types/yargs": "^17.0.24",
|
"@types/yargs": "^17.0.24",
|
||||||
|
@ -1486,6 +1487,15 @@
|
||||||
"@types/node": "*"
|
"@types/node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/source-map-support": {
|
||||||
|
"version": "0.5.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/source-map-support/-/source-map-support-0.5.6.tgz",
|
||||||
|
"integrity": "sha512-b2nJ9YyXmkhGaa2b8VLM0kJ04xxwNyijcq12/kDoomCt43qbHBeK2SLNJ9iJmETaAj+bKUT05PQUu3Q66GvLhQ==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"source-map": "^0.6.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@types/unist": {
|
"node_modules/@types/unist": {
|
||||||
"version": "2.0.6",
|
"version": "2.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.6.tgz",
|
||||||
|
|
|
@ -89,6 +89,7 @@
|
||||||
"@types/node": "^20.1.2",
|
"@types/node": "^20.1.2",
|
||||||
"@types/pretty-time": "^1.1.2",
|
"@types/pretty-time": "^1.1.2",
|
||||||
"@types/serve-handler": "^6.1.1",
|
"@types/serve-handler": "^6.1.1",
|
||||||
|
"@types/source-map-support": "^0.5.6",
|
||||||
"@types/workerpool": "^6.4.0",
|
"@types/workerpool": "^6.4.0",
|
||||||
"@types/ws": "^8.5.5",
|
"@types/ws": "^8.5.5",
|
||||||
"@types/yargs": "^17.0.24",
|
"@types/yargs": "^17.0.24",
|
||||||
|
|
|
@ -298,14 +298,15 @@ See the [documentation](https://quartz.jzhao.xyz) for how to get started.
|
||||||
outfile: path.join("quartz", cacheFile),
|
outfile: path.join("quartz", cacheFile),
|
||||||
bundle: true,
|
bundle: true,
|
||||||
keepNames: true,
|
keepNames: true,
|
||||||
minify: true,
|
minifyWhitespace: true,
|
||||||
|
minifySyntax: true,
|
||||||
platform: "node",
|
platform: "node",
|
||||||
format: "esm",
|
format: "esm",
|
||||||
jsx: "automatic",
|
jsx: "automatic",
|
||||||
jsxImportSource: "preact",
|
jsxImportSource: "preact",
|
||||||
packages: "external",
|
packages: "external",
|
||||||
metafile: true,
|
metafile: true,
|
||||||
sourcemap: "inline",
|
sourcemap: true,
|
||||||
sourcesContent: false,
|
sourcesContent: false,
|
||||||
plugins: [
|
plugins: [
|
||||||
sassPlugin({
|
sassPlugin({
|
||||||
|
@ -374,6 +375,7 @@ See the [documentation](https://quartz.jzhao.xyz) for how to get started.
|
||||||
}
|
}
|
||||||
|
|
||||||
// bypass module cache
|
// bypass module cache
|
||||||
|
// https://github.com/nodejs/modules/issues/307
|
||||||
const { default: buildQuartz } = await import(cacheFile + `?update=${randomUUID()}`)
|
const { default: buildQuartz } = await import(cacheFile + `?update=${randomUUID()}`)
|
||||||
await buildQuartz(argv, clientRefresh)
|
await buildQuartz(argv, clientRefresh)
|
||||||
clientRefresh()
|
clientRefresh()
|
||||||
|
|
|
@ -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 path from "path"
|
||||||
import { PerfTimer } from "./perf"
|
import { PerfTimer } from "./perf"
|
||||||
import { rimraf } from "rimraf"
|
import { rimraf } from "rimraf"
|
||||||
|
@ -14,6 +29,8 @@ import { ProcessedContent } from "./plugins/vfile"
|
||||||
import { Argv, BuildCtx } from "./ctx"
|
import { Argv, BuildCtx } from "./ctx"
|
||||||
import { glob, toPosixPath } from "./glob"
|
import { glob, toPosixPath } from "./glob"
|
||||||
import { trace } from "./trace"
|
import { trace } from "./trace"
|
||||||
|
import { fileURLToPath } from "url"
|
||||||
|
import fs from "fs"
|
||||||
|
|
||||||
async function buildQuartz(argv: Argv, clientRefresh: () => void) {
|
async function buildQuartz(argv: Argv, clientRefresh: () => void) {
|
||||||
const ctx: BuildCtx = {
|
const ctx: BuildCtx = {
|
||||||
|
|
Loading…
Reference in a new issue