@vue/compiler-sfc 3.2.46 → 3.3.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compiler-sfc.cjs.js +3451 -7358
- package/dist/compiler-sfc.d.ts +259 -317
- package/dist/compiler-sfc.esm-browser.js +18046 -19204
- package/package.json +8 -8
package/dist/compiler-sfc.d.ts
CHANGED
|
@@ -1,317 +1,259 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { BindingMetadata } from '@vue/compiler-core';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
export
|
|
161
|
-
type: 'script';
|
|
162
|
-
setup?: string | boolean;
|
|
163
|
-
bindings?: BindingMetadata;
|
|
164
|
-
imports?: Record<string, ImportBinding>;
|
|
165
|
-
scriptAst?: Statement[];
|
|
166
|
-
scriptSetupAst?: Statement[];
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
*
|
|
185
|
-
*/
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
*
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
*
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
export declare interface SFCTemplateBlock extends SFCBlock {
|
|
261
|
-
type: 'template';
|
|
262
|
-
ast: ElementNode;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
export declare interface SFCTemplateCompileOptions {
|
|
266
|
-
source: string;
|
|
267
|
-
filename: string;
|
|
268
|
-
id: string;
|
|
269
|
-
scoped?: boolean;
|
|
270
|
-
slotted?: boolean;
|
|
271
|
-
isProd?: boolean;
|
|
272
|
-
ssr?: boolean;
|
|
273
|
-
ssrCssVars?: string[];
|
|
274
|
-
inMap?: RawSourceMap;
|
|
275
|
-
compiler?: TemplateCompiler;
|
|
276
|
-
compilerOptions?: CompilerOptions;
|
|
277
|
-
preprocessLang?: string;
|
|
278
|
-
preprocessOptions?: any;
|
|
279
|
-
/**
|
|
280
|
-
* In some cases, compiler-sfc may not be inside the project root (e.g. when
|
|
281
|
-
* linked or globally installed). In such cases a custom `require` can be
|
|
282
|
-
* passed to correctly resolve the preprocessors.
|
|
283
|
-
*/
|
|
284
|
-
preprocessCustomRequire?: (id: string) => any;
|
|
285
|
-
/**
|
|
286
|
-
* Configure what tags/attributes to transform into asset url imports,
|
|
287
|
-
* or disable the transform altogether with `false`.
|
|
288
|
-
*/
|
|
289
|
-
transformAssetUrls?: AssetURLOptions | AssetURLTagConfig | boolean;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
export declare interface SFCTemplateCompileResults {
|
|
293
|
-
code: string;
|
|
294
|
-
ast?: RootNode;
|
|
295
|
-
preamble?: string;
|
|
296
|
-
source: string;
|
|
297
|
-
tips: string[];
|
|
298
|
-
errors: (string | CompilerError)[];
|
|
299
|
-
map?: RawSourceMap;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
export { shouldTransformRef }
|
|
303
|
-
|
|
304
|
-
export declare interface TemplateCompiler {
|
|
305
|
-
compile(template: string, options: CompilerOptions): CodegenResult;
|
|
306
|
-
parse(template: string, options: ParserOptions): RootNode;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
export { transformRef }
|
|
310
|
-
|
|
311
|
-
export { transformRefAST }
|
|
312
|
-
|
|
313
|
-
export declare const walk: any;
|
|
314
|
-
|
|
315
|
-
export { walkIdentifiers }
|
|
316
|
-
|
|
317
|
-
export { }
|
|
1
|
+
import * as _babel_types from '@babel/types';
|
|
2
|
+
import { CompilerOptions, CodegenResult, ParserOptions, RootNode, CompilerError, SourceLocation, ElementNode, BindingMetadata } from '@vue/compiler-core';
|
|
3
|
+
export { BindingMetadata, CompilerError, CompilerOptions, extractIdentifiers, generateCodeFrame, isInDestructureAssignment, isStaticProperty, walkIdentifiers } from '@vue/compiler-core';
|
|
4
|
+
import { RawSourceMap } from 'source-map';
|
|
5
|
+
import { ParserPlugin } from '@babel/parser';
|
|
6
|
+
export { parse as babelParse } from '@babel/parser';
|
|
7
|
+
import { Result, LazyResult } from 'postcss';
|
|
8
|
+
export { shouldTransform as shouldTransformRef, transform as transformRef, transformAST as transformRefAST } from '@vue/reactivity-transform';
|
|
9
|
+
export { default as MagicString } from 'magic-string';
|
|
10
|
+
|
|
11
|
+
export interface AssetURLTagConfig {
|
|
12
|
+
[name: string]: string[];
|
|
13
|
+
}
|
|
14
|
+
export interface AssetURLOptions {
|
|
15
|
+
/**
|
|
16
|
+
* If base is provided, instead of transforming relative asset urls into
|
|
17
|
+
* imports, they will be directly rewritten to absolute urls.
|
|
18
|
+
*/
|
|
19
|
+
base?: string | null;
|
|
20
|
+
/**
|
|
21
|
+
* If true, also processes absolute urls.
|
|
22
|
+
*/
|
|
23
|
+
includeAbsolute?: boolean;
|
|
24
|
+
tags?: AssetURLTagConfig;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface TemplateCompiler {
|
|
28
|
+
compile(template: string, options: CompilerOptions): CodegenResult;
|
|
29
|
+
parse(template: string, options: ParserOptions): RootNode;
|
|
30
|
+
}
|
|
31
|
+
export interface SFCTemplateCompileResults {
|
|
32
|
+
code: string;
|
|
33
|
+
ast?: RootNode;
|
|
34
|
+
preamble?: string;
|
|
35
|
+
source: string;
|
|
36
|
+
tips: string[];
|
|
37
|
+
errors: (string | CompilerError)[];
|
|
38
|
+
map?: RawSourceMap;
|
|
39
|
+
}
|
|
40
|
+
export interface SFCTemplateCompileOptions {
|
|
41
|
+
source: string;
|
|
42
|
+
filename: string;
|
|
43
|
+
id: string;
|
|
44
|
+
scoped?: boolean;
|
|
45
|
+
slotted?: boolean;
|
|
46
|
+
isProd?: boolean;
|
|
47
|
+
ssr?: boolean;
|
|
48
|
+
ssrCssVars?: string[];
|
|
49
|
+
inMap?: RawSourceMap;
|
|
50
|
+
compiler?: TemplateCompiler;
|
|
51
|
+
compilerOptions?: CompilerOptions;
|
|
52
|
+
preprocessLang?: string;
|
|
53
|
+
preprocessOptions?: any;
|
|
54
|
+
/**
|
|
55
|
+
* In some cases, compiler-sfc may not be inside the project root (e.g. when
|
|
56
|
+
* linked or globally installed). In such cases a custom `require` can be
|
|
57
|
+
* passed to correctly resolve the preprocessors.
|
|
58
|
+
*/
|
|
59
|
+
preprocessCustomRequire?: (id: string) => any;
|
|
60
|
+
/**
|
|
61
|
+
* Configure what tags/attributes to transform into asset url imports,
|
|
62
|
+
* or disable the transform altogether with `false`.
|
|
63
|
+
*/
|
|
64
|
+
transformAssetUrls?: AssetURLOptions | AssetURLTagConfig | boolean;
|
|
65
|
+
}
|
|
66
|
+
declare function compileTemplate(options: SFCTemplateCompileOptions): SFCTemplateCompileResults;
|
|
67
|
+
|
|
68
|
+
export interface SFCScriptCompileOptions {
|
|
69
|
+
/**
|
|
70
|
+
* Scope ID for prefixing injected CSS variables.
|
|
71
|
+
* This must be consistent with the `id` passed to `compileStyle`.
|
|
72
|
+
*/
|
|
73
|
+
id: string;
|
|
74
|
+
/**
|
|
75
|
+
* Production mode. Used to determine whether to generate hashed CSS variables
|
|
76
|
+
*/
|
|
77
|
+
isProd?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Enable/disable source map. Defaults to true.
|
|
80
|
+
*/
|
|
81
|
+
sourceMap?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* https://babeljs.io/docs/en/babel-parser#plugins
|
|
84
|
+
*/
|
|
85
|
+
babelParserPlugins?: ParserPlugin[];
|
|
86
|
+
/**
|
|
87
|
+
* (Experimental) Enable syntax transform for using refs without `.value` and
|
|
88
|
+
* using destructured props with reactivity
|
|
89
|
+
*/
|
|
90
|
+
reactivityTransform?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* (Experimental) Enable syntax transform for using refs without `.value`
|
|
93
|
+
* https://github.com/vuejs/rfcs/discussions/369
|
|
94
|
+
* @deprecated now part of `reactivityTransform`
|
|
95
|
+
* @default false
|
|
96
|
+
*/
|
|
97
|
+
refTransform?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* (Experimental) Enable syntax transform for destructuring from defineProps()
|
|
100
|
+
* https://github.com/vuejs/rfcs/discussions/394
|
|
101
|
+
* @deprecated now part of `reactivityTransform`
|
|
102
|
+
* @default false
|
|
103
|
+
*/
|
|
104
|
+
propsDestructureTransform?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* @deprecated use `reactivityTransform` instead.
|
|
107
|
+
*/
|
|
108
|
+
refSugar?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Compile the template and inline the resulting render function
|
|
111
|
+
* directly inside setup().
|
|
112
|
+
* - Only affects `<script setup>`
|
|
113
|
+
* - This should only be used in production because it prevents the template
|
|
114
|
+
* from being hot-reloaded separately from component state.
|
|
115
|
+
*/
|
|
116
|
+
inlineTemplate?: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Options for template compilation when inlining. Note these are options that
|
|
119
|
+
* would normally be passed to `compiler-sfc`'s own `compileTemplate()`, not
|
|
120
|
+
* options passed to `compiler-dom`.
|
|
121
|
+
*/
|
|
122
|
+
templateOptions?: Partial<SFCTemplateCompileOptions>;
|
|
123
|
+
}
|
|
124
|
+
export interface ImportBinding {
|
|
125
|
+
isType: boolean;
|
|
126
|
+
imported: string;
|
|
127
|
+
local: string;
|
|
128
|
+
source: string;
|
|
129
|
+
isFromSetup: boolean;
|
|
130
|
+
isUsedInTemplate: boolean;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Compile `<script setup>`
|
|
134
|
+
* It requires the whole SFC descriptor because we need to handle and merge
|
|
135
|
+
* normal `<script>` + `<script setup>` if both are present.
|
|
136
|
+
*/
|
|
137
|
+
declare function compileScript(sfc: SFCDescriptor, options: SFCScriptCompileOptions): SFCScriptBlock;
|
|
138
|
+
|
|
139
|
+
export interface SFCParseOptions {
|
|
140
|
+
filename?: string;
|
|
141
|
+
sourceMap?: boolean;
|
|
142
|
+
sourceRoot?: string;
|
|
143
|
+
pad?: boolean | 'line' | 'space';
|
|
144
|
+
ignoreEmpty?: boolean;
|
|
145
|
+
compiler?: TemplateCompiler;
|
|
146
|
+
}
|
|
147
|
+
export interface SFCBlock {
|
|
148
|
+
type: string;
|
|
149
|
+
content: string;
|
|
150
|
+
attrs: Record<string, string | true>;
|
|
151
|
+
loc: SourceLocation;
|
|
152
|
+
map?: RawSourceMap;
|
|
153
|
+
lang?: string;
|
|
154
|
+
src?: string;
|
|
155
|
+
}
|
|
156
|
+
export interface SFCTemplateBlock extends SFCBlock {
|
|
157
|
+
type: 'template';
|
|
158
|
+
ast: ElementNode;
|
|
159
|
+
}
|
|
160
|
+
export interface SFCScriptBlock extends SFCBlock {
|
|
161
|
+
type: 'script';
|
|
162
|
+
setup?: string | boolean;
|
|
163
|
+
bindings?: BindingMetadata;
|
|
164
|
+
imports?: Record<string, ImportBinding>;
|
|
165
|
+
scriptAst?: _babel_types.Statement[];
|
|
166
|
+
scriptSetupAst?: _babel_types.Statement[];
|
|
167
|
+
}
|
|
168
|
+
export interface SFCStyleBlock extends SFCBlock {
|
|
169
|
+
type: 'style';
|
|
170
|
+
scoped?: boolean;
|
|
171
|
+
module?: string | boolean;
|
|
172
|
+
}
|
|
173
|
+
export interface SFCDescriptor {
|
|
174
|
+
filename: string;
|
|
175
|
+
source: string;
|
|
176
|
+
template: SFCTemplateBlock | null;
|
|
177
|
+
script: SFCScriptBlock | null;
|
|
178
|
+
scriptSetup: SFCScriptBlock | null;
|
|
179
|
+
styles: SFCStyleBlock[];
|
|
180
|
+
customBlocks: SFCBlock[];
|
|
181
|
+
cssVars: string[];
|
|
182
|
+
/**
|
|
183
|
+
* whether the SFC uses :slotted() modifier.
|
|
184
|
+
* this is used as a compiler optimization hint.
|
|
185
|
+
*/
|
|
186
|
+
slotted: boolean;
|
|
187
|
+
/**
|
|
188
|
+
* compare with an existing descriptor to determine whether HMR should perform
|
|
189
|
+
* a reload vs. re-render.
|
|
190
|
+
*
|
|
191
|
+
* Note: this comparison assumes the prev/next script are already identical,
|
|
192
|
+
* and only checks the special case where <script setup lang="ts"> unused import
|
|
193
|
+
* pruning result changes due to template changes.
|
|
194
|
+
*/
|
|
195
|
+
shouldForceReload: (prevImports: Record<string, ImportBinding>) => boolean;
|
|
196
|
+
}
|
|
197
|
+
export interface SFCParseResult {
|
|
198
|
+
descriptor: SFCDescriptor;
|
|
199
|
+
errors: (CompilerError | SyntaxError)[];
|
|
200
|
+
}
|
|
201
|
+
declare function parse(source: string, { sourceMap, filename, sourceRoot, pad, ignoreEmpty, compiler }?: SFCParseOptions): SFCParseResult;
|
|
202
|
+
|
|
203
|
+
export type PreprocessLang = 'less' | 'sass' | 'scss' | 'styl' | 'stylus';
|
|
204
|
+
|
|
205
|
+
export interface SFCStyleCompileOptions {
|
|
206
|
+
source: string;
|
|
207
|
+
filename: string;
|
|
208
|
+
id: string;
|
|
209
|
+
scoped?: boolean;
|
|
210
|
+
trim?: boolean;
|
|
211
|
+
isProd?: boolean;
|
|
212
|
+
inMap?: RawSourceMap;
|
|
213
|
+
preprocessLang?: PreprocessLang;
|
|
214
|
+
preprocessOptions?: any;
|
|
215
|
+
preprocessCustomRequire?: (id: string) => any;
|
|
216
|
+
postcssOptions?: any;
|
|
217
|
+
postcssPlugins?: any[];
|
|
218
|
+
/**
|
|
219
|
+
* @deprecated use `inMap` instead.
|
|
220
|
+
*/
|
|
221
|
+
map?: RawSourceMap;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Aligns with postcss-modules
|
|
225
|
+
* https://github.com/css-modules/postcss-modules
|
|
226
|
+
*/
|
|
227
|
+
export interface CSSModulesOptions {
|
|
228
|
+
scopeBehaviour?: 'global' | 'local';
|
|
229
|
+
generateScopedName?: string | ((name: string, filename: string, css: string) => string);
|
|
230
|
+
hashPrefix?: string;
|
|
231
|
+
localsConvention?: 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly';
|
|
232
|
+
exportGlobals?: boolean;
|
|
233
|
+
globalModulePaths?: RegExp[];
|
|
234
|
+
}
|
|
235
|
+
export interface SFCAsyncStyleCompileOptions extends SFCStyleCompileOptions {
|
|
236
|
+
isAsync?: boolean;
|
|
237
|
+
modules?: boolean;
|
|
238
|
+
modulesOptions?: CSSModulesOptions;
|
|
239
|
+
}
|
|
240
|
+
export interface SFCStyleCompileResults {
|
|
241
|
+
code: string;
|
|
242
|
+
map: RawSourceMap | undefined;
|
|
243
|
+
rawResult: Result | LazyResult | undefined;
|
|
244
|
+
errors: Error[];
|
|
245
|
+
modules?: Record<string, string>;
|
|
246
|
+
dependencies: Set<string>;
|
|
247
|
+
}
|
|
248
|
+
declare function compileStyle(options: SFCStyleCompileOptions): SFCStyleCompileResults;
|
|
249
|
+
declare function compileStyleAsync(options: SFCAsyncStyleCompileOptions): Promise<SFCStyleCompileResults>;
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Utility for rewriting `export default` in a script block into a variable
|
|
253
|
+
* declaration so that we can inject things into it
|
|
254
|
+
*/
|
|
255
|
+
declare function rewriteDefault(input: string, as: string, parserPlugins?: ParserPlugin[]): string;
|
|
256
|
+
|
|
257
|
+
declare const walk: any;
|
|
258
|
+
|
|
259
|
+
export { compileScript, compileStyle, compileStyleAsync, compileTemplate, parse, rewriteDefault, walk };
|