silverstripe / silverstripe-session-manager

Allow users to manage and revoke access to multiple login sessions across devices.
BSD 3-Clause "New" or "Revised" License
9 stars 7 forks source link

Storybook does not work - regeneratorRuntime #43

Closed emteknetnz closed 3 years ago

emteknetnz commented 3 years ago

Removing this line of code from LoginSession.js breaks storybook:

import 'regenerator-runtime/runtime';

Omitting this line does not break the frontend code, only storybook

image

This method of importing (similar to a php include statement) is pretty non-standard in our codebase and will add a global variable regeneratorRuntime to the CMS. However we only want this for storybook, not the frontend.

This issue on babel/babel explains why it's needed for inner async functions

We have an inner async function in order to utilise the @silverstripe/reactstrap-confirm component which itself uses the ^7 version of @babel/runtime-transform-plugin - package.json. That is why the frontend still works.

The correct place to globally expose regeneratorRuntime would be as a dev only dependency on admin

PRs

emteknetnz commented 3 years ago

Sorted by properly including babel-runtime as dependency and babel-plugin-transform-runtime as a --dev dependency, and updated .babelrc to include the plugin