From d4498e2f46079c6c2a5464d72b6658ebb155b79f Mon Sep 17 00:00:00 2001 From: AdingApkgg Date: Tue, 31 Mar 2026 00:04:57 +0800 Subject: [PATCH] refactor: update PrismJS plugin in Vite configuration to use ESM import - Renamed the PrismJS plugin to 'prismjs-esm-fix' for clarity. - Modified the code transformation to use ESM import for 'prism-core', enhancing compatibility with modern module systems. --- vite.config.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index 223e2e6..fb5ba89 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -20,11 +20,11 @@ export default defineConfig({ plugins: [ { - name: 'prismjs-global-fix', + name: 'prismjs-esm-fix', transform(code, id) { if (id.includes('prismjs/components/') && !id.includes('prism-core')) { return { - code: `var Prism = (typeof window !== 'undefined' ? window : globalThis).Prism;\n${code}`, + code: `import Prism from 'prismjs/components/prism-core';\n${code}`, map: null, } }