Skip to content

Commit 3dc8185

Browse files
Make the options constants easier to treeshake (#5)
1 parent 33f225a commit 3dc8185

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

Diff for: src/vue-vnode-utils.ts

+18-9
Original file line numberDiff line numberDiff line change
@@ -172,26 +172,35 @@ export type IterationOptions = {
172172
static?: boolean
173173
}
174174

175-
export const ALL_VNODES: IterationOptions = Object.freeze({
176-
element: true,
177-
component: true,
178-
comment: true,
179-
text: true,
180-
static: true
181-
})
175+
// esbuild can remove an identity function, so long as it uses a function declaration
176+
function freeze<T>(obj: T): T {
177+
if (DEV) {
178+
return Object.freeze(obj)
179+
}
182180

183-
export const COMPONENTS_AND_ELEMENTS: IterationOptions = Object.freeze({
181+
return obj
182+
}
183+
184+
export const COMPONENTS_AND_ELEMENTS: IterationOptions = /*#__PURE__*/ freeze({
184185
element: true,
185186
component: true
186187
})
187188

188-
export const SKIP_COMMENTS: IterationOptions = Object.freeze({
189+
export const SKIP_COMMENTS: IterationOptions = /*#__PURE__*/ freeze({
189190
element: true,
190191
component: true,
191192
text: true,
192193
static: true
193194
})
194195

196+
export const ALL_VNODES: IterationOptions = /*#__PURE__*/ freeze({
197+
element: true,
198+
component: true,
199+
text: true,
200+
static: true,
201+
comment: true
202+
})
203+
195204
const promoteToVNode = (node: VNode | string | number | boolean | null | undefined | void, options: IterationOptions): VNode | null => {
196205
const type = getType(node)
197206

0 commit comments

Comments
 (0)