vue
vue copied to clipboard
Vue.compile should return the errors which happens during compilation even in prod env
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.
Vue already does that. If it's failing at some specific scenario it shouldn't be failing at, please provide a repro
@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.
oh, indeed the errors are not returned as I thought
Was this every addressed?, or is there a way to detect compilation errors, namely more than oen parent node?
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.