]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
dx(runtime-dom): warn config.isCustomElement usage in runtime-only build (#2945)
authorHcySunYang <HcySunYang@outlook.com>
Wed, 24 Feb 2021 21:18:55 +0000 (05:18 +0800)
committerGitHub <noreply@github.com>
Wed, 24 Feb 2021 21:18:55 +0000 (16:18 -0500)
packages/runtime-core/src/component.ts
packages/runtime-core/src/index.ts
packages/runtime-dom/src/index.ts

index 406e8e0e4f6bd60aa43a66fb623f70c2fb4a764f..9b142036219f66311f98fdd3fcfe8544b4bb6fc0 100644 (file)
@@ -653,6 +653,9 @@ type CompileFunction = (
 
 let compile: CompileFunction | undefined
 
+// dev only
+export const isRuntimeOnly = () => !compile
+
 /**
  * For runtime-dom to register the compiler.
  * Note the exported method uses any to avoid d.ts relying on the compiler types.
index 818caa597e6ce9de4328e14c9611d46180bbe8e0..a24672226dbc9c1d2115c9b749888786f8b3781a 100644 (file)
@@ -87,7 +87,7 @@ export {
   resolveDynamicComponent
 } from './helpers/resolveAssets'
 // For integration with runtime compiler
-export { registerRuntimeCompiler } from './component'
+export { registerRuntimeCompiler, isRuntimeOnly } from './component'
 export {
   useTransitionState,
   resolveTransitionHooks,
index 027bef11be7cbc9fbe6affea17e8654669b194e3..8a66ec994c9094fdbd8a73aa614afa7cc0604b47 100644 (file)
@@ -7,7 +7,8 @@ import {
   Renderer,
   HydrationRenderer,
   App,
-  RootHydrateFunction
+  RootHydrateFunction,
+  isRuntimeOnly
 } from '@vue/runtime-core'
 import { nodeOps } from './nodeOps'
 import { patchProp, forcePatchProp } from './patchProp'
@@ -55,6 +56,7 @@ export const createApp = ((...args) => {
 
   if (__DEV__) {
     injectNativeTagCheck(app)
+    injectCustomElementCheck(app)
   }
 
   const { mount } = app
@@ -83,6 +85,7 @@ export const createSSRApp = ((...args) => {
 
   if (__DEV__) {
     injectNativeTagCheck(app)
+    injectCustomElementCheck(app)
   }
 
   const { mount } = app
@@ -105,6 +108,25 @@ function injectNativeTagCheck(app: App) {
   })
 }
 
+// dev only
+function injectCustomElementCheck(app: App) {
+  if (isRuntimeOnly()) {
+    const value = app.config.isCustomElement
+    Object.defineProperty(app.config, 'isCustomElement', {
+      get() {
+        return value
+      },
+      set() {
+        warn(
+          `The \`isCustomElement\` config option is only respected when using the runtime compiler.` +
+            `If you are using the runtime-only build, \`isCustomElement\` must be passed to \`@vue/compiler-dom\` in the build setup instead` +
+            `- for example, via the \`compilerOptions\` option in vue-loader: https://vue-loader.vuejs.org/options.html#compileroptions.`
+        )
+      }
+    })
+  }
+}
+
 function normalizeContainer(
   container: Element | ShadowRoot | string
 ): Element | null {