1
- import fs from 'fs/promises'
2
- import { fileURLToPath } from 'url'
1
+ import fs from 'node: fs/promises'
2
+ import { fileURLToPath } from 'node: url'
3
3
4
4
import dts from 'rollup-plugin-dts'
5
5
import fg from 'fast-glob'
@@ -9,6 +9,10 @@ import MagicString from 'magic-string'
9
9
import importMap from '../dist/json/importMap.json' with { type : 'json' }
10
10
import importMapLabs from '../dist/json/importMap-labs.json' with { type : 'json' }
11
11
12
+ /**
13
+ * @param code {string}
14
+ * @returns {string }
15
+ */
12
16
export function codeTransform ( code ) {
13
17
return code
14
18
// ignore missing vue-router
@@ -17,6 +21,13 @@ export function codeTransform (code) {
17
21
. replaceAll ( / ^ \s * e x p o r t \{ \s * \} ; ? $ / gm, '' )
18
22
}
19
23
24
+ /**
25
+ * @param input {string}
26
+ * @param output {string}
27
+ * @param renderChunk {import("rollup").RenderChunkHook | undefined}
28
+ * @param filter {(files: string[]) => string[] | undefined}
29
+ * @returns {import("rollup").RollupOptions[] }
30
+ */
20
31
function createTypesConfig ( input , output , renderChunk , filter ) {
21
32
input = 'lib/' + input
22
33
let files = fg . sync ( input )
@@ -25,7 +36,8 @@ function createTypesConfig (input, output, renderChunk, filter) {
25
36
26
37
return files . map ( file => {
27
38
const outputFile = output . replace ( '*' , mm . capture ( input , file ) [ 0 ] )
28
- return {
39
+ /** @type {import("rollup").RollupOptions } */
40
+ const options = {
29
41
input : file ,
30
42
output : [ { file : outputFile , format : 'es' , sourcemap : false } ] ,
31
43
plugins : [
@@ -51,9 +63,14 @@ function createTypesConfig (input, output, renderChunk, filter) {
51
63
} ,
52
64
] ,
53
65
}
66
+ return options
54
67
} )
55
68
}
56
69
70
+ /**
71
+ * @param useImport {boolean|undefined}
72
+ * @returns {Promise<string> }
73
+ */
57
74
async function getShims ( useImport ) {
58
75
let components
59
76
if ( useImport ) {
@@ -75,7 +92,8 @@ async function getShims (useImport) {
75
92
. replace ( / ^ \s * \/ \/ @ g e n e r a t e - c o m p o n e n t s $ / gm, components )
76
93
}
77
94
78
- export default [
95
+ /** @type {import("rollup").RollupOptions[] } */
96
+ const options = [
79
97
createTypesConfig ( 'entry-bundler.d.ts' , 'dist/vuetify.d.ts' , async code => {
80
98
code . replaceAll ( / t y p e i n d e x _ d \$ 1 _ V ( \w + ) = V ( \w + ) ; / gm, 'declare const index_d$$1_V$1: typeof V$2;' )
81
99
code . append ( '\n\n' )
@@ -91,3 +109,5 @@ export default [
91
109
code . append ( await getShims ( true ) )
92
110
} ) ,
93
111
] . flat ( )
112
+
113
+ export default options
0 commit comments