glimmerjs / glimmer-vm

MIT License
1.13k stars 190 forks source link

Can decompile the precompiled template #1443

Open helvenk opened 12 months ago

helvenk commented 12 months ago

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?
NullVoxPopuli commented 12 months ago

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

helvenk commented 12 months ago

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.

NullVoxPopuli commented 12 months ago

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

jelhan commented 6 months ago

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.