storybook: framework-preset-vue requires `babel-preset-vue` but does not depend on it
Bug or support request summary
When using SB in a vue app, this line runs:
I’m not sure if it should even be running that line, as this project has a babel.config.js which contains:
module.exports = {
presets: ["@vue/app"]
};
Steps to reproduce
npx -p @vue/cli vue create --preset hichroma/vue-preset-learnstorybook taskbox
cd taskbox
npx -p @storybook/cli@rc sb init
yarn storybook
You’ll see:
ERR! Error: Cannot find module 'babel-preset-vue'
ERR! at Function.Module._resolveFilename (module.js:547:15)
ERR! at Function.resolve (internal/module.js:18:19)
ERR! at Object.babelDefault (/private/tmp/taskbox/node_modules/@storybook/vue/dist/server/framework-preset-vue.js:38:79)
ERR! at /private/tmp/taskbox/node_modules/@storybook/core/dist/server/presets.js:73:26
ERR! at Array.reduce (<anonymous>)
ERR! at applyPresets (/private/tmp/taskbox/node_modules/@storybook/core/dist/server/presets.js:66:18)
ERR! at Object.apply (/private/tmp/taskbox/node_modules/@storybook/core/dist/server/presets.js:84:14)
ERR! at /private/tmp/taskbox/node_modules/@storybook/core/dist/server/core-preset-dev.js:37:20
ERR! at _default (/private/tmp/taskbox/node_modules/@storybook/core/dist/server/loadCustomBabelConfig.js:88:29)
ERR! at Object.babel (/private/tmp/taskbox/node_modules/@storybook/core/dist/server/core-preset-dev.js:36:45)
ERR! at /private/tmp/taskbox/node_modules/@storybook/core/dist/server/presets.js:73:26
ERR! at Array.reduce (<anonymous>)
ERR! at applyPresets (/private/tmp/taskbox/node_modules/@storybook/core/dist/server/presets.js:66:18)
ERR! at Object.apply (/private/tmp/taskbox/node_modules/@storybook/core/dist/server/presets.js:84:14)
ERR! at Object.babel (/private/tmp/taskbox/node_modules/@storybook/core/dist/server/config.js:27:22)
ERR! at getWebpackConfig (/private/tmp/taskbox/node_modules/@storybook/core/dist/server/config.js:55:30)
babel-preset-vue is not a (peer) dependency of @storybook/vue, and I don’t think it should be being used at all.
Please specify which version of Storybook and optionally any affected addons that you’re running
- @storybook/vue 4.0.0-rc.0
Affected platforms
Dependencies of app:
"dependencies": {
"vue": "^2.5.17"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.0.5",
"@vue/cli-plugin-eslint": "^3.0.5",
"@vue/cli-plugin-unit-jest": "^3.0.5",
"@vue/cli-service": "^3.0.5",
"@vue/eslint-config-prettier": "^3.0.5",
"@vue/test-utils": "^1.0.0-beta.20",
"babel-core": "7.0.0-bridge.0",
"babel-jest": "^23.0.1",
"vue-template-compiler": "^2.5.17",
"@storybook/vue": "^4.0.0-rc.0",
"@storybook/addon-actions": "^4.0.0-rc.0",
"@storybook/addon-links": "^4.0.0-rc.0",
"@storybook/addons": "^4.0.0-rc.0",
"babel-loader": "^8.0.4"
}
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 3
- Comments: 54 (43 by maintainers)
Commits related to this issue
- Revert to installing `babel-preset-vue` from view installer. This was removed in e496dfbb91fa38224adaf12d4d6c7ac3b39f85cb Probably we should not even be using this preset (see https://github.com/sto... — committed to storybookjs/storybook by tmeasday 6 years ago
- Vue: Remove babel-preset-vue #4475 See the vue-kitchen-sink app for a migration path. Basically you just need to add the preset to your or storybook's babel config. — committed to storybookjs/storybook by graup 4 years ago
OK, I’ll work on this. I can make a version that has some sort of migration path for Babel 6 users.
It is 2020 and
babel-preset-vueis still in the code and docs. This makes Storybook unusable out-of-the-box when using vue-cli and the storybook-vue guide. (1. Install vue-cli 2. Create a new vue project 3. Try to add storybook according to the guide. It forces you to installbabel-preset-vuewhich is completely unnecessary.)What do we need to do here?
As @pksunkara mentioned, we could just get rid of it altogether? Nobody creating a new project today would use Babel 6.
/Edit: If anyone wants a quick workaround, I created a minimal Storybook-Vue-TS repository which uses a patch file to get rid of this requirement.
You need to add your custom loaders (looks like you’re using stylus) to the storybook webpack config too @crusenov.
The current issue really isn’t related to this though, https://github.com/storybookjs/vue-cli-plugin-storybook/issues/23 looks to be more suited, or open a new issue if you believe there’s a bug. Thanks!
@backbone87 @pksunkara I’m fine as long as we have great documentation and support for the latest and greatest. Older versions can be in the documentation or even documented in issues. really feels like storybook for Vue could use a little love ❤️
As far as I can see the fix here is to just remove the automatic inclusion of that preset and make it clear in the documentation that users should specify a preset themselves? (Which in most cases will have already been taken care of.)
Can someone reiterate why that preset is there in the first place? It seems counter-intuitive to forcefully add babel presets to existing babel projects.
Will do @shilman 👍
I ran into this problem while migrating from webpack 3/stroybook 3 to webpack 4/storybook 4. We removed the babel preset as we don’t use it anymore in our vue build. I think at least this should be added as a peer dependency until it is clear how to proceed. As the preset is requirered at runtime it has to be some kind of dependency.
I use vue-cli@3 , I encountered the same problem on window 10
In the interests of not blocking the SB4 release: https://github.com/storybooks/storybook/pull/4535
There may be better solutions, but AFAICT this works and doesn’t introduce problems. We can do a better fix in a 4.0.1 perhaps?
I’m confused here. AFAICT this is a blocker for the 4.0 release—any chance we can get some clarity on this in the next day or so?
Here’s a small update. While working on #10813 I tried to remove
babel-preset-vuefrom storybook’s vue preset. Existing projects relying on it can be pretty easily migrated by adding it back in manually, but I ran into a bunch of problems with the E2E tests (sb init). I may be mistaken but this is how I understand it now.As far as I can tell, the SFC_VUE e2e test does this:
sb init, which recognizes the project as a SFC_VUE project, based on the ‘vue-loader’ depbabel-preset-vue(that adds support for JSX). It fails if that preset is missing from the babel config.My questions:
babel-preset-vue(I think?). Without that preset, no JSX. Maybe we could remove the use of JSX in the generated story? Users of JSX in Vue should be using another babel plugin anyway according to the vue docs.babel-preset-vue?I think what we need to do is
babel-preset-vue(at the moment, there’s a weird cross-dependency from the story js code to that preset)babel-preset-vuefrom the codeSome more code references:
@graup any chance you can take a crack at this? We’re working on storybook 6.0 right now, so there’s never been a better time to make a breaking change
We should definitely get rid of
babel-preset-vue, as far as I can tell that is not even compatible with Babel 7 (it’s from the time before babel switched from thebabel-preset-namenaming to@babel/name). I tried to use JSX in Vue with it and it creates all sorts of errors.For now, is there a workaround to tell @storyboard/vue to NOT require
babel-preset-vue? I want to use@vue/appor@vue/babel-preset-appinstead, as specified in my babel config.Nothing changed, so probably this bug is still there. Nothing to close here!