Giter VIP home page Giter VIP logo

storybook-csf-angular-aot-demo's Introduction

Transform Storybook CSF to AoT compatible code for Angular

This repo is a sandbox for using TypeScript Compiler API to transform Storybook CSF stories into AoT compatible code for consumption by @ngtools/webpack and AngularCompilerPlugin. This allows stories to benefit from AoT compilation which is the default in Angular 9+ and enables the Ivy view engine.

To run this demo

  • clone the repo
  • npm install

Run these two commands in separate terminals:

npm run tools:dev
npm run stories:serve

Then you can edit stories under src/stories/button.ts to see changes in the browser. For now don't change anything in this file except template and moduleMetadata. No other properties are currently supported, this is just a technical proof.

What this does

Storybook CSF format is tailored towards the react component model, which is at odds with how Angular compiles components. As of version 9, Angular compiles components ahead of time by default. CSF format is not compatible with AoT, so it needs to be transformed into a format that Angular can statically analyse. This is achieved using the TypeScript Compiler API to extract metadata from the CSF story file and generate AoT compatible code.

What this doesn't do

It doesn't actually integrate with Storybook at this stage. It doesn't support all of the properties that can be defined in a CSF story, and it only works with parenthesised expressions returned from an arrow function. This can be expanded later.

storybook-csf-angular-aot-demo's People

Contributors

stupidawesome avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.