Skip to content

Commit

Permalink
Merge pull request #55 from patricklx/improve-ast-parse
Browse files Browse the repository at this point in the history
replace babel.parse with babel.template.expression.ast
  • Loading branch information
ef4 authored May 10, 2024
2 parents f6fbc57 + d5332ed commit 2f8418d
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,13 +479,7 @@ function insertCompiledTemplate<EnvSpecificOptions>(
precompileResultString = opts.compiler.precompile(template, options);
}

let precompileResultAST = babel.parse(`var precompileResult = ${precompileResultString}; `, {
babelrc: false,
configFile: false,
}) as t.File;

let templateExpression = (precompileResultAST.program.body[0] as t.VariableDeclaration)
.declarations[0].init as t.Expression;
let templateExpression = babel.template.expression.ast(precompileResultString);

t.addComment(
templateExpression,
Expand Down

0 comments on commit 2f8418d

Please sign in to comment.