]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
wip: remove unnecessary inlinePropsIdentifier option 2532/head
authorEvan You <yyx990803@gmail.com>
Wed, 11 Nov 2020 15:36:59 +0000 (10:36 -0500)
committerEvan You <yyx990803@gmail.com>
Wed, 11 Nov 2020 15:36:59 +0000 (10:36 -0500)
packages/compiler-core/src/codegen.ts
packages/compiler-core/src/options.ts
packages/compiler-core/src/transform.ts
packages/compiler-core/src/transforms/transformExpression.ts
packages/compiler-sfc/src/compileScript.ts

index 299106fde3b986c08cc33a4ad83fa1f56d44a470..9e58d751da96d2c956a1edb580f1cdadd45cf102 100644 (file)
@@ -66,10 +66,7 @@ export interface CodegenResult {
 }
 
 export interface CodegenContext
-  extends Omit<
-      Required<CodegenOptions>,
-      'bindingMetadata' | 'inline' | 'inlinePropsIdentifier'
-    > {
+  extends Omit<Required<CodegenOptions>, 'bindingMetadata' | 'inline'> {
   source: string
   code: string
   line: number
index 5f0f06dbea4b692f07ed33cdf9e67c77dd86efad..37641a458b9abe680f4947c7ab72e3cc1625d35d 100644 (file)
@@ -91,10 +91,6 @@ interface SharedTransformCodegenOptions {
    * This allows the function to directly access setup() local bindings.
    */
   inline?: boolean
-  /**
-   * Identifier for props in setup() inline mode.
-   */
-  inlinePropsIdentifier?: string
 }
 
 export interface TransformOptions extends SharedTransformCodegenOptions {
index aab29d000acef0257297d56b7053f3dc24df56c8..c3a37c9f7157d8b69a98d4741bdaf47bd03d1a6f 100644 (file)
@@ -125,7 +125,6 @@ export function createTransformContext(
     ssrCssVars = ``,
     bindingMetadata = EMPTY_OBJ,
     inline = false,
-    inlinePropsIdentifier = `$props`,
     onError = defaultOnError
   }: TransformOptions
 ): TransformContext {
@@ -145,7 +144,6 @@ export function createTransformContext(
     ssrCssVars,
     bindingMetadata,
     inline,
-    inlinePropsIdentifier,
     onError,
 
     // state
index 52a35538e9ce2db1803f8edbf79a2c5505f0de6b..924d217a893a548481894c2e5933ef816e40649b 100644 (file)
@@ -98,14 +98,12 @@ export function processExpression(
     return node
   }
 
-  const { inline, inlinePropsIdentifier, bindingMetadata } = context
+  const { inline, bindingMetadata } = context
   const prefix = (raw: string) => {
     const type = hasOwn(bindingMetadata, raw) && bindingMetadata[raw]
     if (inline) {
       // setup inline mode
-      if (type === 'props') {
-        return `${inlinePropsIdentifier}.${raw}`
-      } else if (type === 'setup') {
+      if (type === 'setup') {
         return `${context.helperString(UNREF)}(${raw})`
       } else if (type === 'component-import') {
         return raw
index 085839415ff7769b3912a3675d2e2e1a861992cc..8978196119882d7e86e75397185bc355ba01c56d 100644 (file)
@@ -405,20 +405,16 @@ export function compileScript(
       )
     }
 
-    // parse the signature to extract the identifiers users are assigning to
-    // the arguments. props identifier is always needed for inline mode
-    // template compilation
-    const params = ((signatureAST as ExpressionStatement)
-      .expression as ArrowFunctionExpression).params
-    if (params[0] && params[0].type === 'Identifier') {
-      propsASTNode = params[0]
-      propsIdentifier = propsASTNode.name
-    }
-
     if (isTS) {
       // <script setup="xxx" lang="ts">
-      // additional identifiers are needed for TS in order to match declared
-      // types
+      // parse the signature to extract the identifiers users are assigning to
+      // the arguments. They are needed for matching type delcarations.
+      const params = ((signatureAST as ExpressionStatement)
+        .expression as ArrowFunctionExpression).params
+      if (params[0] && params[0].type === 'Identifier') {
+        propsASTNode = params[0]
+        propsIdentifier = propsASTNode.name
+      }
       if (params[1] && params[1].type === 'ObjectPattern') {
         setupCtxASTNode = params[1]
         for (const p of params[1].properties) {
@@ -701,7 +697,7 @@ export function compileScript(
   }
 
   // 7. finalize setup argument signature.
-  let args = options.inlineTemplate ? `$props` : ``
+  let args = ``
   if (isTS) {
     if (slotsType === 'Slots') {
       helperImports.add('Slots')
@@ -787,7 +783,6 @@ export function compileScript(
         source: sfc.template.content,
         compilerOptions: {
           inline: true,
-          inlinePropsIdentifier: propsIdentifier,
           bindingMetadata
         }
         // TODO source map