Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (sfc.template) {
if (!sfc.template.content && sfc.template.src) {
// Src Imports
if (basedir) {
try {
sfc.template.content = fs.readFileSync(
path.resolve(basedir, sfc.template.src),
'utf-8'
)
} catch (e) {
console.error(e)
sfc.template.content = ''
}
}
}
res.templateAst = compile(sfc.template.content, {
comments: true
}).ast
}
return res
}
} = options;
let componentsInUsed = {};
Object.keys(components).forEach(name => {
if (!componentsInUsed[name]) {
componentsInUsed[name] = {
using: false,
declaration: components[name]
};
}
});
const {
ast,
errors
} = compileTemplate(source, {
preserveWhitespace: false,
modules: [{
preTransformNode(el, options) {
// swan doesn't support PascalCase tag name
// componentsInUsed map is hyphenated
// so transform h5 tag into hyphenated to match it
el.tag = hyphenate(el.tag);
let basicCompMap = {};
delToVueTag(el, {
basicCompMap,
componentsInUsed
});
Object.assign(componentSet, basicCompMap);
}
}]
let componentsInUsed = {};
Object.keys(components).forEach(name => {
if (!componentsInUsed[name]) {
componentsInUsed[name] = {
using: false,
declaration: components[name]
};
}
});
const {
ast,
staticRenderFns,
errors
} = compileTemplate(source, {
preserveWhitespace: false,
modules: [
{
transformNode: getMarkNode(options, componentsInUsed),
postTransformNode: getPostTrans(options)
}
]
});
const render = generate(ast, {
processFilterData: getGenData(),
isComplexExp,
isFilter,
isInFor,
getIterators
});