Improve code-splitting of highlight.js and maplibre-gs libs (#12349)
* Dynamic import anything that touches maplibre-gs Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Dynamic import anything that touches highlight.js Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix types Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix tests Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
79c50db009
commit
4a05de485e
17 changed files with 185 additions and 63 deletions
|
@ -16,7 +16,6 @@ limitations under the License.
|
|||
|
||||
import React, { createRef, SyntheticEvent, MouseEvent } from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
import highlight from "highlight.js";
|
||||
import { MsgType } from "matrix-js-sdk/src/matrix";
|
||||
import { TooltipProvider } from "@vector-im/compound-web";
|
||||
|
||||
|
@ -238,7 +237,9 @@ export default class TextualBody extends React.Component<IBodyProps, IState> {
|
|||
pre.append(document.createElement("span"));
|
||||
}
|
||||
|
||||
private highlightCode(code: HTMLElement): void {
|
||||
private async highlightCode(code: HTMLElement): Promise<void> {
|
||||
const { default: highlight } = await import("highlight.js");
|
||||
|
||||
if (code.textContent && code.textContent.length > MAX_HIGHLIGHT_LENGTH) {
|
||||
console.log(
|
||||
"Code block is bigger than highlight limit (" +
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue