MCPcopy Create free account
hub / github.com/cn-docs/vueuse / updateImport

Function updateImport

scripts/utils.ts:52–102  ·  view source on GitHub ↗
({ packages, functions }: PackageIndexes)

Source from the content-addressed store, hash-verified

50}
51
52export async function updateImport({ packages, functions }: PackageIndexes) {
53 for (const { name, dir, manualImport } of Object.values(packages)) {
54 if (manualImport)
55 continue
56
57 let imports: string[]
58 if (name === 'components') {
59 imports = functions
60 .sort((a, b) => a.name.localeCompare(b.name))
61 .flatMap((fn) => {
62 const arr: string[] = []
63
64 // don't include integration components
65 if (fn.package === 'integrations')
66 return arr
67
68 if (fn.component)
69 arr.push(`export * from '../${fn.package}/${fn.name}/component'`)
70 if (fn.directive)
71 arr.push(`export * from '../${fn.package}/${fn.name}/directive'`)
72 return arr
73 })
74 }
75 else {
76 imports = functions
77 .filter(i => i.package === name)
78 .map(f => f.name)
79 .sort()
80 .map(name => `export * from './${name}'`)
81 }
82
83 if (name === 'core') {
84 imports.push(
85 'export * from \'./types\'',
86 'export * from \'@vueuse/shared\'',
87 'export * from \'./ssr-handlers\'',
88 )
89 }
90
91 if (name === 'nuxt') {
92 imports.push(
93 'export * from \'@vueuse/core\'',
94 )
95 }
96
97 await fs.writeFile(join(dir, 'index.ts'), `${imports.join('\n')}\n`)
98
99 // temporary file for export-size
100 await fs.rm(join(dir, 'index.mjs'), { force: true })
101 }
102}
103
104export function uniq<T extends any[]>(a: T) {
105 return Array.from(new Set(a))

Callers 2

runFunction · 0.90
buildFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected