Khan / aphrodite

Framework-agnostic CSS-in-JS with support for server-side rendering, browser prefixing, and minimum CSS generation
5.34k stars 188 forks source link

Working with linked packages #129

Open msokk opened 8 years ago

msokk commented 8 years ago

Hi,

I hit into one little snag when setting it up. We have split our app into private npm packages and in development we are running everything with symlinks (npm link).

Given that this package uses module scope (https://github.com/Khan/aphrodite/blob/master/src/inject.js#L105), it's not possible to have multiple dependency declarations of this package as the module variables are cached separately. For example if there is a generic server package and a project package, with both declaring aphrodite in package.json the inject.js modules will differ, running into Cannot automatically buffer without a document flow and causing the server to crash. In production the dependency tree is deduped and there is one instance of the aphrodite package.

One possible option would be to break variables out of module scope into global/window. I wonder if fixing this would be in the scope of the project? We have a workaround of importing aphrodite through common utility package to prevent duplicates.

kentcdodds commented 8 years ago

Hi there. Was this submitted by mistake? What is this issue for?

msokk commented 8 years ago

Sorry, I posted the issue description now, I managed to somehow ctrl+enter submit it emptily.

omerzach commented 7 years ago

I think we have this same issue—we're using npm link with private repos (via Lerna) and getting the Cannot automatically buffer without a document despite (I believe) doing server-side rendering like the examples show.

zaklampert commented 6 years ago

+1, same issue here using npm link and importing a custom component library to a server-rendered app