@liip/esbuild-plugin-ast-vue
Version:
Esbuild plugin to parse Vue AST
45 lines • 1.37 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolvePath = resolvePath;
exports.convertErrors = convertErrors;
exports.validateDependency = validateDependency;
const node_path_1 = require("node:path");
function resolvePath(filePath) {
const [filename, query] = filePath.split('?', 2);
return { filename, dirname: (0, node_path_1.dirname)(filename), query };
}
function convertErrors(errors, filename) {
const convert = (e) => {
let location = null;
if ('loc' in e && typeof e.loc !== 'undefined') {
const start = e.loc.start;
location = {
file: filename,
namespace: '',
line: start.line + 1,
column: start.column,
length: e.loc.source.length,
lineText: e.loc.source,
suggestion: '',
};
}
return {
id: 'convertErrors',
pluginName: 'ast-vue',
text: e.message,
location,
notes: [],
detail: '',
};
};
return errors.map((e) => convert(e));
}
function validateDependency() {
try {
require.resolve('@vue/compiler-sfc');
}
catch {
throw new Error('@vue/compiler-sfc has not been installed');
}
}
//# sourceMappingURL=utils.js.map