How to use the isExportDefaultDeclaration function from @babel/types

Find comprehensive JavaScript @babel/types.isExportDefaultDeclaration code examples handpicked from public code repositorys.

11
12
13
14
15
16
17
18
19
20
if (!path) {
  return path;
}

if (
  t.isExportDefaultDeclaration(path) ||
  (t.isExportNamedDeclaration(path) && path.has('declaration'))
) {
  path = path.get('declaration');
}
fork icon510
star icon0
watch icon3

191
192
193
194
195
196
197
198
199
200

function isExport(node) {
        return (
                t.isExportAllDeclaration(node) ||
                t.isExportDeclaration(node) ||
                t.isExportDefaultDeclaration(node) ||
                t.isExportNamedDeclaration(node) ||
                t.isExportNamespaceSpecifier(node)
        );
}
fork icon2
star icon35
watch icon2

+ 33 other calls in file

27
28
29
30
31
32
33
34
35

  if (!TSInterfaceDeclaration && t.isTSInterfaceDeclaration(node)) {
    TSInterfaceDeclaration = node
  }

  if (!ExportDefaultDeclaration && t.isExportDefaultDeclaration(node)) {
    ExportDefaultDeclaration = node
  }
})
fork icon42
star icon91
watch icon8

48
49
50
51
52
53
54
55
56
babelTraverse(ast, {
  ObjectMethod(path) {
    // 对象方法
    const parent = path.parentPath.parent;
    const name = path.node.key.name;
    if (parent && t.isExportDefaultDeclaration(parent)) {
      if (name === 'data') {
        const body = path.node.body.body;
        state.data['_statements'] = [].concat(body);
fork icon1
star icon8
watch icon2

+ 3 other calls in file

257
258
259
260
261
262
263
264
265
266
let parent = printStack[i];

while (i >= 0) {
  if (expressionStatement && t.isExpressionStatement(parent, {
    expression: node
  }) || exportDefault && t.isExportDefaultDeclaration(parent, {
    declaration: node
  }) || arrowBody && t.isArrowFunctionExpression(parent, {
    body: node
  }) || forHead && t.isForStatement(parent, {
fork icon0
star icon0
watch icon0

+ 2 other calls in file

223
224
225
226
227
228
229
230
231
232
let parent = printStack[i];

while (i >= 0) {
  if (t.isExpressionStatement(parent, {
    expression: node
  }) || considerDefaultExports && t.isExportDefaultDeclaration(parent, {
    declaration: node
  }) || considerArrow && t.isArrowFunctionExpression(parent, {
    body: node
  })) {
fork icon0
star icon0
watch icon0

91
92
93
94
95
96
97
98
99
100
let foundDeclaration = null
let foundPath = null
// 分析抽象代码语法树
this.traverse(ast, {
  enter: (path) => {
    if (!foundDeclaration && babelTypes.isExportDefaultDeclaration(path.node)) {
      if (!foundExportDefault) {
        foundExportDefault = true
        const declaration = path.node.declaration
        if (babelTypes.isObjectExpression(declaration)) {
fork icon0
star icon0
watch icon0

Other functions in @babel/types

Sorted by popularity

function icon

@babel/types.identifier is the most popular function in @babel/types (20936 examples)