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

Release: Patch 8.5.4 #30459

Merged
merged 18 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
002ea75
Update ./docs/versions/next.json for v8.6.0-alpha.4
storybook-bot Feb 5, 2025
435ef9a
Update ./docs/versions/next.json for v8.6.0-alpha.5
storybook-bot Feb 10, 2025
64bd74f
Merge pull request #30360 from storybookjs/valentin/remove-build-sand…
valentinpalkovic Jan 29, 2025
00a9145
Merge pull request #30464 from storybookjs/shilman/restore-default-se…
shilman Feb 5, 2025
31cb0ed
Merge pull request #30485 from storybookjs/valentin/fix-ci-react-vite
valentinpalkovic Feb 6, 2025
fc16ced
Merge pull request #30483 from storybookjs/jeppe/disable-svelte-4-san…
JReinhold Feb 6, 2025
7b30b5d
Merge pull request #30469 from storybookjs/valentin/fix-local-sandbox…
valentinpalkovic Feb 5, 2025
4dc0481
Merge pull request #30471 from storybookjs/valentin/fix-local-sandbox…
valentinpalkovic Feb 5, 2025
d1a7885
Merge pull request #30461 from storybookjs/valentin/fix-local-sandbox…
valentinpalkovic Feb 4, 2025
0119404
Merge pull request #30511 from storybookjs/valentin/fix-virtual-id-re…
valentinpalkovic Feb 11, 2025
ed2252c
Write changelog for 8.5.4 [skip ci]
storybook-bot Feb 11, 2025
8a183a7
Merge pull request #30460 from storybookjs/valentin/update-nx
valentinpalkovic Feb 4, 2025
f6042e2
Merge pull request #30462 from storybookjs/valentin/fix-local-angular…
valentinpalkovic Feb 5, 2025
60c706c
Merge pull request #30422 from storybookjs/yann/update-react-docgen-t…
valentinpalkovic Feb 6, 2025
74896d6
Merge pull request #30432 from JSMike/issue-30338-vite-allowedHosts
shilman Feb 5, 2025
3048209
Merge pull request #30442 from storybookjs/valentin/make-vitest-axe-o…
valentinpalkovic Feb 4, 2025
b0aba8e
Build: Fix test command in CircleCI config to use multiple reporters
valentinpalkovic Jan 23, 2025
caa8a9b
Fix failing tests
valentinpalkovic Feb 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
182 changes: 83 additions & 99 deletions .circleci/config.yml

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
22.6.0
22.13.1

894 changes: 0 additions & 894 deletions .yarn/releases/yarn-4.3.0.cjs

This file was deleted.

934 changes: 934 additions & 0 deletions .yarn/releases/yarn-4.6.0.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ nodeLinker: node-modules

npmPublishAccess: public

yarnPath: .yarn/releases/yarn-4.3.0.cjs
yarnPath: .yarn/releases/yarn-4.6.0.cjs
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 8.5.4

- Addon A11y: Make Vitest Axe optional - [#30442](https://github.com/storybookjs/storybook/pull/30442), thanks @valentinpalkovic!
- Builder-Vite: Fix allowedHosts handling for custom hosts - [#30432](https://github.com/storybookjs/storybook/pull/30432), thanks @JSMike!
- Builder-Vite: Fix resolve id warning - [#30511](https://github.com/storybookjs/storybook/pull/30511), thanks @valentinpalkovic!
- React: Update react-docgen-typescript to fix CI hanging issues - [#30422](https://github.com/storybookjs/storybook/pull/30422), thanks @yannbf!

## 8.5.3

- Preview: Add `globals` to `extract()` - [#30415](https://github.com/storybookjs/storybook/pull/30415), thanks @ndelangen!
Expand Down
21 changes: 21 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<h1>Migration</h1>

- [From version 8.4.x to 8.5.x](#from-version-84x-to-85x)
- [React Vite: react-docgen-typescript is updated](#react-vite-react-docgen-typescript-is-updated)
- [Introducing features.developmentModeForBuild](#introducing-featuresdevelopmentmodeforbuild)
- [Added source code panel to docs](#added-source-code-panel-to-docs)
- [Addon-a11y: Component test integration](#addon-a11y-component-test-integration)
Expand Down Expand Up @@ -429,6 +430,26 @@

## From version 8.4.x to 8.5.x

### React Vite: react-docgen-typescript is updated

Storybook now uses [react-docgen-typescript](https://github.com/joshwooding/vite-plugin-react-docgen-typescript) v0.5.0 which updates its internal logic on how it parses files, available under an experimental feature flag `EXPERIMENTAL_useWatchProgram`, which is disabled by default.

Previously, once you made changes to a component's props, the controls and args table would not update unless you restarted Storybook. With the `EXPERIMENTAL_useWatchProgram` flag, you do not need to restart Storybook anymore, however you do need to refresh the browser page. Keep in mind that this flag is experimental and also does not support the `references` field in tsconfig.json files. Depending on how big your codebase is, it might have performance issues.

```ts
// .storybook/main.ts
const config = {
// ...
typescript: {
reactDocgen: "react-docgen-typescript",
reactDocgenTypescriptOptions: {
EXPERIMENTAL_useWatchProgram: true,
},
},
};
export default config;
```

### Introducing features.developmentModeForBuild

As part of our ongoing efforts to improve the testability and debuggability of Storybook, we are introducing a new feature flag: `developmentModeForBuild`. This feature flag allows you to set `process.env.NODE_ENV` to `development` in built Storybooks, enabling development-related optimizations that are typically disabled in production builds.
Expand Down
934 changes: 934 additions & 0 deletions code/.yarn/releases/yarn-4.6.0.cjs

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions code/.yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ plugins:
- path: ../.yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: '@yarnpkg/plugin-workspace-tools'

# See https://github.com/nrwl/nx/issues/22177
supportedArchitectures:
cpu:
- current
Expand All @@ -36,6 +35,4 @@ supportedArchitectures:
unsafeHttpWhitelist:
- localhost

yarnPath: ../.yarn/releases/yarn-4.3.0.cjs
# Sometimes you get a "The remote archive doesn't match the expected checksum" error, uncommenting this line will fix it
# checksumBehavior: 'update'
yarnPath: .yarn/releases/yarn-4.6.0.cjs
valentinpalkovic marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 3 additions & 3 deletions code/addons/a11y/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@
"dependencies": {
"@storybook/addon-highlight": "workspace:*",
"@storybook/test": "workspace:*",
"axe-core": "^4.2.0",
"vitest-axe": "^0.1.0"
"axe-core": "^4.2.0"
},
"devDependencies": {
"@storybook/global": "^5.0.0",
Expand All @@ -82,7 +81,8 @@
"react-dom": "^18.2.0",
"react-resize-detector": "^7.1.2",
"resize-observer-polyfill": "^1.5.1",
"typescript": "^5.3.2"
"typescript": "^5.3.2",
"vitest-axe": "^0.1.0"
},
"peerDependencies": {
"storybook": "workspace:^"
Expand Down
11 changes: 7 additions & 4 deletions code/addons/a11y/src/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Source: https://github.com/chaance/vitest-axe/blob/main/src/to-have-no-violations.ts
import * as matchers from 'vitest-axe/matchers';

import type { AfterEach } from 'storybook/internal/types';

import { expect } from '@storybook/test';
Expand All @@ -10,7 +7,7 @@ import { A11Y_TEST_TAG } from './constants';
import type { A11yParameters } from './params';
import { getIsVitestRunning, getIsVitestStandaloneRun } from './utils';

expect.extend(matchers);
let vitestMatchersExtended = false;

// eslint-disable-next-line @typescript-eslint/naming-convention
export const experimental_afterEach: AfterEach<any> = async ({
Expand Down Expand Up @@ -54,6 +51,12 @@ export const experimental_afterEach: AfterEach<any> = async ({
*/
if (getIsVitestStandaloneRun()) {
if (hasViolations) {
if (!vitestMatchersExtended) {
const { toHaveNoViolations } = await import('vitest-axe/matchers');
expect.extend({ toHaveNoViolations });
vitestMatchersExtended = true;
}

// @ts-expect-error - todo - fix type extension of expect from @storybook/test
expect(result).toHaveNoViolations();
}
Expand Down
6 changes: 3 additions & 3 deletions code/addons/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@
"@storybook/blocks": "workspace:*",
"@storybook/csf-plugin": "workspace:*",
"@storybook/react-dom-shim": "workspace:*",
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
"ts-dedent": "^2.0.0"
},
"devDependencies": {
"@mdx-js/mdx": "^3.0.0",
"@rollup/pluginutils": "^5.0.2",
"@types/react": "^16.8.0 || ^17.0.0 || ^18.0.0",
"@types/react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rehype-external-links": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion code/addons/test/src/components/GlobalErrorModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const ModalActionBar = styled.div({
alignItems: 'center',
});

const ModalTitle = styled.div(({ theme: { typography } }) => ({
const ModalTitle = styled(Modal.Title)(({ theme: { typography } }) => ({
fontSize: typography.size.s2,
fontWeight: typography.weight.bold,
}));
Expand Down
2 changes: 1 addition & 1 deletion code/builders/builder-vite/input/iframe.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@
<!-- [BODY HTML SNIPPET HERE] -->
<div id="storybook-root"></div>
<div id="storybook-docs"></div>
<script type="module" src="/virtual:/@storybook/builder-vite/vite-app.js"></script>
<script type="module" src="virtual:@storybook/builder-vite/vite-app.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export async function generateModernIframeScriptCode(options: Options, projectRo

return `
if (import.meta.hot) {
import.meta.hot.accept('${getResolvedVirtualModuleId(SB_VIRTUAL_FILES.VIRTUAL_STORIES_FILE)}', (newModule) => {
import.meta.hot.accept('${SB_VIRTUAL_FILES.VIRTUAL_STORIES_FILE}', (newModule) => {
// importFn has changed so we need to patch the new one in
window.__STORYBOOK_PREVIEW__.onStoriesChanged({ importFn: newModule.importFn });
});
Expand Down
3 changes: 1 addition & 2 deletions code/builders/builder-vite/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ function iframeMiddleware(options: Options, server: ViteDevServer): Middleware {
const indexHtml = await readFile(require.resolve('@storybook/builder-vite/input/iframe.html'), {
encoding: 'utf8',
});
const generated = await transformIframeHtml(indexHtml, options);
const transformed = await server.transformIndexHtml('/iframe.html', generated);
const transformed = await server.transformIndexHtml('/iframe.html', indexHtml);
res.setHeader('Content-Type', 'text/html');
res.statusCode = 200;
res.write(transformed);
Expand Down
14 changes: 11 additions & 3 deletions code/builders/builder-vite/src/plugins/webpack-stats-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,23 @@ export function pluginWebpackStats({ workingDir }: WebpackStatsPluginOptions): W
/** Convert an absolute path name to a path relative to the vite root, with a starting `./` */
function normalize(filename: string) {
// Do not try to resolve virtual files
if (filename.startsWith('/virtual:')) {
return filename;
if (filename.startsWith('virtual:')) {
// We have to append a forward slash because otherwise we break turbosnap.
// As soon as the chromatic-cli supports `virtual:` id's without a starting forward slash,
// we can remove adding the forward slash here
// Reference: https://github.com/chromaui/chromatic-cli/blob/v11.25.2/node-src/lib/getDependentStoryFiles.ts#L53
return `/${filename}`;
}
// ! Maintain backwards compatibility with the old virtual file names
// ! to ensure that the stats file doesn't change between the versions
// ! Turbosnap is also only compatible with the old virtual file names
// ! the old virtual file names did not start with the obligatory \0 character
if (Object.values(SB_VIRTUAL_FILES).includes(getOriginalVirtualModuleId(filename))) {
return getOriginalVirtualModuleId(filename);
// We have to append a forward slash because otherwise we break turbosnap.
// As soon as the chromatic-cli supports `virtual:` id's without a starting forward slash,
// we can remove adding the forward slash here
// Reference: https://github.com/chromaui/chromatic-cli/blob/v11.25.2/node-src/lib/getDependentStoryFiles.ts#L53
return `/${getOriginalVirtualModuleId(filename)}`;
}

// Otherwise, we need them in the format `./path/to/file.js`.
Expand Down
13 changes: 12 additions & 1 deletion code/builders/builder-vite/src/transform-iframe-html.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { normalizeStories } from 'storybook/internal/common';
import type { DocsOptions, Options, TagsOptions } from 'storybook/internal/types';

import { SB_VIRTUAL_FILES } from './virtual-file-names';

export type PreviewHtml = string | undefined;

export async function transformIframeHtml(html: string, options: Options) {
Expand All @@ -26,7 +28,7 @@ export async function transformIframeHtml(html: string, options: Options) {
...(build?.test?.disableBlocks ? { __STORYBOOK_BLOCKS_EMPTY_MODULE__: {} } : {}),
};

return html
const transformedHtml = html
.replace('[CONFIG_TYPE HERE]', configType || '')
.replace('[LOGLEVEL HERE]', logLevel || '')
.replace(`'[FRAMEWORK_OPTIONS HERE]'`, JSON.stringify(frameworkOptions))
Expand All @@ -46,4 +48,13 @@ export async function transformIframeHtml(html: string, options: Options) {
.replace(`'[TAGS_OPTIONS HERE]'`, JSON.stringify(tagsOptions || {}))
.replace('<!-- [HEAD HTML SNIPPET HERE] -->', headHtmlSnippet || '')
.replace('<!-- [BODY HTML SNIPPET HERE] -->', bodyHtmlSnippet || '');

if (configType === 'DEVELOPMENT') {
return transformedHtml.replace(
'virtual:@storybook/builder-vite/vite-app.js',
`/@id/__x00__${SB_VIRTUAL_FILES.VIRTUAL_APP_FILE}`
);
}

return transformedHtml;
}
8 changes: 4 additions & 4 deletions code/builders/builder-vite/src/virtual-file-names.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export const SB_VIRTUAL_FILES = {
VIRTUAL_APP_FILE: '/virtual:/@storybook/builder-vite/vite-app.js',
VIRTUAL_STORIES_FILE: '/virtual:/@storybook/builder-vite/storybook-stories.js',
VIRTUAL_PREVIEW_FILE: '/virtual:/@storybook/builder-vite/preview-entry.js',
VIRTUAL_ADDON_SETUP_FILE: '/virtual:/@storybook/builder-vite/setup-addons.js',
VIRTUAL_APP_FILE: 'virtual:@storybook/builder-vite/vite-app.js',
VIRTUAL_STORIES_FILE: 'virtual:@storybook/builder-vite/storybook-stories.js',
VIRTUAL_PREVIEW_FILE: 'virtual:@storybook/builder-vite/preview-entry.js',
VIRTUAL_ADDON_SETUP_FILE: 'virtual:@storybook/builder-vite/setup-addons.js',
};

export function getResolvedVirtualModuleId(virtualModuleId: string) {
Expand Down
10 changes: 8 additions & 2 deletions code/builders/builder-vite/src/vite-server.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { Options } from 'storybook/internal/types';

import type { Server } from 'http';
import type { InlineConfig, ServerOptions } from 'vite';

import { getAssetsInclude } from './assetsInclude';
import { sanitizeEnvVars } from './envs';
import { getOptimizeDeps } from './optimizeDeps';
import { commonConfig } from './vite-config';
Expand All @@ -12,7 +12,7 @@ export async function createViteServer(options: Options, devServer: Server) {

const commonCfg = await commonConfig(options, 'development');

const config = {
const config: InlineConfig & { server: ServerOptions } = {
...commonCfg,
// Set up dev server
server: {
Expand All @@ -29,6 +29,12 @@ export async function createViteServer(options: Options, devServer: Server) {
optimizeDeps: await getOptimizeDeps(commonCfg, options),
};

const ipRegex = /^(?:\d{1,3}\.){3}\d{1,3}$|^(?:[a-fA-F0-9]{1,4}:){7}[a-fA-F0-9]{1,4}$/;

config.server.allowedHosts =
commonCfg.server?.allowedHosts ??
(options.host && !ipRegex.test(options.host) ? [options.host.toLowerCase()] : true);

const finalConfig = await presets.apply('viteFinal', config, options);

const { createServer } = await import('vite');
Expand Down
8 changes: 4 additions & 4 deletions code/core/src/components/components/Modal/Modal.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const Default: Story = {
<>
<Modal {...props} open={isOpen}>
<div style={{ padding: 15 }}>
<div>Hello world!</div>
<Modal.Title>Hello world!</Modal.Title>
<Modal.Dialog.Close onClick={() => setOpen(false)}>Close</Modal.Dialog.Close>
</div>
</Modal>
Expand Down Expand Up @@ -70,7 +70,7 @@ export const FixedWidth: Story = {
<>
<Modal {...props} open={isOpen}>
<div style={{ padding: 15 }}>
<div>Hello world!</div>
<Modal.Title>Hello world!</Modal.Title>
<Modal.Dialog.Close onClick={() => setOpen(false)}>Close</Modal.Dialog.Close>
</div>
</Modal>
Expand Down Expand Up @@ -98,7 +98,7 @@ export const FixedHeight: Story = {
<>
<Modal {...props} open={isOpen}>
<div style={{ padding: 15 }}>
<div>Hello world!</div>
<Modal.Title>Hello world!</Modal.Title>
<Modal.Dialog.Close onClick={() => setOpen(false)}>Close</Modal.Dialog.Close>
</div>
</Modal>
Expand Down Expand Up @@ -127,7 +127,7 @@ export const FixedWidthAndHeight: Story = {
<>
<Modal {...props} open={isOpen}>
<div style={{ padding: 15 }}>
<div>Hello world!</div>
<Modal.Title>Hello world!</Modal.Title>
<Modal.Dialog.Close onClick={() => setOpen(false)}>Close</Modal.Dialog.Close>
</div>
</Modal>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ReactNode } from 'react';
import type { ReactElement } from 'react';
import React, { useEffect, useRef } from 'react';

const usePrevious = (value: any) => {
Expand All @@ -20,7 +20,7 @@ const useUpdate = (update: boolean, value: any) => {

export interface AddonPanelProps {
active: boolean;
children: ReactNode;
children: ReactElement;
}

export const AddonPanel = ({ active, children }: AddonPanelProps) => {
Expand Down
2 changes: 1 addition & 1 deletion code/core/src/manager-api/modules/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const defaultLayoutState: SubState = {
panelPosition: 'bottom',
showTabs: true,
},
selectedPanel: 'chromaui/addon-visual-tests/panel',
selectedPanel: undefined,
theme: create(),
};

Expand Down
3 changes: 1 addition & 2 deletions code/core/src/manager-api/modules/stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,7 @@ export const init: ModuleFn<SubAPI, SubState> = ({
return undefined;
}
if (refId) {
// @ts-expect-error (possibly undefined)
return refs[refId].index ? refs[refId].index[storyId] : undefined;
return refs?.[refId]?.index?.[storyId] ?? undefined;
}
return index ? index[storyId] : undefined;
},
Expand Down
13 changes: 7 additions & 6 deletions code/e2e-tests/addon-docs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,18 +200,19 @@ test.describe('addon-docs', () => {
const root = sbPage.previewRoot();

// Arrange - Setup expectations
let expectedReactVersionRange = /^18/;
let expectedReactVersionRange = /^19/;
if (templateName.includes('react-webpack/17') || templateName.includes('react-vite/17')) {
expectedReactVersionRange = /^17/;
} else if (templateName.includes('react16')) {
expectedReactVersionRange = /^16/;
} else if (
templateName.includes('nextjs/default-ts') ||
templateName.includes('nextjs/prerelease') ||
templateName.includes('react-vite/prerelease') ||
templateName.includes('react-webpack/prerelease')
templateName.includes('internal/react18-webpack-babel') ||
templateName.includes('preact-vite/default-js') ||
templateName.includes('preact-vite/default-ts') ||
templateName.includes('react-native-web-vite/expo-ts') ||
templateName.includes('react-webpack/18-ts')
) {
expectedReactVersionRange = /^19/;
expectedReactVersionRange = /^18/;
}

// Arrange - Get the actual versions
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/react-native-web-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"@babel/plugin-transform-modules-commonjs": "^7.26.3",
"@babel/preset-react": "^7.26.3",
"@bunchtogether/vite-plugin-flow": "^1.0.2",
"@joshwooding/vite-plugin-react-docgen-typescript": "0.4.2",
"@joshwooding/vite-plugin-react-docgen-typescript": "0.5.0",
"@storybook/builder-vite": "workspace:*",
"@storybook/react": "workspace:*",
"@storybook/react-vite": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/react-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"prep": "jiti ../../../scripts/prepare/bundle.ts"
},
"dependencies": {
"@joshwooding/vite-plugin-react-docgen-typescript": "0.4.2",
"@joshwooding/vite-plugin-react-docgen-typescript": "0.5.0",
"@rollup/pluginutils": "^5.0.2",
"@storybook/builder-vite": "workspace:*",
"@storybook/react": "workspace:*",
Expand Down
Loading
Loading