Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Question: Storybook with rollup.js and TypeScript does not work #13867

Closed
digital-h opened this issue Feb 10, 2021 · 0 comments
Closed

Question: Storybook with rollup.js and TypeScript does not work #13867

digital-h opened this issue Feb 10, 2021 · 0 comments

Comments

@digital-h
Copy link

Apperantly I have an issue running Storybook (version 6) with TypeScript using rollup.js through yarn build-storybook.

As long as I only include stories which relate to plain javascript-modules, everything runs fine. But as soon as I add a story, which releates to a typescript-module, the complete storybook is broken (means the skeleton is there, but waiting for content). Unfortunately without any error-message, that might help me out.

Does anyone know, where this might come from and what I can do as Storybook states on their website that there should be "zero-configuration" for typescript. Am I missing anything here?

Even stranger: if I run yarn start-storybook --node-resolve --watch --open everything works fine. How is this different? What mechanism is used here to compile typescript?

Here comes my .storybook/main.js

const typescript = require('rollup-plugin-typescript2');
const cpy = require('rollup-plugin-cpy');

module.exports = {
    stories: [
        
        // -----------> these are only plain javascript-packages
        '../stories/*.stories.@(js|mdx)',
        '../packages/my-javascript-ui-component/**/*.stories.@(js|mdx)',

        // -----------> breaks as soon as I include any TS-package
        // '../packages/**/*.stories.@(js|mdx)',
        // '../packages/my-evil-typescript-ui-component/**/*.stories.@(js|mdx)',
    ],

    esDevServer: {
        watch: true,
        babel: true,
        nodeResolve: true,
    },

    rollup: config => {
        config.plugins = [
            ...config.plugins,
            typescript({
                typescript: require('typescript'),
            }),
            cpy({
                files: ['**/stories/**/images/*.svg', '**/stories/**/images/*.png'],
                dest: 'public/storybook/stories/imports/images',
            }),
            cpy({
                files: ['**/material-iconfont/**'],
                dest: 'public/storybook/material-iconfont',
            }),
        ];
        return config;
    },

    addons: [
        'storybook-prebuilt/addon-knobs/register.js',
        'storybook-prebuilt/addon-docs/register.js',
    ],
};

package.json:

{
    "name": "frontend-monorepo",
    "version": "4.0.0",
    "private": true,
    "workspaces": [
        "packages/*"
    ],
    "dependencies": {
        "lit-element": "2.4.0"
    },
    "devDependencies": {
        "@babel/cli": "^7.8.4",
        "@babel/core": "^7.9.0",
        "@babel/plugin-proposal-class-properties": "^7.8.3",
        "@babel/plugin-proposal-decorators": "^7.8.3",
        "@babel/plugin-proposal-private-methods": "^7.8.3",
        "@babel/plugin-syntax-dynamic-import": "^7.8.3",
        "@babel/plugin-transform-modules-systemjs": "^7.12.0",
        "@babel/preset-typescript": "^7.8.3",
        "@open-wc/demoing-storybook": "2.4.7",
        "@open-wc/eslint-config": "3.0.0",
        "@open-wc/testing": "2.5.32",
        "@open-wc/testing-karma": "4.0.9",
        "@rollup/plugin-commonjs": "17.1.0",
        "@rollup/plugin-node-resolve": "11.1.1",
        "@rollup/plugin-replace": "2.3.4",
        "@types/resize-observer-browser": "^0.1.4",
        "babel-eslint": "10.1.0",
        "concurrently": "5.3.0",
        "deepmerge": "4.2.2",
        "es-dev-server": "1.60.2",
        "eslint-config-prettier": "6.15.0",
        "eslint-plugin-babel": "5.3.1",
        "eslint-plugin-chai-friendly": "0.6.0",
        "eslint-plugin-mocha-no-only": "1.1.1",
        "eslint-plugin-prettier": "3.2.0",
        "fetch-mock": "9.10.4",
        "karma-junit-reporter": "2.0.1",
        "lerna": "3.22.1",
        "pre-commit": "1.2.2",
        "prettier": "2.2.1",
        "rimraf": "^2.7.1",
        "rollup": "2.38.5",
        "rollup-plugin-cleanup": "3.2.1",
        "rollup-plugin-cpy": "2.0.1",
        "rollup-plugin-index-html": "1.12.7",
        "rollup-plugin-terser": "7.0.2",
        "rollup-plugin-typescript2": "0.29.0",
        "rollup-plugin-workbox": "6.1.1",
        "sinon": "9.2.1",
        "typescript": "4.0.5",
        "web-component-analyzer": "1.1.6"
    },
    "scripts": {
        "clean": "rimraf build && mkdir build",
        "compile": "yarn run clean && tsc -d --outDir ./build/compile",
        "build": "yarn run compile && rollup -c",
        "storybook": "start-storybook --node-resolve --watch --open",
        "storybook:clean": "rimraf public/storybook",
        "storybook:build": "yarn run storybook:clean && build-storybook -o public/storybook"
    }
}

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

3 participants