kobotoolbox / kpi

kpi is the (frontend) server for KoboToolbox. It includes an API for users to access data and manage their forms, question library, sharing settings, create reports, and export data.
https://www.kobotoolbox.org
GNU Affero General Public License v3.0
131 stars 176 forks source link

Upgrade to React 6.14.0, share build config between frontend and Storybook 7 #4539

Open p2edwards opened 1 year ago

p2edwards commented 1 year ago

Description

It seems that the .babelrc for the Storybook 7 build is contradicting the .swcrc with the kpi build, resulting in a regression for the dev server. (live reload or react refresh no longer works.)

The scope of this issue is to restore the dev server without breaking the Storybook 7 build. Ideally, unify configs between Storybook and frontend, because that's why Storybook 7 tries to use a root-level .babelrc in the first place.

Steps to Reproduce

Try running npm run watch, with and without .babelrc.json present in the kpi source directory.

Once the dev server's up, modify some frontend files and save them.

Expected behavior

npm run watch should present a live dev server, reloading changes when frontend files are saved.

Actual behavior

With .babelrc.json present, the live reloading no longer occurs.

(But if .babelrc.json is absent, the storybook build fails.)

Additional details

I think since swc contains affordances as a drop-in replacement for babel, it's probably reading some values from .babelrc.json, that are not the same as what's in .swcrc.

Storybook 7 might not be compatible with the 'classic' runtime (at least, that's what I remember from when I tried this earlier.)

I'd like to do what I commented here in .storybook/main.js:

p2edwards commented 1 year ago

Changing this to 'low priority' as it hasn't been an issue for other devs — nor me since the initial write-up.

Would still be cool to unify the configs, but there doesn't appear to be a pressing issue at the moment.