elidoran / cosmos-browserify

Browserify npm modules for client side in Meteor packages
MIT License
78 stars 12 forks source link

Make the imported modules available on the server #28

Closed arunoda closed 8 years ago

arunoda commented 8 years ago

This is related to this question on FlowRouter SSR: https://github.com/kadirahq/flow-router/issues/369

So, basically he is trying to use a browserify imported React component on the server. (via FlowRouter SSR). So, it seems to have undefined.

I assume, Cosmos:Browserify does not expose components to the client. Anyway does it?

arunoda commented 8 years ago

Closing since it's answered on the original question.

elidoran commented 8 years ago

Which scope the browserify results is sent to is determined by where the file is in the app, or, the scopes specified by the package.js file in a package. So, for an app, put the file somewhere shared by both client and server and it'll be available to both. For a package, just specify both scopes in the api.addFiles() call.

The cosmos:browserify plugin doesn't pay attention to scopes at all. It just accepts files based on their name patterns and browserifies them.