Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (hasJSX && !hasAddNervJsImportDefaultName) {
//@fix
// node.body.unshift(
// t.importDeclaration([
// t.importDefaultSpecifier(t.identifier(nervJsImportDefaultName))
// ], t.stringLiteral(PACKAGES['nervjs']))
// )
}
if (taroImportDefaultName) {
const importTaro = toAst(`import ${taroImportDefaultName} from '${PACKAGES['@tarojs/taro-h5']}'`)
node.body.unshift(importTaro)
}
}
}
})
const generateCode = generate(ast, {
jsescOption: {
minimal: true
}
}).code
return {
code: generateCode,
ast
}
}
if (hasJSX && !hasAddNervJsImportDefaultName) {
//@fix
// node.body.unshift(
// t.importDeclaration([
// t.importDefaultSpecifier(t.identifier(nervJsImportDefaultName))
// ], t.stringLiteral(PACKAGES['nervjs']))
// )
}
if (taroImportDefaultName) {
const importTaro = toAst(`import ${taroImportDefaultName} from '${PACKAGES['@tarojs/taro-h5']}'`)
node.body.unshift(importTaro)
}
}
}
})
const generateCode = generate(ast, {
jsescOption: {
minimal: true
}
}).code
return {
code: generateCode,
ast
}
}
//@fix
//extraNodes.unshift(importNervjsNode)
}
if (tabBar) {
extraNodes.unshift(importComponentNode)
}
lastImportNode.insertAfter(extraNodes)
if (renderCallCode) {
const renderCallNode = toAst(renderCallCode)
astPath.pushContainer('body', renderCallNode)
}
}
}
})
const generateCode = generate(ast, {
jsescOption: {
minimal: true
}
}).code
return {
code: generateCode,
ast
}
}
function generateMinimalEscapeCode (ast) {
return generate(ast, {
jsescOption: {
minimal: true
}
}).code
}
//@fix
//extraNodes.unshift(importNervjsNode)
}
if (tabBar) {
extraNodes.unshift(importComponentNode)
}
lastImportNode.insertAfter(extraNodes)
if (renderCallCode) {
const renderCallNode = toAst(renderCallCode)
astPath.pushContainer('body', renderCallNode)
}
}
}
})
const generateCode = generate(ast, {
jsescOption: {
minimal: true
}
}).code
return {
code: generateCode,
ast
}
}
if (hasJSX && !hasAddNervJsImportDefaultName) {
extraNodes.unshift(importNervjsNode)
}
if (tabBar) {
extraNodes.unshift(importComponentNode)
}
lastImportNode.insertAfter(extraNodes)
if (renderCallCode) {
const renderCallNode = toAst(renderCallCode)
astPath.pushContainer('body', renderCallNode)
}
}
}
})
const generateCode = generate(ast, {
jsescOption: {
minimal: true
}
}).code
return {
code: generateCode,
ast
}
}
enter (astPath) {
const node = astPath.node
const callee = node.callee
const calleeName = callee.name
const parentPath = astPath.parentPath
if (t.isMemberExpression(callee)) {
if (callee.object.name === taroImportDefaultName && callee.property.name === 'render') {
callee.object.name = nervJsImportDefaultName
renderCallCode = generate(astPath.node).code
astPath.remove()
}
} else {
if (calleeName === setStoreFuncName) {
if (parentPath.isAssignmentExpression() ||
parentPath.isExpressionStatement() ||
parentPath.isVariableDeclarator()) {
parentPath.remove()
}
}
}
}
},
enter (astPath) {
const node = astPath.node
const callee = node.callee
const calleeName = callee.name
const parentPath = astPath.parentPath
if (t.isMemberExpression(callee)) {
if (callee.object.name === taroImportDefaultName && callee.property.name === 'render') {
callee.object.name = nervJsImportDefaultName
renderCallCode = generate(astPath.node).code
astPath.remove()
}
} else {
if (calleeName === setStoreFuncName) {
if (parentPath.isAssignmentExpression() ||
parentPath.isExpressionStatement() ||
parentPath.isVariableDeclarator()) {
parentPath.remove()
}
}
}
}
},
//@fix
//extraNodes.unshift(importNervjsNode)
}
if (tabBar) {
extraNodes.unshift(importComponentNode)
}
lastImportNode.insertAfter(extraNodes)
if (renderCallCode) {
const renderCallNode = toAst(renderCallCode)
astPath.pushContainer('body', renderCallNode)
}
}
}
})
const generateCode = generate(ast, {
jsescOption: {
minimal: true
}
}).code
return {
code: generateCode,
ast
}
}