Skip to content

Commit

Permalink
perf: mark defineComponent as side-effects-free
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu authored and yyx990803 committed Jul 11, 2023
1 parent 97b6fae commit ee5e5e0
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 51 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"prettier": "^2.7.1",
"pug": "^3.0.1",
"puppeteer": "~19.6.0",
"rollup": "^3.20.2",
"rollup": "^3.26.0",
"rollup-plugin-dts": "^5.3.0",
"rollup-plugin-esbuild": "^5.0.0",
"rollup-plugin-polyfill-node": "^0.12.0",
Expand Down
1 change: 1 addition & 0 deletions packages/runtime-core/src/apiAsyncComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export interface AsyncComponentOptions<T = any> {
export const isAsyncWrapper = (i: ComponentInternalInstance | VNode): boolean =>
!!(i.type as ComponentOptions).__asyncLoader

/*! #__NO_SIDE_EFFECTS__ */
export function defineAsyncComponent<
T extends Component = { new (): ComponentPublicInstance }
>(source: AsyncComponentLoader<T> | AsyncComponentOptions<T>): T {
Expand Down
3 changes: 2 additions & 1 deletion packages/runtime-core/src/apiDefineComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export type DefineComponent<
// for TSX / manual render function / IDE support.

// overload 1: direct setup function
// (uses user defined props interface)
// (uses user defined props interface)]
export function defineComponent<
Props extends Record<string, any>,
E extends EmitsOptions = {},
Expand Down Expand Up @@ -274,6 +274,7 @@ export function defineComponent<
>

// implementation, close to no-op
/*! #__NO_SIDE_EFFECTS__ */
export function defineComponent(
options: unknown,
extraOptions?: ComponentOptions
Expand Down
2 changes: 2 additions & 0 deletions packages/runtime-dom/src/apiCustomElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export function defineCustomElement(options: {
new (...args: any[]): ComponentPublicInstance
}): VueElementConstructor

/*! #__NO_SIDE_EFFECTS__ */
export function defineCustomElement(
options: any,
hydrate?: RootHydrateFunction
Expand All @@ -155,6 +156,7 @@ export function defineCustomElement(
return VueCustomElement
}

/*! #__NO_SIDE_EFFECTS__ */
export const defineSSRCustomElement = ((options: any) => {
// @ts-ignore
return defineCustomElement(options, hydrate)
Expand Down
90 changes: 41 additions & 49 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ee5e5e0

Please sign in to comment.