Skip to content
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

Core: Make Storybook esbuild-compatible #14380

Merged
merged 2 commits into from
Mar 30, 2021

Conversation

eirslett
Copy link
Contributor

This would be a good fundament for adding Snowpack/Vite
builder support. Currently, Storybook UI can be built by
Webpack or tsc, but not esbuild. Esbuild transpiles .ts file-by-file
and therefore has some caveats:

https://esbuild.github.io/content-types/#typescript-caveats

What I did

This change adds isolatedModules: true to tsconfig.json,
and fixes a few places in the Storybook source code.
(Mostly export type)

The result has been briefly tested with esbuild - with
these changes, it's possible to build Storybook UI
using Vite.

How to test

I tested building it manually using Esbuild, but my setup is
quite cumbersome to replicate. At least I don't think this change
will break anything - if anything breaks, the automated test
suite should uncover it.

This would be a good fundament for adding Snowpack/Vite
builder support. Currently, Storybook UI can be built by
Webpack or tsc, but esbuild transpiles .ts file-by-file
and therefore has some  caveats:

https://esbuild.github.io/content-types/#typescript-caveats

This change adds isolatedModules: true to tsconfig.json,
and fixes a few places in the Storybook source code.
The result has been briefly tested with esbuild - with
these changes, it's possible to build Storybook UI
using Vite.
@eirslett eirslett force-pushed the esbuild-compatible branch from 4b53a01 to f74a04a Compare March 29, 2021 20:18
@shilman shilman added core maintenance User-facing maintenance tasks labels Mar 29, 2021
@shilman shilman changed the title Make Storybook esbuild-compatible Core: Make Storybook esbuild-compatible Mar 29, 2021
Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eirslett Looks great modulo one question

tsconfig.json Show resolved Hide resolved

// Make it work with --isolatedModules, we need a dummy export
/* eslint-disable jest/no-export */
export default {};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why export default {}; here and export {}; above?

Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @eirslett and excited to see the next step on this!! 🚀

@shilman shilman merged commit 47cceca into storybookjs:next Mar 30, 2021
@eirslett eirslett deleted the esbuild-compatible branch March 30, 2021 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core maintenance User-facing maintenance tasks typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants