Use module build of markmap-lib

If we use the default import then webpack will use the "browser"
bundle which relies on CDN lazy loading of dependencies.

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2021-04-15 22:04:04 +02:00
parent 64fe7233e7
commit bfcb617eeb
4 changed files with 17 additions and 25 deletions

View file

@ -176,6 +176,7 @@
"webpack-bundle-analyzer": "4.4.1" "webpack-bundle-analyzer": "4.4.1"
}, },
"resolutions": { "resolutions": {
"cypress": "7.1.0" "cypress": "7.1.0",
"katex": "0.13.2"
} }
} }

View file

@ -1,26 +1,15 @@
/* /*
SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file) * SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
*
SPDX-License-Identifier: AGPL-3.0-only * SPDX-License-Identifier: AGPL-3.0-only
*/ */
import { loadCSS, loadJS } from 'markmap-common' import { Transformer } from 'markmap-lib/dist/index.esm'
import { Transformer } from 'markmap-lib'
import { Markmap } from 'markmap-view' import { Markmap } from 'markmap-view'
const transformer: Transformer = new Transformer() const transformer: Transformer = new Transformer()
export const markmapLoader = (svg: SVGSVGElement, code: string): void => { export const markmapLoader = (svg: SVGSVGElement, code: string): void => {
const { root, features } = transformer.transform(code) const { root } = transformer.transform(code)
const { styles, scripts } = transformer.getUsedAssets(features)
if (styles) {
loadCSS(styles)
}
if (scripts) {
loadJS(scripts)
.catch(console.log)
}
Markmap.create(svg, {}, root) Markmap.create(svg, {}, root)
} }

View file

@ -0,0 +1,9 @@
/*
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
declare module 'markmap-lib/dist/index.esm' {
export * from 'markmap-lib'
}

View file

@ -9053,20 +9053,13 @@ jsprim@^1.2.2:
array-includes "^3.1.2" array-includes "^3.1.2"
object.assign "^4.1.2" object.assign "^4.1.2"
katex@0.13.2: katex@0.13.2, katex@^0.12.0:
version "0.13.2" version "0.13.2"
resolved "https://registry.yarnpkg.com/katex/-/katex-0.13.2.tgz#4075b9144e6af992ec9a4b772fa3754763be5f26" resolved "https://registry.yarnpkg.com/katex/-/katex-0.13.2.tgz#4075b9144e6af992ec9a4b772fa3754763be5f26"
integrity sha512-u/KhjFDhyPr+70aiBn9SL/9w/QlLagIXBi2NZSbNnBUp2tR8dCjQplyEMkEzniem5gOeSCBjlBUg4VaiWs1JJg== integrity sha512-u/KhjFDhyPr+70aiBn9SL/9w/QlLagIXBi2NZSbNnBUp2tR8dCjQplyEMkEzniem5gOeSCBjlBUg4VaiWs1JJg==
dependencies: dependencies:
commander "^6.0.0" commander "^6.0.0"
katex@^0.12.0:
version "0.12.0"
resolved "https://registry.yarnpkg.com/katex/-/katex-0.12.0.tgz#2fb1c665dbd2b043edcf8a1f5c555f46beaa0cb9"
integrity sha512-y+8btoc/CK70XqcHqjxiGWBOeIL8upbS0peTPXTvgrh21n1RiWWcIpSWM+4uXq+IAgNh9YYQWdc7LVDPDAEEAg==
dependencies:
commander "^2.19.0"
khroma@^1.1.0: khroma@^1.1.0:
version "1.3.0" version "1.3.0"
resolved "https://registry.yarnpkg.com/khroma/-/khroma-1.3.0.tgz#1a0238ffcce1b049b8c733d5b07850a379aca04a" resolved "https://registry.yarnpkg.com/khroma/-/khroma-1.3.0.tgz#1a0238ffcce1b049b8c733d5b07850a379aca04a"