How to use the ImportDeclaration function from babel-types
Find comprehensive JavaScript babel-types.ImportDeclaration code examples handpicked from public code repositorys.
GitHub: noahlam/practice-truth
8 9 10 11 12 13 14 15 16 17
ImportDeclaration(path, _ref = {opts:{}}){ const specifiers = path.node.specifiers; const source = path.node.source; if (!t.isImportDefaultSpecifier(specifiers[0]) ) { var declarations = specifiers.map((specifier, i) => { return t.ImportDeclaration( [t.importDefaultSpecifier(specifier.local)], t.StringLiteral(`${source.value}/${specifier.local.name}`) ) })
64
68
2
193 194 195 196 197 198 199 200 201 202
// Create a AST object for `Program` that includes the imports and function // and returns it along with the name of the function so it can be written to // a file. typeImports = _.uniq(typeImports).map(function (name) { var importStatement = t.ImportDeclaration( [t.ImportSpecifier(t.Identifier(name), t.Identifier(name))], t.StringLiteral('../types/' + name) ) importStatement.importKind = 'type'
4
9
2
+ 29 other calls in file
5 6 7 8 9 10 11 12 13 14
ImportDeclaration(path, _ref = {opts:{}}){ const specifiers = path.node.specifiers; const source = path.node.source; if (!t.isImportDefaultSpecifier(specifiers[0]) ) { var declarations = specifiers.map((specifier) => { //遍历 uniq extend flatten cloneDeep return t.ImportDeclaration( //创建importImportDeclaration节点 [t.importDefaultSpecifier(specifier.local)], t.StringLiteral(`${source.value}/${specifier.local.name}`) ) })
2
11
2
8 9 10 11 12 13 14 15 16 17
// if ( // state.opts.libraryName === source.value && // !types.isImportDefaultSpecifier(specifiers[0]) // ) { // const declarations = specifiers.map((specifiers, index) => { // return types.ImportDeclaration( // [types.importDefaultSpecifier(specifiers.local)], // types.stringLiteral(`${source.value}/${specifiers.local.name}`) // ) // })
0
0
0
babel-types.identifier is the most popular function in babel-types (4076 examples)