Skip to content

Commit

Permalink
feat(md-enhance): hide eval warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed Nov 1, 2022
1 parent 2243ae4 commit 6f478a1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/md-enhance/package.json
Expand Up @@ -81,6 +81,7 @@
"devDependencies": {
"@types/babel__core": "7.1.19",
"@vuepress/core": "2.0.0-beta.53",
"@vuepress/bundler-vite": "2.0.0-beta.53",
"@vuepress/markdown": "2.0.0-beta.53",
"markdown-it-container": "3.0.0",
"rimraf": "3.0.2",
Expand Down
27 changes: 27 additions & 0 deletions packages/md-enhance/src/node/plugin.ts
Expand Up @@ -8,6 +8,7 @@ import {
chainWebpack,
deepAssign,
getLocales,
mergeViteConfig,
} from "vuepress-shared/node";

import { logger } from "./utils.js";
Expand Down Expand Up @@ -59,6 +60,8 @@ import { prepareConfigFile, prepareRevealPluginFile } from "./prepare.js";
import { MATHML_TAGS } from "./utils.js";

import type { PluginFunction } from "@vuepress/core";
import type { ViteBundlerOptions } from "@vuepress/bundler-vite";
import type { RollupWarning } from "rollup";
import type { KatexOptions } from "katex";
import type { MarkdownEnhanceOptions } from "../shared/index.js";

Expand Down Expand Up @@ -154,6 +157,30 @@ export const mdEnhancePlugin =
}),

extendsBundlerOptions: (config: unknown, app): void => {
const { bundler } = app.options;

if (bundler.name.endsWith("vite")) {
const bundlerConfig = <ViteBundlerOptions>config;

bundlerConfig.viteOptions = mergeViteConfig(
bundlerConfig.viteOptions || {},
{
build: {
rollupOptions: {
onwarn(
warning: RollupWarning,
warn: (warning: RollupWarning) => void
) {
if (warning.message.includes("Use of eval")) return;

warn(warning);
},
},
},
}
);
}

addViteSsrNoExternal({ app, config }, "vuepress-shared");

if (katexEnable && katexOptions.output !== "html")
Expand Down
5 changes: 4 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6f478a1

Please sign in to comment.