AssignmentExpression()

in packages/build-plugin-alt/src/babelPluginMeta.ts [34:62]


  AssignmentExpression(path, pass) {
    const left = path.node.left;
    if (BabelTypes.isMemberExpression(left) && BabelTypes.isIdentifier(left.object) && left.object.name === pass.declarationName) {
      const property = left.property;
      if (
        (BabelTypes.isIdentifier(property) && property.name === 'pluginName') ||
        (BabelTypes.isStringLiteral(property) && property.value === 'pluginName')
      ) {
        const meta = pass.meta;
        pass.cache.pluginNameAssignmentExists = true;
        if (meta?.pluginName) {
          path.node.right = BabelTypes.stringLiteral(meta.pluginName);
          addInfoComment(path.node);
        }
      }
      if (
        (BabelTypes.isIdentifier(property) && property.name === 'meta') ||
        (BabelTypes.isStringLiteral(property) && property.value === 'meta')
      ) {
        const meta = pass.meta;
        pass.cache.metaAssignmentExists = true;
        if (meta?.meta) {
          const generateAst = template(`const a = ${JSON.stringify(meta.meta)}`)() as BabelTypes.VariableDeclaration;
          path.node.right = generateAst.declarations[0].init;
          addInfoComment(path.node);
        }
      }
    }
  }