-
-
Notifications
You must be signed in to change notification settings - Fork 418
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
Storybook does not work on new open-wc workspace #2659
Comments
For me, using a freshly generated project with I think that specific template lives here and could be updated: https://github.com/open-wc/create/blob/8700df758c8bf756169d2778c7713432b76e8bdc/src/generators/demoing-storybook-ts/templates/package.json#L7 |
just tried it out. I agree the package.json+commonjs-Hack is no longer necessary. still the storybook command shows the main app. (used the same building options as before) i still need the change in the web-dev-server.config.mjs -> appIndex |
an even better solution would be to change the .storybook/server.mjs and add the proper appIndex there. export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
...baseConfig,
open: '/',
appIndex: './storybook-static/index.html',
plugins: [storybookPlugin({ type: 'web-components' }), ...baseConfig.plugins],
}); |
I had a fresh install but needed the
|
When I try to do this, I get this error:
|
Mine didn't even generate a Before and after updating [9:38:46 PM] @custom-elements-manifest/analyzer: Created new manifest.
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /****/.storybook/main.js
require() of ES modules is not supported.
require() of /****/.storybook/main.js from /****/node_modules/@web/dev-server-storybook/dist/shared/config/readStorybookConfig.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename main.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /****/package.json. |
|
Expected behavior
starting storybook on a new open-wc workspace using
should show the storybook UI where you can select from a list of found stories and change parameters to see the rending variations.
Actual Behavior
instead the command first results in this error:
which can be solved by creating a new file
.storybook/package.json
including only:after this - the
npm run storybook
command works, but does NOT show the storybook. instead it shows the same webcomponent app asnpm run start
- so no demoing.Possible solution
it took me a while to figure this out as all parts seems to be working correctly - still the outcome is plain wrong.
in the file
web-dev-server.config.mjs
the exported propertyappIndex
seems to be wrong. In a typescript context the transpiled storybook content is located in/storybook-static/
. therefore the correct value should be:after that the storybook command works as expected with live reload and all.
Additional context
I created a new open-wc application using this command:
npm init @open-wc --destinationPath /home/apausch/workspace/workshops/openwc-workspace --type scaffold --scaffoldType app --features linting testing demoing building --typescript true --tagName openwc-workspace --writeToDisk true --installDependencies npm
npm ls:
The text was updated successfully, but these errors were encountered: