feat: Initial devtools support (#1125)

This commit is contained in:
Guillaume Chau
2020-07-17 00:18:52 +02:00
committed by GitHub
parent 5ed73cd874
commit 568b6db12b
15 changed files with 132 additions and 17 deletions

16
packages/vue/src/dev.ts Normal file
View File

@@ -0,0 +1,16 @@
import { version, setDevtoolsHook } from '@vue/runtime-dom'
export function initDev() {
const target: any = __BROWSER__ ? window : global
target.__VUE__ = version
setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__)
if (__BROWSER__) {
// @ts-ignore `console.info` cannot be null error
console[console.info ? 'info' : 'log'](
`You are running a development build of Vue.\n` +
`Make sure to use the production build (*.prod.js) when deploying for production.`
)
}
}

View File

@@ -1,7 +0,0 @@
if (__BROWSER__ && __DEV__) {
// @ts-ignore `console.info` cannot be null error
console[console.info ? 'info' : 'log'](
`You are running a development build of Vue.\n` +
`Make sure to use the production build (*.prod.js) when deploying for production.`
)
}

View File

@@ -1,11 +1,13 @@
// This entry is the "full-build" that includes both the runtime
// and the compiler, and supports on-the-fly compilation of the template option.
import './devCheck'
import { initDev } from './dev'
import { compile, CompilerOptions, CompilerError } from '@vue/compiler-dom'
import { registerRuntimeCompiler, RenderFunction, warn } from '@vue/runtime-dom'
import * as runtimeDom from '@vue/runtime-dom'
import { isString, NOOP, generateCodeFrame, extend } from '@vue/shared'
__DEV__ && initDev()
const compileCache: Record<string, RenderFunction> = Object.create(null)
function compileToFunction(

View File

@@ -1,8 +1,10 @@
// This entry exports the runtime only, and is built as
// `dist/vue.esm-bundler.js` which is used by default for bundlers.
import './devCheck'
import { initDev } from './dev'
import { warn } from '@vue/runtime-dom'
__DEV__ && initDev()
export * from '@vue/runtime-dom'
export const compile = () => {