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.
This commit is contained in:
AdingApkgg
2026-03-31 00:04:57 +08:00
parent 048560fd0a
commit d4498e2f46

View File

@@ -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,
}
}