|
|
@@ -98,8 +98,36 @@ export default defineConfig(({ mode }) => {
|
|
|
rollupOptions: {
|
|
|
output: {
|
|
|
entryFileNames: `assets/[name].js`,
|
|
|
- chunkFileNames: `assets/[name].js`,
|
|
|
+ chunkFileNames: (chunkInfo) => {
|
|
|
+ if (chunkInfo.name === "mermaid-bundle") {
|
|
|
+ return `assets/mermaid-bundle.js`
|
|
|
+ }
|
|
|
+ // Default naming for other chunks, ensuring uniqueness from entry
|
|
|
+ return `assets/chunk-[hash].js`
|
|
|
+ },
|
|
|
assetFileNames: `assets/[name].[ext]`,
|
|
|
+ manualChunks: (id, { getModuleInfo }) => {
|
|
|
+ // Consolidate all mermaid code and its direct large dependencies (like dagre)
|
|
|
+ // into a single chunk. The 'channel.js' error often points to dagre.
|
|
|
+ if (
|
|
|
+ id.includes("node_modules/mermaid") ||
|
|
|
+ id.includes("node_modules/dagre") || // dagre is a common dep for graph layout
|
|
|
+ id.includes("node_modules/cytoscape") // another potential graph lib
|
|
|
+ // Add other known large mermaid dependencies if identified
|
|
|
+ ) {
|
|
|
+ return "mermaid-bundle"
|
|
|
+ }
|
|
|
+
|
|
|
+ // Check if the module is part of any explicitly defined mermaid-related dynamic import
|
|
|
+ // This is a more advanced check if simple path matching isn't enough.
|
|
|
+ const moduleInfo = getModuleInfo(id)
|
|
|
+ if (moduleInfo?.importers.some((importer) => importer.includes("node_modules/mermaid"))) {
|
|
|
+ return "mermaid-bundle"
|
|
|
+ }
|
|
|
+ if (moduleInfo?.dynamicImporters.some((importer) => importer.includes("node_modules/mermaid"))) {
|
|
|
+ return "mermaid-bundle"
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
},
|
|
|
},
|
|
|
@@ -116,6 +144,11 @@ export default defineConfig(({ mode }) => {
|
|
|
},
|
|
|
define,
|
|
|
optimizeDeps: {
|
|
|
+ include: [
|
|
|
+ "mermaid",
|
|
|
+ "dagre", // Explicitly include dagre for pre-bundling
|
|
|
+ // Add other known large mermaid dependencies if identified
|
|
|
+ ],
|
|
|
exclude: ["@vscode/codicons", "vscode-oniguruma", "shiki"],
|
|
|
},
|
|
|
assetsInclude: ["**/*.wasm", "**/*.wav"],
|