From: Evan You Date: Fri, 4 Oct 2019 21:43:20 +0000 (-0400) Subject: workflow: improve template explorer X-Git-Tag: v3.0.0-alpha.0~614 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0873254c6c4d82c12698c1bdc1638869f6cb93c9;p=thirdparty%2Fvuejs%2Fcore.git workflow: improve template explorer --- diff --git a/packages/compiler-core/src/codegen.ts b/packages/compiler-core/src/codegen.ts index 9e4e866262..8337c3a58c 100644 --- a/packages/compiler-core/src/codegen.ts +++ b/packages/compiler-core/src/codegen.ts @@ -22,7 +22,8 @@ import { SourceMapGenerator, RawSourceMap } from 'source-map' import { advancePositionWithMutation, assert, - isSimpleIdentifier + isSimpleIdentifier, + loadDep } from './utils' import { isString, isArray } from '@vue/shared' import { TO_STRING, CREATE_VNODE, COMMENT } from './runtimeConstants' @@ -97,7 +98,7 @@ function createCodegenContext( map: __BROWSER__ || !sourceMap ? undefined - : new (require('source-map')).SourceMapGenerator(), + : new (loadDep('source-map')).SourceMapGenerator(), helper(name) { return prefixIdentifiers ? name : `_${name}` diff --git a/packages/compiler-core/src/transforms/vIf.ts b/packages/compiler-core/src/transforms/vIf.ts index b78d395c39..25700c34c4 100644 --- a/packages/compiler-core/src/transforms/vIf.ts +++ b/packages/compiler-core/src/transforms/vIf.ts @@ -41,7 +41,9 @@ export const transformIf = createStructuralDirectiveTransform( (!dir.exp || !(dir.exp as SimpleExpressionNode).content.trim()) ) { const loc = dir.exp ? dir.exp.loc : node.loc - context.onError(createCompilerError(ErrorCodes.X_IF_NO_EXPRESSION, loc)) + context.onError( + createCompilerError(ErrorCodes.X_IF_NO_EXPRESSION, dir.loc) + ) dir.exp = createSimpleExpression(`true`, false, loc) } diff --git a/packages/compiler-core/src/utils.ts b/packages/compiler-core/src/utils.ts index c8711d1401..e77a4856a6 100644 --- a/packages/compiler-core/src/utils.ts +++ b/packages/compiler-core/src/utils.ts @@ -29,7 +29,7 @@ import { PropsExpression } from './transforms/transformElement' let _parse: typeof parse let _walk: typeof walk -function loadDep(name: string) { +export function loadDep(name: string) { if (typeof process !== 'undefined' && isFunction(require)) { return require(name) } else { diff --git a/packages/template-explorer/index.html b/packages/template-explorer/index.html index 41c46c35f7..349758adc1 100644 --- a/packages/template-explorer/index.html +++ b/packages/template-explorer/index.html @@ -1,35 +1,21 @@ +Vue Template Explorer - + +
+