Skip to content

Instantly share code, notes, and snippets.

@bwindels
Created April 27, 2021 15:46
Show Gist options
  • Select an option

  • Save bwindels/efd0a3368cb35c866e2fad0e0b0720a2 to your computer and use it in GitHub Desktop.

Select an option

Save bwindels/efd0a3368cb35c866e2fad0e0b0720a2 to your computer and use it in GitHub Desktop.
const acorn = require("acorn");
const walk = require("acorn-walk");
walk.simple(acorn.parse("const str = this.i18n`foo ${bar} haha`", {sourceType: "module"}), {
// https://github.com/estree/estree/blob/master/es2015.md#template-literals
TaggedTemplateExpression(node) {
console.log("TaggedTemplateExpression:")
console.log(JSON.stringify(node, undefined, 2));
},
ImportDeclaration(node) {
console.log("ImportDeclaration:")
console.log(JSON.stringify(node, undefined, 2));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment