vuejs / vue-component-compiler

Compile a single file Vue component into a CommonJS module.
MIT License
342 stars 52 forks source link

SSR optimization logic on runtime. #71

Open serkanyersen opened 6 years ago

serkanyersen commented 6 years ago

Hi there.

I'm currently using vue-component-compiler on a custom bundler I wrote. We have an internal Vue component library and we need to bundle each component separately instead of bundling everything into a single file.

I got everything else working but I'm having trouble with the SSR optimizations. As far as I understand I can only compile for SSR or CLIENT but not both at the same time.

Would it be possible to get a compiled component decide what to do on runtime? Right now SSR related pieces in the code just prints if(true). I feel like if I could get it to print if(process.env.VUE_ENV === 'server') instead, it might just work.

I'm also open to other suggestions for 1:1 mapping of .vue files to compiled .js versions.

Thank you for great work!

znck commented 6 years ago

It is possible to use @vue/component-compiler-utils, it is a lower level utility.