web icon indicating copy to clipboard operation
web copied to clipboard

fix(dev-server-storybook): rename storybook config file

Open samvimes01 opened this issue 4 years ago • 2 comments

Why I did this change

I had a bug and couldn't start storybook in my package with type: module

Steps to reproduce:

  1. start a package with packcage.json "type: module" (or for example clone or download https://github.com/lit/lit-element-starter-ts)
  2. according to the current guide add the dev-server-storybook
  • create a .storybook/main.js with exports.default = (N.B. - it's the source of issue)
  • create a .storybook/server.config.mjs
  1. run wds --config .storybook/server.config.mjs
  2. got the error ERR_REQUIRE_ESM require() of ES modules is not supported

What I did

So the fastest and easiest fix that works both in commonjs and module packages - rename main.js to main.cjs

  1. renamed hardcoded filename in packages/dev-server-storybook/src/shared/config/readStorybookConfig.ts
  2. changed docs and guide - rename main.js to main.cjs

samvimes01 avatar Jan 03 '22 10:01 samvimes01

🦋 Changeset detected

Latest commit: 276c50d4e6afc895b0b9fa4dc0dadbff5f868c78

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@web/dev-server-storybook Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar Jan 03 '22 10:01 changeset-bot[bot]

This is a breaking change that will break existing projects. It would be better to check if the .cjs file exists, and otherwise use the .js file.

LarsDenBakker avatar Apr 16 '22 19:04 LarsDenBakker