Skip to content

Core: Enable gzip compression on the development server#14459

Merged
shilman merged 2 commits intostorybookjs:nextfrom
kaelig:compression
Apr 8, 2021
Merged

Core: Enable gzip compression on the development server#14459
shilman merged 2 commits intostorybookjs:nextfrom
kaelig:compression

Conversation

@kaelig
Copy link
Contributor

@kaelig kaelig commented Apr 2, 2021

Issue: #14280

What I did

This PR enables compression on assets served by the dev server. The compression level is low, which yields good compression results without slowing down the feedback loop between saving a file and changes appearing in the browser.

This is useful when a Storybook has large bundles.

How to test

Make sure HMR works as expected. It should be okay, but in older versions of the compression package, it could sometimes be an issue.

Also ensure loading and reloading performance is within acceptable parameters.

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.

Hi @kaelig, this looks great! However, it looks like there are some types missing which is causing the build to break:

@storybook/core-server: src/dev-server.ts(2,25): error TS7016: Could not find a declaration file for module 'compression'. '/tmp/storybook/node_modules/compression/index.js' implicitly has an 'any' type.
@storybook/core-server:   Try `npm install @types/compression` if it exists or add a new declaration (.d.ts) file containing `declare module 'compression';

Looks like it's on DefinitelyTypeed:

MMBP15:storybook shilman$ npm info @types/compression

@types/compression@1.7.0 | MIT | deps: 1 | versions: 20
TypeScript definitions for compression

@kaelig
Copy link
Contributor Author

kaelig commented Apr 3, 2021

Thanks! My local tests consisted of modifying the compiled version in node_modules… I should have tested compilation and type checked properly!

I updated the PR 🤞

@kaelig kaelig requested a review from shilman April 5, 2021 17:42
@shilman
Copy link
Member

shilman commented Apr 5, 2021

FYI, we're in a merge freeze while the latest release is stabilizing. We'll resume merging PRs and publishing daily-ish alphas in a week or two. Thanks for your patience!

@shilman shilman changed the title Enable gzip compression on the development server Core: Enable gzip compression on the development server Apr 8, 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.

Nice, simple fix. 💯

@shilman shilman merged commit 607258d into storybookjs:next Apr 8, 2021
@kaelig kaelig deleted the compression branch April 8, 2021 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants