Closed musaffa closed 5 years ago
@gabrielcsapo, wasn't sb cli
supposed to install sb-ember-adapter
?
@musaffa, try to use ember-cli-storybook
until we have a better solution.
@musaffa have you tried using the quick-start guide https://storybook.js.org/basics/guide-ember/?
@igor-dv will investigate and make sure it gets added as a part of the bootstrapping process
@gabrielcsapo Yes I tried and I encountered this error #4672.
here is clean repository with this issue https://github.com/killabeat/storybook-issue-4957
@musaffa what was the version of storybook you were installing?
@killabeat would you be able to go through the bootstrapping process and show where it fails? There is no stories in the specified link.
Storybook version: 4.0.12
@gabrielcsapo sorry i hurried) added strories to https://github.com/killabeat/storybook-issue-4957
I went through the steps on the Ember guide an ran into issue #4672. I solved it by running npm i --save-dev babel-loader
. After that, I hit this issue ☹️. Anybody solve it yet?
@musaffa @barryofguilder I can run this example https://github.com/storybooks/storybook/tree/next/examples/ember-cli
@killabeat the package.json
file seems to have a lot more stuff than what you get by following the instructions in the guide.
I have followed the Ember specific guide which just says you have to run npm i --save-dev @storybook/ember
and then it walks you through adding the config file, stories, etc. That will give you the error that says "Cannot find module 'babel-loader/package.json'" when you run npm run storybook
and it tries to pull stuff from the Ember build. After manually running npm i --save-dev babel-loader
, I get the error that says "Uncaught TypeError: _global.window.require is not a function" after storybook is launched in my browser.
I have followed the instructions from the generic Quick Start guide that says to run npx -p @storybook/cli sb init
. This actually gets you a little further because it detects I am using Ember, so it installs storybook for Ember. It also installs babel-loader
. But I still get an error that says "Uncaught TypeError: _global.window.require is not a function" after storybook is launched.
I'm not sure if there are some dependencies that are not added when installing storybook (using either method), or if there are some additional dependencies needed for storybook that I should just know I have to install.
@killabeat And yes, if I clone the storybook repo and run the ember-cli
example, it works. I'm trying to figure out what's missing between mine and that.
It seems that the step missing from the guide is to manually install ember-cli-storybook
. The guides say
Your environment will be preconfigured using
ember-cli-storybook
.
But I don't think there's anything that's actually installing that addon when running npm i --save-dev @storybook/ember
. This addon is what's responsible for creating the .storybook/preview-head.html
file which is crucial to running Stoybook.
After manually installing that addon with ember install ember-cli-storybook
, my Ember app is successfully running Storybook.
Edit: It also seems that if you run the storybook
script first, which does ember serve & start-storybook -p 9001 -s dist
, the storybook files are not generated. You must first run the build-storybook
command, which does ember build && build-storybook -p 9001 -s dist
. After you do that, running the storybook
command will update the files, but it seems like it doesn't create the files initially.
@barryofguilder correct, you have to start ember serve or ember build then run storybook. This is a limitation of how ember can be integrated with storybook, hopefully we can statically build a ember application in the future, without the need to compile the application and then inject it to run pieces of it.
@gabrielcsapo It's strange though, when running storybook the very first time, ember serve
does not create the preview-head.html
file. I noticed that I had to run ember build
the first time, then once the preview-head.html
file exists, running ember serve
before storybook will update the file accordingly.
Right, ember serve
will enable live reload, ember build
does not enable live reload.
@gabrielcsapo Sorry, I don't think I'm explaining it well enough.
If I follow the steps on the Storybook for Ember page, I get an error due to the preview-head.html
file not being there. I have my npm scripts setup just like it says:
{
"scripts": {
"build-storybook": "ember build && build-storybook -p 9001 -s dist",
"storybook": "ember serve & start-storybook -p 9001 -s dist"
}
}
What I'm saying is, after installing Storybook and going through the guide, at the end it says:
Now everything is ready. Simply run your storybook with:
npm run storybook
Doing that gives me the error that this issue is talking about. It seems that running ember serve
does not create the preview-head.html
file. Running ember build
does create the preview-head.html
file. Once the file exists, running ember serve
will update the file with additional stuff, but it does not create it.
That leads me to believe one of two things:
ember-cli-storybook
addon needs to be updated to create the preview-head.html
file when running ember serve
.preview-head.html
file doesn't exist, you must first run ember build
(not ember serve
) to create it.I'm not familiar enough with Storybook yet to know which option is correct.
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!
Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!
Still having this issue. Anyone find a resolution?
I ran into this same issue. I ran the exact steps listed in the original issue.
I resolved it by doing the following:
ember install @storybook/ember-cli-storybook
"build-storybook": "ember build && build-storybook -s dist",
"storybook": "ember serve & start-storybook -p 9001 -s dist"
npm run build-storybook && npm run storybook
I keep running into this issues.
I have tried to do the following in succession:
ember install @storybook/ember-cli-storybook
ember build
build-storybook -s dist
ember serve
in one terminalstart-storybook -p 9003 -s dist
in anotherBut I keep running into:
_global.window.require is not a function
The file .storybook/preview-head.html
is there.
I keep running into this issues.
I have tried to do the following in succession:
ember install @storybook/ember-cli-storybook
ember build
build-storybook -s dist
ember serve
in one terminalstart-storybook -p 9003 -s dist
in anotherBut I keep running into:
_global.window.require is not a function
The file
.storybook/preview-head.html
is there.
I started by completing this doc
and faced the same issue
and followed this comment and had my issue fixed by following the steps in this comment
@gossi is there a problem in the ember docs?
Possibly, or in the auto-generated scripts
. The most possible cause for this problem is, when storybook is started before ember is started. That said, there are other reasons this error is showing up, such as wrong wiring of dist files that sb is not picking up.
I think, there are two use-cases:
If this is the decision, we can drive this forward.
I think option 1 would be great. We can follow what ember-cli-typescript does with TSC. We can make it so that it just works instead of having to run multiple commands for development.
I think it is still useful to have a separate build-storybook command since that produces artifacts.
After running the storybook server, the following error pops up in the browser console:
Originates from this line.
To Reproduce Steps to reproduce the behavior:
System: