@@ -18,36 +18,53 @@ export const LANGS_LAZY_EMBEDDED_ALL = {
1818 * Single-file-component-like languages that have embedded langs
1919 * For these langs, we exclude the standalone embedded langs from the main bundle
2020 */
21- export const LANGS_LAZY_EMBEDDED_PARTIAL = [
22- 'vue' ,
23- 'vue-html' ,
24- 'svelte' ,
25- 'pug' ,
26- 'haml' ,
27- 'astro' ,
28- ]
29-
30- /**
31- * Languages to be excluded from SFC langs
32- */
33- export const STANDALONE_LANGS_EMBEDDED = [
34- 'pug' ,
35- 'stylus' ,
36- 'sass' ,
37- 'scss' ,
38- 'coffee' ,
39- 'jsonc' ,
40- 'json5' ,
41- 'yaml' ,
42- 'toml' ,
43- 'scss' ,
44- 'graphql' ,
45- 'markdown' ,
46- 'less' ,
47- 'jsx' ,
48- 'tsx' ,
49- 'ruby' ,
50- ]
21+ export const LANGS_LAZY_EMBEDDED_PARTIAL = {
22+ 'vue' : [
23+ 'markdown' ,
24+ 'pug' ,
25+ 'stylus' ,
26+ 'sass' ,
27+ 'scss' ,
28+ 'less' ,
29+ 'jsx' ,
30+ 'tsx' ,
31+ 'coffee' ,
32+ 'jsonc' ,
33+ 'json5' ,
34+ 'yaml' ,
35+ 'toml' ,
36+ 'graphql' ,
37+ ] ,
38+ 'vue-html' : [ ] ,
39+ 'svelte' : [
40+ 'coffee' ,
41+ 'stylus' ,
42+ 'sass' ,
43+ 'scss' ,
44+ 'less' ,
45+ 'pug' ,
46+ 'markdown' ,
47+ ] ,
48+ 'pug' : [
49+ 'sass' ,
50+ 'scss' ,
51+ 'stylus' ,
52+ 'coffee' ,
53+ ] ,
54+ 'haml' : [
55+ 'ruby' ,
56+ 'sass' ,
57+ 'coffee' ,
58+ 'markdown' ,
59+ ] ,
60+ // Since Astro is a extension of MDX, we don't exclude `jsx` here.
61+ 'astro' : [
62+ 'sass' ,
63+ 'scss' ,
64+ 'stylus' ,
65+ 'less' ,
66+ ] ,
67+ } as Record < string , string [ ] >
5168
5269export async function loadLangs ( ) {
5370 const allLangFiles = await fg ( '*.json' , {
@@ -83,9 +100,10 @@ export async function loadLangs() {
83100 json . embeddedLangsLazy = ( json . embeddedLangs || [ ] ) . filter ( i => ! includes . includes ( i ) ) || [ ]
84101 json . embeddedLangs = includes
85102 }
86- else if ( LANGS_LAZY_EMBEDDED_PARTIAL . includes ( lang . name ) ) {
87- json . embeddedLangsLazy = ( json . embeddedLangs || [ ] ) . filter ( i => STANDALONE_LANGS_EMBEDDED . includes ( i ) ) || [ ]
88- json . embeddedLangs = ( json . embeddedLangs || [ ] ) . filter ( i => ! STANDALONE_LANGS_EMBEDDED . includes ( i ) ) || [ ]
103+ else if ( LANGS_LAZY_EMBEDDED_PARTIAL [ lang . name ] ) {
104+ const includes = LANGS_LAZY_EMBEDDED_PARTIAL [ lang . name ]
105+ json . embeddedLangsLazy = includes
106+ json . embeddedLangs = ( json . embeddedLangs || [ ] ) . filter ( i => ! includes . includes ( i ) ) || [ ]
89107 }
90108
91109 resolvedLangs . push ( json )
0 commit comments