How to use the isImportDeclaration function from @babel/types
Find comprehensive JavaScript @babel/types.isImportDeclaration code examples handpicked from public code repositorys.
GitHub: yandex/reshadow
![yandex profile picture](/yandex.png?size=40)
140 141 142 143 144 145 146 147 148 149
}); [{node: IMPORT}] = FILE.path.get('body').filter(p => { const {node} = p; return ( t.isImportDeclaration(node) && node.source.value === moduleName ); }); }
+ 29 other calls in file
GitHub: DiBuz/intergalactic
![DiBuz profile picture](/DiBuz.png?size=40)
163 164 165 166 167 168 169 170 171 172
nameHint: 'styled', }); [{ node: IMPORT }] = FILE.path.get('body').filter((p) => { const { node } = p; return t.isImportDeclaration(node) && node.source.value === moduleName; }); } if (imports[name]) return imports[name];
+ 3 other calls in file
90 91 92 93 94 95 96 97 98 99
// 覆盖ExportAllDeclaration、ExportNamedDeclaration、ImportDeclaration if ( t.isExportAllDeclaration(path.node) || t.isExportNamedDeclaration(path.node) || t.isImportDeclaration(path.node) ) { if ( path.node && path.node.source &&
4 5 6 7 8 9 10 11 12 13
const t = require('@babel/types'); const prettierFormat = require('./prettierFormat'); const addImportDeclaration = (node, specifiers, importPath) => { const { body } = node; const lastImportIndex = _.findLastIndex(body, (item) => t.isImportDeclaration(item)); const importSpecifiers = (Array.isArray(specifiers) ? specifiers : [specifiers]).map((specifier) => { return specifier.imported ? t.importSpecifier(t.identifier(specifier.local), t.identifier(specifier.imported))
+ 3 other calls in file
20 21 22 23 24 25 26 27 28 29
switch (node == null ? void 0 : node.type) { default: if (t.isModuleDeclaration(node)) { if ((t.isExportAllDeclaration(node) || t.isExportNamedDeclaration(node) || t.isImportDeclaration(node)) && node.source) { gatherNodeParts(node.source, parts); } else if ((t.isExportNamedDeclaration(node) || t.isImportDeclaration(node)) && node.specifiers && node.specifiers.length) { for (const e of node.specifiers) gatherNodeParts(e, parts); } else if ((t.isExportDefaultDeclaration(node) || t.isExportNamedDeclaration(node)) && node.declaration) { gatherNodeParts(node.declaration, parts); }
+ 16 other calls in file
GitHub: HandsomeWalker/v2r
28 29 30 31 32 33 34 35 36 37
jsAst = initState(jsAst, store); templateAst = initTemplate(templateAst, null, new Set()); const { code: jsCode } = generator( t.program( [ ...jsAst.program.body.filter((item) => t.isImportDeclaration(item)), t.functionDeclaration( t.identifier("VueTest"), [t.identifier("props")], t.blockStatement([
+ 213 other calls in file
364 365 366 367 368 369 370 371 372 373
const declaration = collectTypeDeclaration(seg); if (declaration) { state.typeDefines.push(declaration); } }); const imports = path.node.body.filter((segment) => t.isImportDeclaration(segment)); for (let i = 0; i < imports.length; i++) { const segment = path.node.body[i]; if (!t.isImportDeclaration(segment)) { continue;
+ 25 other calls in file
@babel/types.identifier is the most popular function in @babel/types (20936 examples)