-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow Webpack 2 #637
Allow Webpack 2 #637
Conversation
Increase allowable webpack range, for folks using webpack 2, now webpack can be deduped in most cases so the users chosen version is used. related: storybookjs#556
I just checked and this is working pretty great with CRA setup too. |
Actually in that case it uses Webpack 1 behind the scene. (Since CRA uses Webpack 1 and even beta versions are resolved by default) When we updated to Webpack 2 by force it gives us few errors. We may need to change our default config as well.
|
What's the status of this? |
It's probably tricky, because a single configuration can't cover both webpack versions? |
Most probably you’ll need to detect Webpack version and use appropriate config because they aren’t always compatible and Webpack 2 has validation that yells at valid Webpack 1 configs. We do that in Styleguidist and it works well: https://github.com/styleguidist/react-styleguidist/blob/next/scripts/make-webpack-config.js |
I'd love to see this happen. The divide between webpack 1 and webpack 2 is so large at this point that it requires maintaining two separate configs. I regularly spend a few hours a week just tracking down weird webpack issues with storybooks since my app is on webpack 2 and I can't share any of the configs at this point. The approach above seems like the best bet given the wide distribution of storybooks and the fact that it's likely to take months for everyone to fully migrate to webpack 2. Anything I can do to help? |
Doubling down on what @gabeweaver said. Anything I could do to help move this forward? |
Is there any news on this? |
I fiddled a bit in https://github.com/romeovs/react-storybook At least with the changes in https://github.com/romeovs/react-storybook there's no more webpack errors 👍 |
@arunoda could we get some attention on this issue? With more and more projects adopting webpack 2, this means that it will become more and more common to have to maintain a duplicate webpack 1 config for storybook only. |
i'm having the same scenario. i can't wait for this to get fixed, so my interim solution is deep renaming keys: https://runkit.com/587e7a68a1e7580014cd2541/589b3097b360a100148838fe
|
also, for what it's worth, i ended up doing this to get it to work: // .storybook/webpack.config.js
const renameKeys = require('deep-rename-keys')
const baseWebpack = require('base-webpack')() // this is my own custom package with base webpack config
const storybookConfig = require('@kadira/storybook/dist/server/config/defaults/webpack.config.js')
module.exports = function (config, env) {
const webpackConfig = storybookConfig(config, env)
// add additional aliases to react-storybook's initial webpack config. i'm doing this because
// i'm using 'preact' and need to resolve.alias react & react-dom to preact-compat
for (alias in baseWebpack.resolve.alias) {
webpackConfig.resolve.alias[alias] = baseWebpack.resolve.alias[alias]
}
// remove unneeded keys
delete webpackConfig.devtool
delete webpackConfig.plugins['OccurrenceOrderPlugin']
delete webpackConfig.postcss // this i need to figure out :/
delete webpackConfig.resolve.extensions
delete webpackConfig.resolve.fallback
// store plugins in a temporary object, so renameKeys doesnt screw
// up the paths
const webpackPlugins = webpackConfig.plugins
// rename webpack config keys for webpack 2 support until react-storybook
// supports this out of the box
const transformToWebpack2 = function (key) {
// 'loaders' and 'loader' i commented out since theres now interop support for these
// if (key === 'loaders') return 'rules'
// if (key === 'loader') return 'use'
if (key === 'query') return 'options'
if (key === 'modulesDirectories') return 'modules'
return key
}
const transformedWebpack = renameKeys(webpackConfig, transformToWebpack2)
transformedWebpack.plugins = webpackPlugins
return transformedWebpack
} |
@moimikey :-O - we also use a few features from webpack 2 however that are not easily translatable into a webpack 1 world - @arunoda it seems there are quite a few people stranded with workarounds - would you have a look at https://github.com/romeovs/react-storybook to see if this is something we can merge or adapt to get to a solution, please? |
👍 for this issue would love to see support |
I found one issue with @romeovs fork otherwise it worked well for me. Would be helpful to get these merged. A bit odd that I've got to check in the 'dist' folders to get it to work with other repos. Guessing because only the 'official' publish to NPM will run the prepublish script. |
We have a similar workaround that is independent of the webpack version and could potentially go directly into master - see https://github.com/canva/react-storybook/commit/4bc2435109c46c35c76f8a81fb9547b16d939648 /cc @WearyMonkey |
@arunoda 👋 What would it take to get the Webpack 2 upgrade merged? It looks like this PR's pointing to an old beta release of Webpack 2 – I'd be happy to open a new one targeting the latest stable release of Webpack 2, if that would be helpful. |
I use my own webpack config. If I could simply make storybook use webpack 2 that I installed, nothing would need to be converted. For the interim could storybook simply use webpack 2 if it's already installed. people using it would likely have their own configs. Changing this would easily make this work for those who already migrated, while allowing others to stay on webpack 1 until a better plan is laid out. |
Please consider releasing a major version of storybook with Webpack2 support. This will avoid users with custom Webpack configuration to break unnecessarily. |
@arunoda is there anything we can do to help to get this sorted? I am happy to throw some time at it. We are currently running on a fork because we thought it would be a matter of days to get at least any of the solutions here merged, however now three months later I am getting a bit nervous :) |
For reference, we have a fork of Canva's fork over at https://github.com/hammerandchisel/react-storybook that seems to work well enough for us in the meantime. |
I'm running off a fork too (steckel). Had to build the lib files to install via github so I forked the fork here: https://github.com/ntucker/react-storybook |
looking forward for the option of webpack 2 |
What is the status of this change? Is there anything blocking it? |
I guess the reason is #731 (comment) If someone wants to fork it, merge this and maintain it 👍 |
@arunoda would you be happy to give some people here contrib access, so we can keep this awesome tool alive? |
oh god, it was just presented on the recent React conf and now it's dead? even in the current state I found |
@mnquintana sounds great! Unfortunately @arunoda has not answered, yet, I am holding off for another few days before sending an email. Would be great if we could jointly continue this project! |
I will add webpack 2 support ASAP! |
So this is for subscribers on this PR: Here's my progress: I've done all the work to support webpack 2 on here. I'd like to thank @jquense for this PR. I hope it's understandable this PR will not get merged, as it does not solve the problem, as @arunoda has commented. I'll keep you all updated on the progress! Thank you all! |
@ndelangen Thank you! We appreciate it. |
So don't feel bad or like this isn't going to happen, because it's going to happen SOON! I'm closing these PR because they will not be merged, because I'm doing them all in 1 swoop. |
Many thanks to everyone involved. Peace!
…On Apr 1, 2017 4:17 PM, "Norbert de Langen" ***@***.***> wrote:
So don't feel bad or like this isn't going to happen, because it's going
to happen SOON!
I'm closing these PR because they will not be merged, because I'm doing
them all in 1 swoop.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#637 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAer-YuzLg95N1eR1nizPBm1enCtTdEIks5rrtr9gaJpZM4LCmf5>
.
|
I'm only just now finding this thread. I wish I would have seen it a lot earlier today as it would have saved me a lot of time and headaches trying to add Storybook to my Webpack 2 build. I really want to use Storybook, but I dread the thought of having to re-write my config in webpack 1 just to do it... I'd really appreciate any update that you can give on the status of Webpack 2 integration. |
@domwashburn Im using my webpack2 config right now with this fork ntucker/react-storybook#steckel/webpack-2-compatible |
Thanks @dozoisch! That's going to be a huge help, hopefully Webpack 2 support can be integrated into Storybook soon :) |
I updated my fork to include some needed fixes for webpack 2 support: https://github.com/ntucker/react-storybook/commits/steckel/webpack-2-compatible (commit here: ntucker@d01b097) @ndelangen You might consider supporting resolveLoader and custom module.rules like I did here: ntucker@d01b097 as my heavily customized webpack wouldn't work without such things. |
@ntucker what is the recommended way of consuming your fork? Install the older version via npm then copy your dist folder somewhere? |
@ntucker are you planning to make a pull-request for your updates around webpack 2? |
@row1 yarn add @kadira/storybook@git+ssh://[email protected]/ntucker/react-storybook#steckel/webpack-2-compatible |
@creaux No plans for a PR. The maintainers are already working toward a release with compatibility. However, since they use a monorepo one cannot install via the git method so my repo is still quite useful. |
@ndelangen so what came of this? is react-storybook now compatible with webpack 2? |
@Pau1fitz yep, 3.x was recently released; see the changelog and docs for more info. |
Increase allowable webpack range, for folks using webpack 2, now webpack can be deduped in most cases so the users chosen version is used. This may require that webpack be specified in devDeps as well if you want to test against v1 only
related: #556