File tree Expand file tree Collapse file tree 4 files changed +86
-120
lines changed Open diff view settings
Expand file tree Collapse file tree 4 files changed +86
-120
lines changed Open diff view settings
Original file line number Diff line number Diff line change @@ -382,6 +382,7 @@ declare module 'vue' {
382382 readonly createInjectionState : UnwrapRef < typeof import ( '@vueuse/core' ) [ 'createInjectionState' ] >
383383 readonly createProjection : UnwrapRef < typeof import ( '@vueuse/math' ) [ 'createProjection' ] >
384384 readonly createReactiveFn : UnwrapRef < typeof import ( '@vueuse/core' ) [ 'createReactiveFn' ] >
385+ readonly createRef : UnwrapRef < typeof import ( '@vueuse/core' ) [ 'createRef' ] >
385386 readonly createReusableTemplate : UnwrapRef < typeof import ( '@vueuse/core' ) [ 'createReusableTemplate' ] >
386387 readonly createSharedComposable : UnwrapRef < typeof import ( '@vueuse/core' ) [ 'createSharedComposable' ] >
387388 readonly createTemplatePromise : UnwrapRef < typeof import ( '@vueuse/core' ) [ 'createTemplatePromise' ] >
Original file line number Diff line number Diff line change 1+ import type { Plugin } from 'vite'
2+
3+ const CDN_BASE = 'https://esm.sh/'
4+
5+ const BABEL_HELPER_GLOBALS_IMPORT_MAPS = [
6+ '@babel/helper-globals/data/builtin-lower.json' ,
7+ '@babel/helper-globals/data/builtin-upper.json' ,
8+ ]
9+
10+ export function importMapPlugin ( ) : Plugin {
11+ return {
12+ name : 'import-map-plugin' ,
13+ apply : 'build' ,
14+ transformIndexHtml ( html : string ) {
15+ // Create import map script tag
16+ const importMapScript = `<script type="importmap">
17+ {
18+ "imports": ${ JSON . stringify ( BABEL_HELPER_GLOBALS_IMPORT_MAPS . reduce < Record < string , string > > (
19+ ( acc , cur ) => {
20+ acc [ cur ] = `${ CDN_BASE } ${ cur } `
21+ return acc
22+ } ,
23+ { } ,
24+ ) , null , 2 ) }
25+ }
26+ </script>`
27+
28+ // Insert the import map before any other scripts
29+ return html . replace (
30+ / < h e a d > / ,
31+ `<head>\n${ importMapScript } ` ,
32+ )
33+ } ,
34+ }
35+ }
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import Components from 'unplugin-vue-components/vite'
66import { defineConfig } from 'vite'
77import Inspect from 'vite-plugin-inspect'
88import { alias } from '../alias'
9+ import { importMapPlugin } from './vite-plugin-import-map'
910
1011const git = SimpleGit ( )
1112
@@ -49,6 +50,7 @@ export default defineConfig({
4950 vueTemplate : true ,
5051 dts : 'src/auto-imports.d.ts' ,
5152 } ) ,
53+ importMapPlugin ( ) ,
5254 ] ,
5355 optimizeDeps : {
5456 exclude : [
You can’t perform that action at this time.
0 commit comments