Skip to content
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

Configurable Chromium executable path when extracting stories.json #13724

Closed
ryota-ka opened this issue Jan 25, 2021 · 5 comments
Closed

Configurable Chromium executable path when extracting stories.json #13724

ryota-ka opened this issue Jan 25, 2021 · 5 comments

Comments

@ryota-ka
Copy link

ryota-ka commented Jan 25, 2021

Is your feature request related to a problem? Please describe

stories.json, which is required for Storybook composition, can be generated through $ npx sb extract.

We sometimes want to use preinstalled Chrome/Chromium by providing its path.
Automatic installation of Chromium works nice in most cases, but we are sometimes faced to the situation it doesn't work well.

sb extract internally utilizes puppeteer-core, which aims for programmatic use and does not respect $PUPPETEER_EXECUTABLE_PATH environment variable by design.
This makes it impossible to use preinstalled Chromium and avoid automatic installation.

Describe the solution you'd like

Add a --chromium-executable-path (or --chrome-executable-path) option to sb extract command.
(AFAIK @storybook/addon-storyshots-puppeteer already offers such a feature to solve the problem, by providing chromeExecutablePath option.)

Describe alternatives you've considered

We may respect $PUPPETEER_EXECUTABLE_PATH environment variable in sb extract, but I don't think it's a good idea.

Or we may switch to puppeteer from puppeteer-core.

Are you able to assist to bring the feature to reality?

Yes.

Additional context

Due to this comment, puppeteer-core is designed not to install Chromium, unlike puppeteer.
If we prefer automatic installation, then we may ought to use puppeteer instead of puppeteer-core.

@crohrer
Copy link

crohrer commented Feb 26, 2021

I also had the same issue running sb extract in a CI environment. Is there any workaround?

@ryota-ka
Copy link
Author

@crohrer Here's my dirty & hacky workaround. Hope it works for you.

$ yarn add -D puppeteer
$ sed -i ./node_modules/@storybook/cli/dist/extract.js -e s/puppeteer-core/puppeteer/

@crohrer
Copy link

crohrer commented Feb 27, 2021

@ryota-ka Thank you!

@shilman
Copy link
Member

shilman commented Aug 24, 2021

Gadzooks!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.4.0-alpha.32 containing PR #15878 that references this issue. Upgrade today to the @next NPM tag to try it out!

npx sb upgrade --prerelease

Closing this issue. Please re-open if you think there's still more to do.

@shilman shilman closed this as completed Aug 24, 2021
@tfrijsewijk
Copy link

tfrijsewijk commented Jun 21, 2023

I wanted to generate stories.json for a Storybook 7 with storiesOf. So I need to use storybook extract which in turn uses Puppeteer. My library generated modern code that Chromium could not parse (??=).

So I needed a newer Chromium.

I ended up using a resolution in package.json with Yarn:

  "resolutions": {
    "puppeteer-core@^2.1.1": "13.5.2"
  }

puppeteer-core@2.1.1 uses Chromium 80, 13.5.2 uses Chromium 100.

Of course there's a risk that the puppeteer-core's API doesn't match Storybook usage anymore, but I only need it for storybook extract and that's using ancient methods (https://github.com/storybookjs/storybook/blob/6fddbfb859c31ff1707b9543c09986fa6216118f/code/lib/cli/src/extract.ts).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants