docs: use local wasm file

This commit is contained in:
Justineo
2024-07-24 11:37:03 +08:00
committed by GU Yiling
parent 6b98318504
commit 24ed18e439
3 changed files with 11 additions and 4 deletions

View File

@ -64,7 +64,7 @@
"echarts": "^5.5.1", "echarts": "^5.5.1",
"echarts-gl": "^2.0.9", "echarts-gl": "^2.0.9",
"echarts-liquidfill": "^3.1.0", "echarts-liquidfill": "^3.1.0",
"esbuild-wasm": "^0.19.12", "esbuild-wasm": "^0.23.0",
"eslint": "^7.32.0", "eslint": "^7.32.0",
"eslint-plugin-prettier": "^3.4.1", "eslint-plugin-prettier": "^3.4.1",
"eslint-plugin-vue": "^8.7.1", "eslint-plugin-vue": "^8.7.1",

View File

@ -16,6 +16,7 @@ import javascript from "highlight.js/lib/languages/javascript";
import typescript from "highlight.js/lib/languages/typescript"; import typescript from "highlight.js/lib/languages/typescript";
import hljsVuePlugin from "@highlightjs/vue-plugin"; import hljsVuePlugin from "@highlightjs/vue-plugin";
import { initialize, transform } from "esbuild-wasm"; import { initialize, transform } from "esbuild-wasm";
import wasmURL from "esbuild-wasm/esbuild.wasm";
import { track } from "@vercel/analytics"; import { track } from "@vercel/analytics";
import { getImportsFromOption } from "./utils/codegen"; import { getImportsFromOption } from "./utils/codegen";
@ -75,9 +76,7 @@ const transformedCode = ref("");
const transformErrors = ref([]); const transformErrors = ref([]);
onMounted(async () => { onMounted(async () => {
await initialize({ await initialize({ wasmURL });
wasmURL: "https://cdn.jsdelivr.net/npm/esbuild-wasm@0.19.12/esbuild.wasm"
});
initializing.value = false; initializing.value = false;

View File

@ -20,6 +20,14 @@ export default {
.test(/\.svg$/) .test(/\.svg$/)
.type("asset/source"); .type("asset/source");
config.module
.rule('wasm')
.test(/\.wasm$/)
.type('asset/resource')
.set('generator', {
filename: '[name].[hash:8][ext]'
})
config.plugin("define").tap(([options]) => [ config.plugin("define").tap(([options]) => [
{ {
...options, ...options,