vue icon indicating copy to clipboard operation
vue copied to clipboard

Vue.compile should return the errors which happens during compilation even in prod env

Open jbouzekri opened this issue 5 years ago • 5 comments

What problem does this feature solve?

I am building a VueJS frontend where templates are coming from a backend where end users contributed them in a CMS or something else. VueJS is bundled with esm in order to have the Vue.compile method.

When I run Vue.compile with the template string coming from the backend, I have no way to know if a compilation error occured in order to display a message to the user. In development I just have the warn messages in the console.

What does the proposed API look like?

Vue.compile could return an error boolean in an attribute or an array of all errors that occured during compilation.

jbouzekri avatar Jul 06 '18 19:07 jbouzekri

Vue already does that. If it's failing at some specific scenario it shouldn't be failing at, please provide a repro

posva avatar Jul 06 '18 19:07 posva

@posva : I don't think it does. Vue.compile just returns an object like this :

{
    render: function() { .... },
    staticRenderFns: []
}

There is no indication that compilation had error. Just the warn message in dev environment.

jbouzekri avatar Jul 06 '18 20:07 jbouzekri

oh, indeed the errors are not returned as I thought

posva avatar Jul 06 '18 20:07 posva

Was this every addressed?, or is there a way to detect compilation errors, namely more than oen parent node?

DelfsEngineering avatar Oct 13 '20 03:10 DelfsEngineering

I just got bit by this, loading up templates that I $mount().$el.outerHTML to get the rendered output of for pasting templated data into emails.

Is there no method for obtaining the actual errors, Vue itself must do it somehow i would assume it uses the same .compile to compile the inline templates. I had to paste the template into a mockup to get the error message.

TrendyTim avatar Jan 17 '22 06:01 TrendyTim