Skip to content
Open
Show file tree
Hide file tree
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
36 changes: 23 additions & 13 deletions packages/runtime-core/src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,28 @@ export function registerRuntimeCompiler(_compile: any): void {
// dev only
export const isRuntimeOnly = (): boolean => !compile

/**
* @internal
*/
export function getResolvedCompilerOptions(
instance: ComponentInternalInstance,
): CompilerOptions {
const Component = instance.type as ComponentOptions
const { isCustomElement, compilerOptions } = instance.appContext.config
const { delimiters, compilerOptions: componentCompilerOptions } = Component

return extend(
extend(
{
isCustomElement,
delimiters,
},
compilerOptions,
),
componentCompilerOptions,
)
}

export function finishComponentSetup(
instance: ComponentInternalInstance,
isSSR: boolean,
Expand Down Expand Up @@ -1021,19 +1043,7 @@ export function finishComponentSetup(
if (__DEV__) {
startMeasure(instance, `compile`)
}
const { isCustomElement, compilerOptions } = instance.appContext.config
const { delimiters, compilerOptions: componentCompilerOptions } =
Component
const finalCompilerOptions: CompilerOptions = extend(
extend(
{
isCustomElement,
delimiters,
},
compilerOptions,
),
componentCompilerOptions,
)
const finalCompilerOptions = getResolvedCompilerOptions(instance)
if (__COMPAT__) {
// pass runtime compat config into the compiler
finalCompilerOptions.compatConfig = Object.create(globalCompatConfig)
Expand Down
3 changes: 3 additions & 0 deletions packages/runtime-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ export { transformVNodeArgs } from './vnode'
import {
createComponentInstance,
getComponentPublicInstance,
getResolvedCompilerOptions,
setupComponent,
} from './component'
import { renderComponentRoot } from './componentRenderUtils'
Expand All @@ -416,6 +417,7 @@ const _ssrUtils: {
ensureValidVNode: typeof ensureValidVNode
pushWarningContext: typeof pushWarningContext
popWarningContext: typeof popWarningContext
getResolvedCompilerOptions: typeof getResolvedCompilerOptions
} = {
createComponentInstance,
setupComponent,
Expand All @@ -427,6 +429,7 @@ const _ssrUtils: {
ensureValidVNode,
pushWarningContext,
popWarningContext,
getResolvedCompilerOptions,
}

/**
Expand Down
17 changes: 2 additions & 15 deletions packages/server-renderer/src/helpers/ssrCompile.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {
type ComponentInternalInstance,
type ComponentOptions,

Check failure on line 3 in packages/server-renderer/src/helpers/ssrCompile.ts

View workflow job for this annotation

GitHub Actions / test / lint-and-test-dts

'ComponentOptions' is declared but its value is never read.
ssrUtils,
warn,
} from 'vue'
import { compile } from '@vue/compiler-ssr'
import { NO, extend, generateCodeFrame, isFunction } from '@vue/shared'

Check failure on line 8 in packages/server-renderer/src/helpers/ssrCompile.ts

View workflow job for this annotation

GitHub Actions / test / lint-and-test-dts

'extend' is declared but its value is never read.
import type { CompilerError, CompilerOptions } from '@vue/compiler-core'

Check failure on line 9 in packages/server-renderer/src/helpers/ssrCompile.ts

View workflow job for this annotation

GitHub Actions / test / lint-and-test-dts

'CompilerOptions' is declared but never used.
import type { PushFn } from '../render'

import * as Vue from 'vue'
Expand All @@ -32,21 +33,7 @@
)
}

// TODO: This is copied from runtime-core/src/component.ts and should probably be refactored
const Component = instance.type as ComponentOptions
const { isCustomElement, compilerOptions } = instance.appContext.config
const { delimiters, compilerOptions: componentCompilerOptions } = Component

const finalCompilerOptions: CompilerOptions = extend(
extend(
{
isCustomElement,
delimiters,
},
compilerOptions,
),
componentCompilerOptions,
)
const finalCompilerOptions = ssrUtils.getResolvedCompilerOptions(instance)

finalCompilerOptions.isCustomElement =
finalCompilerOptions.isCustomElement || NO
Expand Down
Loading