Skip to content

Commit

Permalink
build(client): fix SB emotion conflicts
Browse files Browse the repository at this point in the history
Storybook uses emotion v10 while theme-ui uses v11, causing conflicts
(see system-ui/theme-ui#1530). Work around this by aliasing emotion
packages to the v11 equivalents inside storybook's manager.
  • Loading branch information
ethanwu10 committed Mar 28, 2021
1 parent 9100cd1 commit b3aedfc
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
22 changes: 22 additions & 0 deletions packages/client/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
const path = require('path')

// Workaround for conflicting emotion versions (SB v10 vs theme-ui v11)
// https://github.com/storybookjs/storybook/pull/13300#issuecomment-783268111
const rootModules = path.resolve(__dirname, '../../../node_modules')

const updateEmotionAliases = config => ({
...config,
resolve: {
...config.resolve,
alias: {
...config.resolve.alias,
'@emotion/core': path.join(rootModules, '@emotion/react'),
'@emotion/styled': path.join(rootModules, '@emotion/styled'),
'@emotion/styled-base': path.join(rootModules, '@emotion/styled'),
'emotion-theming': path.join(rootModules, '@emotion/react'),
},
},
})

module.exports = {
stories: ['../src/**/*.stories.tsx'],
core: {
Expand All @@ -21,4 +41,6 @@ module.exports = {
},
},
},
webpackManager: updateEmotionAliases,
webpackFinal: updateEmotionAliases,
}
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4339,21 +4339,21 @@
"@xtuc/long" "4.2.2"

"@webpack-cli/configtest@^1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@webpack-cli/configtest/-/configtest-1.0.1.tgz#241aecfbdc715eee96bed447ed402e12ec171935"
integrity sha512-B+4uBUYhpzDXmwuo3V9yBH6cISwxEI4J+NO5ggDaGEEHb0osY/R7MzeKc0bHURXQuZjMM4qD+bSJCKIuI3eNBQ==
version "1.0.2"
resolved "https://registry.yarnpkg.com/@webpack-cli/configtest/-/configtest-1.0.2.tgz#2a20812bfb3a2ebb0b27ee26a52eeb3e3f000836"
integrity sha512-3OBzV2fBGZ5TBfdW50cha1lHDVf9vlvRXnjpVbJBa20pSZQaSkMJZiwA8V2vD9ogyeXn8nU5s5A6mHyf5jhMzA==

"@webpack-cli/info@^1.2.2":
version "1.2.2"
resolved "https://registry.yarnpkg.com/@webpack-cli/info/-/info-1.2.2.tgz#ef3c0cd947a1fa083e174a59cb74e0b6195c236c"
integrity sha512-5U9kUJHnwU+FhKH4PWGZuBC1hTEPYyxGSL5jjoBI96Gx8qcYJGOikpiIpFoTq8mmgX3im2zAo2wanv/alD74KQ==
version "1.2.3"
resolved "https://registry.yarnpkg.com/@webpack-cli/info/-/info-1.2.3.tgz#ef819d10ace2976b6d134c7c823a3e79ee31a92c"
integrity sha512-lLek3/T7u40lTqzCGpC6CAbY6+vXhdhmwFRxZLMnRm6/sIF/7qMpT8MocXCRQfz0JAh63wpbXLMnsQ5162WS7Q==
dependencies:
envinfo "^7.7.3"

"@webpack-cli/serve@^1.3.0":
version "1.3.0"
resolved "https://registry.yarnpkg.com/@webpack-cli/serve/-/serve-1.3.0.tgz#2730c770f5f1f132767c63dcaaa4ec28f8c56a6c"
integrity sha512-k2p2VrONcYVX1wRRrf0f3X2VGltLWcv+JzXRBDmvCxGlCeESx4OXw91TsWeKOkp784uNoVQo313vxJFHXPPwfw==
version "1.3.1"
resolved "https://registry.yarnpkg.com/@webpack-cli/serve/-/serve-1.3.1.tgz#911d1b3ff4a843304b9c3bacf67bb34672418441"
integrity sha512-0qXvpeYO6vaNoRBI52/UsbcaBydJCggoBBnIo/ovQQdn6fug0BgwsjorV1hVS7fMqGVTZGcVxv8334gjmbj5hw==

"@xtuc/ieee754@^1.2.0":
version "1.2.0"
Expand Down

0 comments on commit b3aedfc

Please sign in to comment.