mirror of
https://github.com/vuejs/babel-plugin-jsx.git
synced 2024-11-15 08:19:16 +08:00
refactor: simplify options
This commit is contained in:
parent
ed27b2bc8f
commit
0654b73e90
@ -3,18 +3,14 @@ import { parseExpression } from '@babel/parser';
|
|||||||
// @ts-expect-error no dts
|
// @ts-expect-error no dts
|
||||||
import typescript from '@babel/plugin-syntax-typescript';
|
import typescript from '@babel/plugin-syntax-typescript';
|
||||||
import {
|
import {
|
||||||
type SFCScriptCompileOptions,
|
|
||||||
type SimpleTypeResolveContext,
|
type SimpleTypeResolveContext,
|
||||||
|
type SimpleTypeResolveOptions,
|
||||||
extractRuntimeEmits,
|
extractRuntimeEmits,
|
||||||
extractRuntimeProps,
|
extractRuntimeProps,
|
||||||
} from '@vue/compiler-sfc';
|
} from '@vue/compiler-sfc';
|
||||||
import { codeFrameColumns } from '@babel/code-frame';
|
import { codeFrameColumns } from '@babel/code-frame';
|
||||||
import { addNamed } from '@babel/helper-module-imports';
|
import { addNamed } from '@babel/helper-module-imports';
|
||||||
|
|
||||||
export interface Options {
|
|
||||||
compileOptions?: SFCScriptCompileOptions;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getTypeAnnotation(node: BabelCore.types.Node) {
|
function getTypeAnnotation(node: BabelCore.types.Node) {
|
||||||
if (
|
if (
|
||||||
'typeAnnotation' in node &&
|
'typeAnnotation' in node &&
|
||||||
@ -27,7 +23,7 @@ function getTypeAnnotation(node: BabelCore.types.Node) {
|
|||||||
|
|
||||||
export default ({
|
export default ({
|
||||||
types: t,
|
types: t,
|
||||||
}: typeof BabelCore): BabelCore.PluginObj<Options> => {
|
}: typeof BabelCore): BabelCore.PluginObj<SimpleTypeResolveOptions> => {
|
||||||
let ctx: SimpleTypeResolveContext | undefined;
|
let ctx: SimpleTypeResolveContext | undefined;
|
||||||
let helpers: Set<string> | undefined;
|
let helpers: Set<string> | undefined;
|
||||||
|
|
||||||
@ -89,7 +85,7 @@ export default ({
|
|||||||
ctx = {
|
ctx = {
|
||||||
filename: filename,
|
filename: filename,
|
||||||
source: file.code,
|
source: file.code,
|
||||||
options: this.compileOptions || {},
|
options: this || {},
|
||||||
ast: file.ast.program.body,
|
ast: file.ast.program.body,
|
||||||
error(msg, node) {
|
error(msg, node) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
@ -115,7 +111,6 @@ export default ({
|
|||||||
getString(node) {
|
getString(node) {
|
||||||
return file.code.slice(node.start!, node.end!);
|
return file.code.slice(node.start!, node.end!);
|
||||||
},
|
},
|
||||||
bindingMetadata: Object.create(null),
|
|
||||||
propsTypeDecl: undefined,
|
propsTypeDecl: undefined,
|
||||||
propsRuntimeDefaults: undefined,
|
propsRuntimeDefaults: undefined,
|
||||||
propsDestructuredBindings: {},
|
propsDestructuredBindings: {},
|
||||||
|
Loading…
Reference in New Issue
Block a user