Skip to content

Commit 3549662

Browse files
authored
dx(runtime-dom): warn config.isCustomElement usage in runtime-only build (#2945)
1 parent d0ea745 commit 3549662

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

packages/runtime-core/src/component.ts

+3
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,9 @@ type CompileFunction = (
653653

654654
let compile: CompileFunction | undefined
655655

656+
// dev only
657+
export const isRuntimeOnly = () => !compile
658+
656659
/**
657660
* For runtime-dom to register the compiler.
658661
* Note the exported method uses any to avoid d.ts relying on the compiler types.

packages/runtime-core/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export {
8787
resolveDynamicComponent
8888
} from './helpers/resolveAssets'
8989
// For integration with runtime compiler
90-
export { registerRuntimeCompiler } from './component'
90+
export { registerRuntimeCompiler, isRuntimeOnly } from './component'
9191
export {
9292
useTransitionState,
9393
resolveTransitionHooks,

packages/runtime-dom/src/index.ts

+23-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import {
77
Renderer,
88
HydrationRenderer,
99
App,
10-
RootHydrateFunction
10+
RootHydrateFunction,
11+
isRuntimeOnly
1112
} from '@vue/runtime-core'
1213
import { nodeOps } from './nodeOps'
1314
import { patchProp, forcePatchProp } from './patchProp'
@@ -55,6 +56,7 @@ export const createApp = ((...args) => {
5556

5657
if (__DEV__) {
5758
injectNativeTagCheck(app)
59+
injectCustomElementCheck(app)
5860
}
5961

6062
const { mount } = app
@@ -83,6 +85,7 @@ export const createSSRApp = ((...args) => {
8385

8486
if (__DEV__) {
8587
injectNativeTagCheck(app)
88+
injectCustomElementCheck(app)
8689
}
8790

8891
const { mount } = app
@@ -105,6 +108,25 @@ function injectNativeTagCheck(app: App) {
105108
})
106109
}
107110

111+
// dev only
112+
function injectCustomElementCheck(app: App) {
113+
if (isRuntimeOnly()) {
114+
const value = app.config.isCustomElement
115+
Object.defineProperty(app.config, 'isCustomElement', {
116+
get() {
117+
return value
118+
},
119+
set() {
120+
warn(
121+
`The \`isCustomElement\` config option is only respected when using the runtime compiler.` +
122+
`If you are using the runtime-only build, \`isCustomElement\` must be passed to \`@vue/compiler-dom\` in the build setup instead` +
123+
`- for example, via the \`compilerOptions\` option in vue-loader: https://vue-loader.vuejs.org/options.html#compileroptions.`
124+
)
125+
}
126+
})
127+
}
128+
}
129+
108130
function normalizeContainer(
109131
container: Element | ShadowRoot | string
110132
): Element | null {

0 commit comments

Comments
 (0)