vuejs / vue-component-compiler

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

Move HEAD assignment for SSR compatibility (assembler) #85

Open peremp opened 5 years ago

peremp commented 5 years ago

When you import an SFC on Nuxt, it throws the following error even if the Component is SSR ready: Reason: ReferenceError: document is not defined

This error is fixed by moving this https://github.com/vuejs/vue-component-compiler/blob/c4bcd403a182059a9c20396451c33fc0a888e9ac/src/assembler.ts#L91

inside the addStyle function https://github.com/vuejs/vue-component-compiler/blob/c4bcd403a182059a9c20396451c33fc0a888e9ac/src/assembler.ts#L97

I cannot see any drawback of doing that, but you know better than me so, could that be done?