Skip to content

Make the options constants easier to treeshake #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions src/vue-vnode-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,26 +172,35 @@ export type IterationOptions = {
static?: boolean
}

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

export const COMPONENTS_AND_ELEMENTS: IterationOptions = Object.freeze({
return obj
}

export const COMPONENTS_AND_ELEMENTS: IterationOptions = /*#__PURE__*/ freeze({
element: true,
component: true
})

export const SKIP_COMMENTS: IterationOptions = Object.freeze({
export const SKIP_COMMENTS: IterationOptions = /*#__PURE__*/ freeze({
element: true,
component: true,
text: true,
static: true
})

export const ALL_VNODES: IterationOptions = /*#__PURE__*/ freeze({
element: true,
component: true,
text: true,
static: true,
comment: true
})

const promoteToVNode = (node: VNode | string | number | boolean | null | undefined | void, options: IterationOptions): VNode | null => {
const type = getType(node)

Expand Down