@@ -9,8 +9,20 @@ export enum npmCdnEnum {
9
9
10
10
export const DEFAULT_CDN = npmCdnEnum . unpkg
11
11
12
+ /**
13
+ * get cdn url by package name & filePath
14
+ * if use unpkg cdn, url will add query params: ?module'
15
+ */
16
+ export const getCdnUrl = ( npmName : string , filePath ?: string ) => {
17
+ if ( DEFAULT_CDN === npmCdnEnum . unpkg ) {
18
+ return `${ DEFAULT_CDN } /${ npmName } ?module`
19
+ }
20
+
21
+ return `${ DEFAULT_CDN } /${ npmName } /${ filePath } `
22
+ }
23
+
12
24
/** get vue runtime cdn url buy version */
13
- export const getVueRuntimeURL = ( version : string ) => ` ${ DEFAULT_CDN } /@vue/runtime-dom@ ${ version } /dist/runtime-dom.esm-browser.js`
25
+ export const getVueRuntimeURL = ( version ? : string ) => getCdnUrl ( 'vue' + ( version ? `@ ${ version } ` : '' ) )
14
26
15
27
/** get vue compiler cdn url buy version */
16
28
export const getVueCompilerURL = ( version : string ) => `${ DEFAULT_CDN } /@vue/compiler-sfc@${ version } /dist/compiler-sfc.esm-browser.js`
@@ -33,25 +45,17 @@ export const getVantURL = (version?: string) => {
33
45
export const defaultMainFile = 'App.vue'
34
46
export const vantInjectPlugin = 'vant-inject-plugin.js'
35
47
36
- /**
37
- * get cdn url by package name & filePath
38
- * if use unpkg cdn, url will add query params: ?module'
39
- */
40
- export const getCdnUrl = ( npmName : string , filePath ?: string ) => {
41
- if ( DEFAULT_CDN === npmCdnEnum . unpkg ) {
42
- return `${ DEFAULT_CDN } /${ npmName } ?module`
43
- }
44
-
45
- return `${ DEFAULT_CDN } /${ npmName } /${ filePath } `
46
- }
47
-
48
48
export const vantImports : Record < string , string > = {
49
49
vant : getVantURL ( ) ,
50
50
'@vant/use' : getCdnUrl ( '@vant/use' , '/dist/index.esm.mjs' ) ,
51
51
'@vant/popperjs' : getCdnUrl ( '@vant/popperjs' , '/dist/index.esm.mjs' ) ,
52
52
'@vant/touch-emulator' : `${ DEFAULT_CDN } /@vant/touch-emulator`
53
53
}
54
54
55
+ export const vueImports : Record < string , string > = {
56
+ vue : getVueRuntimeURL ( )
57
+ }
58
+
55
59
export const additionalImports = {
56
60
...vantImports
57
61
}
0 commit comments