Skip to content

Commit 58f3c96

Browse files
committed
chore: improve bundle chunking
1 parent 29b0e39 commit 58f3c96

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

packages/devtools/client/composables/client-services/markdown.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type MarkdownIt from 'markdown-it'
22

3-
const md = ref<MarkdownIt>()
3+
const md = shallowRef<MarkdownIt>()
44

55
let promise: Promise<void> | undefined
66

packages/devtools/client/nuxt.config.ts

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@ import DevTools from '../src/module'
44

55
const resolver = createResolver(import.meta.url)
66

7-
const packageBundles = [
8-
'quicktype-core',
9-
'shiki',
10-
]
7+
const packageBundles = {
8+
'shiki': ['shiki', '@shikijs'],
9+
'quicktype-core': ['quicktype-core'],
10+
'json-editor-vue': ['json-editor-vue', 'ajv', 'vanilla-picker', 'vanilla-jsoneditor'],
11+
'xterm': ['xterm', '@xterm'],
12+
'vis': ['vis-data', 'vis-network'],
13+
'unocss': ['@unocss', 'unocss'],
14+
'markdown-it': ['markdown-it'],
15+
}
1116

1217
export default defineNuxtConfig({
1318
modules: [
@@ -84,18 +89,21 @@ export default defineNuxtConfig({
8489
target: 'esnext',
8590
rollupOptions: {
8691
output: {
92+
chunkFileNames(chunkInfo) {
93+
const kebabName = chunkInfo.name.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase()
94+
return `_nuxt/${kebabName}-[hash].js`
95+
},
96+
assetFileNames(assetInfo) {
97+
const kebabName = (assetInfo.name || '').replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase()
98+
return `_nuxt/${kebabName}-[hash][extname]`
99+
},
87100
manualChunks(id) {
88-
const pkg = packageBundles.find(pkg => id.includes(`node_modules/${pkg}`))
89-
if (pkg) {
90-
return pkg
101+
for (const bundle of Object.entries(packageBundles)) {
102+
if (bundle[1].some(pkg => id.includes(`node_modules/${pkg}/`)))
103+
return `vendor/${bundle[0]}`
91104
}
92-
93-
// if (id.includes('.nuxt/routes'))
94-
// return 'routes'
95-
96-
// if (id.includes('.nuxt'))
97-
// console.log(id)
98105
},
106+
hashCharacters: 'base36',
99107
},
100108
},
101109
},

0 commit comments

Comments
 (0)