How to use the importDefaultSpecifier function from babel-types

Find comprehensive JavaScript babel-types.importDefaultSpecifier code examples handpicked from public code repositorys.

61
62
63
64
65
66
67
68
69
70
    idx = index;
  }
});
if (!defaultSpecifier) {
  node.specifiers.unshift(
    t.importDefaultSpecifier(t.identifier(nervJsImportDefaultName))
  );
} else {
  taroImportDefaultName = defaultSpecifier;
  node.specifiers[idx].local.name = nervJsImportDefaultName;
fork icon5
star icon49
watch icon4

+ 2 other calls in file

8
9
10
11
12
13
14
15
16
17
let node = path.node
let specifiers = node.specifiers
let source = node.source
if (state.opts.library === source.value && t.isImportDefaultSpecifier(specifiers[0])) {
  let declaration = specifiers.map(specifier => {
    let importDefaultSpecifier = t.importDefaultSpecifier(specifier.local)
    t.importDeclaration([importDefaultSpecifier], t.stringLiteral(`${source.value}/${specifier.imported.name}`))
  })
  path.replaceWithMultiple(declaration)
}
fork icon3
star icon16
watch icon2

57
58
59
60
61
62
63
64
65
66
// generate codes
let paramIdx = 0
dependencies.forEach((dependence, idx) => {
  if (!ignoreDependencies.has(dependence) && paramIdx < parameters.length) {
    programBody.push(t.importDeclaration([
        t.importDefaultSpecifier(t.identifier(parameters[paramIdx]))
      ],
      t.stringLiteral(dependence)
    ))
    paramIdx++
fork icon1
star icon7
watch icon2

+ 6 other calls in file

30
31
32
33
34
35
36
37
38
39
path.parent.body.splice(
  node_i,
  0,
  t.importDeclaration(
    [
      t.importDefaultSpecifier(ns.local)
    ],
    t.stringLiteral(
      `${prefix}${encodeURIComponent(specifier)}&namespace`
    )
fork icon1
star icon6
watch icon2

+ 19 other calls in file

16
17
18
19
20
21
22
23
24
25
const isAll = types.isImportNamespaceSpecifier(specifiers[0]);

if (isBelong && !isDefault && !isAll) {
  const newImports = specifiers.map(specifier => {
    const stringLiteral = types.stringLiteral(`${libraryName}/lib/${specifier.local.name}`);
    const newSpecifier = types.importDefaultSpecifier(specifier.local);

    return types.importDeclaration([newSpecifier], stringLiteral);
  })
  path.replaceWithMultiple(newImports);
fork icon0
star icon3
watch icon2

+ 3 other calls in file

39
40
41
42
43
44
45
46
47
48
  typeof identifier === 'string' ? identifier : identifier[0]
);
let specifier;

if (isDefault) {
  specifier = types.importDefaultSpecifier(localIdentifier);
} else if (isNamespace) {
  specifier = types.importNamespaceSpecifier(localIdentifier);
} else {
  specifier = types.importSpecifier(
fork icon0
star icon2
watch icon1

+ 7 other calls in file

100
101
102
103
104
105
106
107
108
109
  taroImportDefaultName = specifier.local.name
  specifier.local.name = reactImportDefaultName
} else if (!hasAddReactImportDefaultName) {
  hasAddReactImportDefaultName = true
  node.specifiers.unshift(
    t.importDefaultSpecifier(t.identifier(reactImportDefaultName))
  )
}
const taroApisSpecifiers = []
specifiers.forEach((item, index) => {
fork icon0
star icon2
watch icon0

422
423
424
425
426
427
428
429
430
431
  specifier.local.name = nervJsImportDefaultName
} else if (!hasAddNervJsImportDefaultName) {
  hasAddNervJsImportDefaultName = true
  //@fix
  // node.specifiers.unshift(
  //   t.importDefaultSpecifier(t.identifier(nervJsImportDefaultName))
  // )
}
const taroApisSpecifiers = []
const deletedIdx = []
fork icon0
star icon0
watch icon0

+ 7 other calls in file

138
139
140
141
142
143
144
145
146
147

var replace = transform(opts.transform, importName, matches);

var newImportSpecifier = (opts.skipDefaultConversion)
    ? memberImport
    : types.importDefaultSpecifier(types.identifier(memberImport.local.name));
transforms.push(types.importDeclaration(
    [newImportSpecifier],
    types.stringLiteral(replace)
));
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 (4076 examples)