Closed oleast closed 4 years ago
You're absolutely correct! The "culprit" is the target: web
of the file webpack.config.js
, meaning Webpack is packing our module to use in browsers only.
Luckily, Webpack accepts several configs from the same file!
I'll look into it, but adding a config for SSR (i.e. node) should do the trick. Do you have a not-too-large SSR-project I can test it on?
I think the most simple way to test it is to create a simple next app, just as you would create-react-app
.
npx create-next-app <project-name>
cd <project-name>
yarn add @dotkomonline/design-system
yarn dev
Then add the button to the included component and then reload the page
My understanding of this is that the package should not be built with webpack.
Webpack should be used in the project that uses the design system, not to build the files here. Adding target: node
will just make it impossible to use the project in a browser.
I can't really find any other libraries that build their project with webpack?
Describe the bug It is not possible to use the design system in project using server-side rendering. Components can not even be imported from the project, since importing relies on the
window
to register things.To Reproduce Steps to reproduce the behavior:
node
, e.g.Will result in an error like this:
Expected behavior I expect the package to be usable when using server-side rendering like in
onlineweb-frontend
or nextjs projects.Additional context This comes from building the project with webpack, which we maybe should not do?