glimmerjs / glimmer-vm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can decompile the precompiled template

helvenk opened this issue · comments

I'm sorry that I'd like to know if the template can be decompiled? Such as the following code:

import { precompile } from '@glimmer/compiler';

const template = `<div>hello {{name}}</div>`;
const str = precompile(template);

// How to decompile the `str` to make them equal?
// decompile(str) === template  //  Can do this?

Before i do investigation, can you provide more information about why you want to do this? 🙃
Thanks!

uh, I build application with ember.js,but in some reason I lost my files accidentally under local git repository,no stage、stash or commit... Fortunately, I have built the project once with sourcemap enabled。ember.js does not provide .hbs source file except component, I'm looking for help to find out my source files.

iirc, it's possible, but there is no existing tool to do that. We have lots of file -> wireformat tests, but it's all opcodes and JSON, so I think it'd be totally possible to go the other way if someone wanted to implement that. The specific opcodes to use would be dependent on glimmer/ember-source version though

Did you checked if the bundle contains the templates as inline comments? It may depend on the build of it does. But I often noticed them when debugging.