donejs / done-component

A plugin for creating <can-component>s
https://www.npmjs.com/package/done-component
MIT License
8 stars 2 forks source link

<style> tag does not work with server side rendering #1

Closed daffl closed 9 years ago

daffl commented 9 years ago

Server side rendering does not work with .component files that have a <style> tag. A component like:

<can-component tag="pmo-home">
  <style>
    p { font-weight: bold; }
  </style>
  <template>
    <h2>{{message}}</h2>
  </template>
</can-component>

Fails with

Cannot set property 'src/home.component/style.css' of undefined
    at assetRegister (file:donejs/place-my-order/node_modules/can-ssr/lib/extension.js:56:21)
    at load.metadata.execute (file:donejs/place-my-order/node_modules/done-css/css.js:100:5)
    at linkDynamicModule (donejs/place-my-order/node_modules/steal/node_modules/systemjs/dist/system.src.js:668:32)
    at link (donejs/place-my-order/node_modules/steal/node_modules/systemjs/dist/system.src.js:528:11)
    at Object.execute (donejs/place-my-order/node_modules/steal/node_modules/systemjs/dist/system.src.js:847:11)
    at doDynamicExecute (donejs/place-my-order/node_modules/steal/node_modules/systemjs/node_modules/es6-module-loader/dist/es6-module-loader.src.js:1949:25)
    at link (donejs/place-my-order/node_modules/steal/node_modules/systemjs/node_modules/es6-module-loader/dist/es6-module-loader.src.js:1997:24)
    at doLink (donejs/place-my-order/node_modules/steal/node_modules/systemjs/node_modules/es6-module-loader/dist/es6-module-loader.src.js:1771:7)
    at updateLinkSetOnLoad (donejs/place-my-order/node_modules/steal/node_modules/systemjs/node_modules/es6-module-loader/dist/es6-module-loader.src.js:1819:18)
    at donejs/place-my-order/node_modules/steal/node_modules/systemjs/node_modules/es6-module-loader/dist/es6-module-loader.src.js:1640:11

It does work client-side.

daffl commented 9 years ago

This may or may not be related to the component not live reloading when adding or removing a <style> tag.

matthewp commented 9 years ago

I think this is a can-ssr bug. Definitely not caused by done-component. I think I ran into something similar so I'll check it out.

matthewp commented 9 years ago

I added a commit here https://github.com/canjs/can-ssr/commit/793cc85229725fb08c9c8b87c8789fc9349fe043 that fixes a related issue and might fix this as well.

matthewp commented 9 years ago

There's also a bug where using a <style> tag doesn't result in server side rendering of the css in dev (some times) and this is a done-component bug.