@@ -61,11 +61,47 @@ export type HoistTransform = (
61
61
parent : ParentNode
62
62
) => void
63
63
64
+ export const enum BindingTypes {
65
+ DATA = 'data' ,
66
+ PROPS = 'props' ,
67
+ SETUP = 'setup' ,
68
+ CONST = 'const' ,
69
+ OPTIONS = 'options'
70
+ }
71
+
64
72
export interface BindingMetadata {
65
- [ key : string ] : 'data' | 'props' | 'setup' | 'options'
73
+ [ key : string ] : BindingTypes
74
+ }
75
+
76
+ interface SharedTransformCodegenOptions {
77
+ /**
78
+ * Transform expressions like {{ foo }} to `_ctx.foo`.
79
+ * If this option is false, the generated code will be wrapped in a
80
+ * `with (this) { ... }` block.
81
+ * - This is force-enabled in module mode, since modules are by default strict
82
+ * and cannot use `with`
83
+ * @default mode === 'module'
84
+ */
85
+ prefixIdentifiers ?: boolean
86
+ /**
87
+ * Generate SSR-optimized render functions instead.
88
+ * The resulting function must be attached to the component via the
89
+ * `ssrRender` option instead of `render`.
90
+ */
91
+ ssr ?: boolean
92
+ /**
93
+ * Optional binding metadata analyzed from script - used to optimize
94
+ * binding access when `prefixIdentifiers` is enabled.
95
+ */
96
+ bindingMetadata ?: BindingMetadata
97
+ /**
98
+ * Compile the function for inlining inside setup().
99
+ * This allows the function to directly access setup() local bindings.
100
+ */
101
+ inline ?: boolean
66
102
}
67
103
68
- export interface TransformOptions {
104
+ export interface TransformOptions extends SharedTransformCodegenOptions {
69
105
/**
70
106
* An array of node transforms to be applied to every AST node.
71
107
*/
@@ -128,26 +164,15 @@ export interface TransformOptions {
128
164
* SFC scoped styles ID
129
165
*/
130
166
scopeId ?: string | null
131
- /**
132
- * Generate SSR-optimized render functions instead.
133
- * The resulting function must be attached to the component via the
134
- * `ssrRender` option instead of `render`.
135
- */
136
- ssr ?: boolean
137
167
/**
138
168
* SFC `<style vars>` injection string
139
169
* needed to render inline CSS variables on component root
140
170
*/
141
171
ssrCssVars ?: string
142
- /**
143
- * Optional binding metadata analyzed from script - used to optimize
144
- * binding access when `prefixIdentifiers` is enabled.
145
- */
146
- bindingMetadata ?: BindingMetadata
147
172
onError ?: ( error : CompilerError ) => void
148
173
}
149
174
150
- export interface CodegenOptions {
175
+ export interface CodegenOptions extends SharedTransformCodegenOptions {
151
176
/**
152
177
* - `module` mode will generate ES module import statements for helpers
153
178
* and export the render function as the default export.
@@ -189,11 +214,6 @@ export interface CodegenOptions {
189
214
* @default 'Vue'
190
215
*/
191
216
runtimeGlobalName ?: string
192
- // we need to know this during codegen to generate proper preambles
193
- prefixIdentifiers ?: boolean
194
- bindingMetadata ?: BindingMetadata
195
- // generate ssr-specific code?
196
- ssr ?: boolean
197
217
}
198
218
199
219
export type CompilerOptions = ParserOptions & TransformOptions & CodegenOptions
0 commit comments