mirror of https://github.com/vuejs/core.git
refactor: remove prefixIdentifier and mode usage in compiler-vapor
vapor compilation always assume module mode + prefixIdentifier: true
This commit is contained in:
parent
fca1aef896
commit
1ff6b136db
|
@ -3,7 +3,7 @@ import { IRNodeTypes } from '../../src'
|
|||
import { getBaseTransformPreset } from '../../src/compile'
|
||||
import { makeCompile } from './_utils'
|
||||
|
||||
const [nodeTransforms, directiveTransforms] = getBaseTransformPreset(true)
|
||||
const [nodeTransforms, directiveTransforms] = getBaseTransformPreset()
|
||||
const compileWithOnce = makeCompile({
|
||||
nodeTransforms,
|
||||
directiveTransforms,
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
import {
|
||||
type CompilerOptions as BaseCompilerOptions,
|
||||
ErrorCodes,
|
||||
type RootNode,
|
||||
createCompilerError,
|
||||
defaultOnError,
|
||||
parse,
|
||||
} from '@vue/compiler-dom'
|
||||
import { extend, isString } from '@vue/shared'
|
||||
|
@ -38,20 +35,9 @@ export function compile(
|
|||
source: string | RootNode,
|
||||
options: CompilerOptions = {},
|
||||
): VaporCodegenResult {
|
||||
const onError = options.onError || defaultOnError
|
||||
const isModuleMode = options.mode === 'module'
|
||||
const prefixIdentifiers = options.prefixIdentifiers === true || isModuleMode
|
||||
|
||||
if (options.scopeId && !isModuleMode) {
|
||||
onError(createCompilerError(ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED))
|
||||
}
|
||||
|
||||
const resolvedOptions = extend({}, options, {
|
||||
prefixIdentifiers,
|
||||
})
|
||||
const resolvedOptions = extend({}, options)
|
||||
const ast = isString(source) ? parse(source, resolvedOptions) : source
|
||||
const [nodeTransforms, directiveTransforms] =
|
||||
getBaseTransformPreset(prefixIdentifiers)
|
||||
const [nodeTransforms, directiveTransforms] = getBaseTransformPreset()
|
||||
|
||||
if (options.isTS) {
|
||||
const { expressionPlugins } = options
|
||||
|
@ -87,9 +73,7 @@ export type TransformPreset = [
|
|||
Record<string, DirectiveTransform>,
|
||||
]
|
||||
|
||||
export function getBaseTransformPreset(
|
||||
prefixIdentifiers?: boolean,
|
||||
): TransformPreset {
|
||||
export function getBaseTransformPreset(): TransformPreset {
|
||||
return [
|
||||
[
|
||||
transformVOnce,
|
||||
|
|
|
@ -68,8 +68,8 @@ export class CodegenContext {
|
|||
options: CodegenOptions,
|
||||
) {
|
||||
const defaultOptions: Required<CodegenOptions> = {
|
||||
mode: 'function', // TODO
|
||||
prefixIdentifiers: options.mode === 'module',
|
||||
mode: 'module',
|
||||
prefixIdentifiers: true,
|
||||
sourceMap: false,
|
||||
filename: `template.vue.html`,
|
||||
scopeId: null,
|
||||
|
|
|
@ -22,7 +22,6 @@ export function genExpression(
|
|||
context: CodegenContext,
|
||||
assignment?: string,
|
||||
): CodeFragment[] {
|
||||
const { prefixIdentifiers } = context.options
|
||||
const { content, ast, isStatic, loc } = node
|
||||
|
||||
if (isStatic) {
|
||||
|
@ -30,7 +29,6 @@ export function genExpression(
|
|||
}
|
||||
|
||||
if (
|
||||
!prefixIdentifiers ||
|
||||
!node.content.trim() ||
|
||||
// there was a parsing error
|
||||
ast === false ||
|
||||
|
|
|
@ -194,7 +194,7 @@ export class TransformContext<T extends AllNode = AllNode> {
|
|||
|
||||
const defaultOptions = {
|
||||
filename: '',
|
||||
prefixIdentifiers: false,
|
||||
prefixIdentifiers: true,
|
||||
hoistStatic: false,
|
||||
hmr: false,
|
||||
cacheHandlers: false,
|
||||
|
|
Loading…
Reference in New Issue