Allow ability to set default compilerOptions when compiling templates in the browser.
What problem does this feature solve?
I need to preserve whitespace when compiling templates in the browser. I have to manually set the compiler option everytime I call createApp.
What does the proposed API look like?
Unsure of the best api but it should be pretty simple.
Something like Vue.default.config.compilerOptions.whitespace = 'preserve'
It's a design principle that apps are not influenced b any global settings, so that potential other apps on the page dnt mess with each other.
You could solve your problem trivially by writing a small wrapper function around createApp that adds that config each time you use it instead of creatApp itself.
I agree with your statement, but I dont think a framework should be influencing my design choices. What do you think about some kind callback or event handler to interact with the instance returned from createApp()?
This is my solution
window.Vue = Object.create(Vue);
Vue.createApp = function(...args){
var app = this.__proto__.createApp(...args);
app.config.compilerOptions.whitespace = 'preserve';
return app;
}
I dont think a framework should be influencing my design choices
That's pretty much what a framework does: it sets a frame in which you can design as you please, but only within the boundaries set by the framework's APIs.
So yes, a framework will be influencing your design choices by its very nature.
Point taken.
I should have expressed my thoughts a bit different. In relation to this specific issue. Vue by default handles whitespace differently to browsers and there is no other way to change this other than coming up with a hacky work around. I want to make the design choice of being able change global variable in the vue framework with the purpose of changing how other app on page work.
On a separate note. Do you think my solution will cause any problems? Can you see any issues with it?