Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a064053
stop using serverRequire from storybook common, because it's about to…
ndelangen Jun 18, 2025
958c7be
Update Node.js version to 20.16.0 in .nvmrc and workflows; reintroduc…
ndelangen Jun 18, 2025
fd3c654
Refactor typecheck workflow and update test mocks to use local server…
ndelangen Jun 18, 2025
b6bd5f6
Add error handling to getTestRunnerConfig function
ndelangen Jun 18, 2025
2094e4b
Update tsup configuration to include Storybook dependencies and adjus…
ndelangen Jun 19, 2025
7fd5891
Add semver dependency to package.json and update yarn.lock
ndelangen Jun 19, 2025
f4b51e6
Remove console error logging from getTestRunnerConfig function
ndelangen Jun 19, 2025
49024ff
Enable treeshaking in tsup configuration for optimized builds
ndelangen Jun 19, 2025
de6531a
Update tsup configuration to exclude additional Storybook internal mo…
ndelangen Jun 19, 2025
d23885c
bundle in the whole core of storybook into the test-runner, since eve…
ndelangen Jun 24, 2025
2a1e346
Update GitHub Actions workflow to set NODE_ENV and increase memory li…
ndelangen Jun 24, 2025
8fcb31b
Refactor test commands in package.json and update GitHub Actions work…
ndelangen Jun 24, 2025
4da85c2
babel everything
ndelangen Jun 24, 2025
52a3bda
Merge pull request #570 from storybookjs/norbert/bundle-in-storybook
ndelangen Jun 24, 2025
9afc71c
Update package.json to include multiple authors for better collaboration
ndelangen Jun 24, 2025
6552af9
Update dependencies in package.json and yarn.lock, including the addi…
ndelangen Jun 24, 2025
d9d46ef
Enhance project structure by refactoring internal imports, adding new…
ndelangen Jun 24, 2025
020e626
Remove TypeScript error suppression in transformCsf and update test c…
ndelangen Jun 24, 2025
8609766
Update storybook-src dependency in package.json and yarn.lock to poin…
ndelangen Jul 7, 2025
f3d1819
Update Jest configuration to support ES2022 syntax by modifying the S…
ndelangen Jul 9, 2025
9fa10a3
bump to new non-version-bundled
ndelangen Jul 9, 2025
7e6c71c
fix tests
ndelangen Jul 9, 2025
db60cb3
Update storybook-src dependency in yarn.lock to point to the latest c…
ndelangen Jul 9, 2025
f437d4a
Update storybook version in package.json and yarn.lock to support 10.…
ndelangen Aug 20, 2025
5cf9d6b
Merge branch 'next' into norbert/asyng-serverRequire-alt
ndelangen Aug 20, 2025
dbc63e2
Update storybook and storybook-src dependencies in package.json and y…
ndelangen Aug 20, 2025
29f1ef4
Discard changes to tsconfig.json
ndelangen Aug 20, 2025
d0c3175
Discard changes to src/playwright/transformPlaywrightJson.ts
ndelangen Aug 20, 2025
2c9779a
Enable TypeScript declaration file generation in tsup.config.ts, upda…
ndelangen Sep 12, 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
19 changes: 4 additions & 15 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
module.exports = {
presets: [
['@babel/preset-env', { targets: { node: 'current' } }],
'@babel/preset-typescript',
'@babel/preset-react',
],
presets: [['@babel/preset-env', { targets: { node: 'current' } }], '@babel/preset-typescript'],
env: {
esm: {
presets: [
[
'@babel/preset-env',
{
modules: false,
targets: { node: 'current' },
},
],
],
test: {
presets: ['@babel/preset-typescript'],
plugins: ['@babel/plugin-transform-modules-commonjs'],
},
},
};
2 changes: 1 addition & 1 deletion .github/workflows/tests-extended.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x, 22.x]
node-version: [20.16.0, 22.x]
steps:
- uses: actions/checkout@v4

Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
node-version: [20.16.0]
steps:
- uses: actions/checkout@v4

Expand All @@ -19,17 +19,19 @@ jobs:
- name: Install dependencies
uses: bahmutov/npm-install@v1

- name: Run unit tests
- name: Build
run: |
yarn build

- name: Run unit tests
run: |
yarn test --coverage

- name: Install Playwright Browsers
run: npx playwright install --with-deps

- name: Run test runner
run: |
yarn build
yarn test-storybook:ci-coverage

- name: Generate code coverage
Expand Down
25 changes: 12 additions & 13 deletions .github/workflows/typecheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@ name: Typecheck
on: [push, pull_request]

jobs:
typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Use Node.js 20.x
uses: actions/setup-node@v1
with:
node-version: '20.x'
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc

- name: Install dependencies
uses: bahmutov/npm-install@v1

- name: Type check
run: yarn tsc
- name: Install dependencies
uses: bahmutov/npm-install@v1

- name: Type check
run: yarn tsc
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18
v20.16.0
4 changes: 4 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
module.exports = {
testMatch: ['**/*.test.ts'],
transform: {
'^.+\\.[t|j]sx?$': 'babel-jest',
},
Comment on lines +3 to +5
Copy link
Member Author

Choose a reason for hiding this comment

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

Is this "the recipe"? 🤔💭❗

transformIgnorePatterns: ['node_modules/(?!(storybook-src)/)'],
moduleNameMapper: {
'@storybook/test-runner/playwright/global-setup': '<rootDir>/playwright/global-setup',
'@storybook/test-runner/playwright/global-teardown': '<rootDir>/playwright/global-teardown',
Expand Down
81 changes: 75 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
"url": "https://github.com/storybookjs/test-runner"
},
"license": "MIT",
"author": "shilman",
"author": [
"shilman",
"ndelangen",
"yannbf"
],
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
Expand All @@ -29,7 +33,7 @@
"*.d.ts"
],
"scripts": {
"build": "tsup",
"build": "NODE_ENV=production NODE_OPTIONS='--max-old-space-size=8192' tsup",
"build-storybook": "storybook build",
"build:watch": "tsup --watch",
"generate-dynamic-stories": "node scripts/generate-dynamic-stories.js",
Expand All @@ -51,13 +55,22 @@
"*.{ts,js,tsx,jsx,css,md}": "prettier --write"
},
"dependencies": {
"@babel/cli": "^7.12.1",
"@babel/core": "^7.22.5",
"@babel/generator": "^7.22.5",
"@babel/parser": "^7.26.9",
"@babel/plugin-transform-modules-commonjs": "^7.22.5",
"@babel/preset-env": "^7.19.4",
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.18.6",
"@babel/template": "^7.22.5",
"@babel/traverse": "^7.26.9",
"@babel/types": "^7.22.5",
"@jest/types": "^29.6.3",
"@swc/core": "^1.5.22",
"@swc/jest": "^0.2.23",
"esbuild": "^0.18.0 || ^0.19.0 || ^0.20.0 || ^0.21.0 || ^0.22.0 || ^0.23.0 || ^0.24.0 || ^0.25.0",
Copy link
Member

Choose a reason for hiding this comment

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

This looks pretty annoying to keep up to date. Is the intention that each time esbuild releases a new version, this will be updated? Why not use >= 0.18.0?

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right @IanVS

However the version range you mention promises to be compatible with "all future versions" of esbuild.

I think that's a promise that can't be kept.
And it locks libraries into a really bad spot.. if they release a new major version, they risk breaking the ecosystem.

Copy link
Member

Choose a reason for hiding this comment

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

That's fair. Though I think you can use 0.18 - 0.25 just to keep the list from becoming unmanageably long.

"esbuild-register": "^3.6.0",
"expect-playwright": "^0.8.0",
"jest": "^29.6.4",
"jest-circus": "^29.6.4",
Expand All @@ -68,50 +81,106 @@
"jest-serializer-html": "^7.1.0",
"jest-watch-typeahead": "^2.0.0",
"nyc": "^15.1.0",
"playwright": "^1.14.0"
"playwright": "^1.14.0",
"playwright-core": "^1.14.0",
"semver": "^7.6.2"
},
"devDependencies": {
"@auto-it/released": "^11.1.6",
"@aw-web-design/x-default-browser": "1.4.126",
"@babel/cli": "^7.12.1",
"@babel/preset-env": "^7.19.4",
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.18.6",
"@storybook/addon-a11y": "next",
"@storybook/addon-coverage": "^1.0.0",
"@storybook/addon-docs": "next",
"@storybook/docs-mdx": "4.0.0-next.1",
"@storybook/icons": "^1.4.0",
"@storybook/react-vite": "next",
"@testing-library/dom": "10.4.0",
"@testing-library/react": "^14.0.0",
"@types/cross-spawn": "^6.0.6",
"@types/detect-port": "^1.3.0",
"@types/diff": "^5.0.9",
"@types/ejs": "^3.1.1",
"@types/find-cache-dir": "^5.0.0",
"@types/jest": "^29.0.0",
"@types/js-yaml": "^4.0.5",
"@types/node": "^16.4.1",
"@types/node-fetch": "^2.6.11",
"@types/npmlog": "^7.0.0",
"@types/picomatch": "^2.3.0",
"@types/prettier": "^3.0.0",
"@types/pretty-hrtime": "^1.0.0",
"@types/semver": "^7.5.8",
"@vitejs/plugin-react": "^4.0.3",
"@yarnpkg/esbuild-plugin-pnp": "^3.0.0-rc.10",
"@yarnpkg/fslib": "2.10.3",
"@yarnpkg/libzip": "2.3.0",
"auto": "^11.1.6",
"babel-jest": "^29.0.0",
"babel-loader": "^8.1.0",
"babel-plugin-istanbul": "^6.1.1",
"browser-dtector": "^3.4.0",
"bundle-require": "^5.1.0",
"camelcase": "^8.0.0",
"can-bind-to-host": "^1.1.1",
"chai": "^5.1.1",
"commander": "^9.0.0",
"comment-parser": "^1.4.1",
"concurrently": "^7.0.0",
"cross-spawn": "^7.0.6",
"diff": "^5.2.0",
"es-toolkit": "^1.36.0",
"esbuild": "^0.18.0 || ^0.19.0 || ^0.20.0 || ^0.21.0 || ^0.22.0 || ^0.23.0 || ^0.24.0 || ^0.25.0",
"find-up": "^5.0.0",
"glob": "^10.2.2",
"globby": "^14.0.1",
"husky": "^8.0.0",
"jest-image-snapshot": "^6.2.0",
"js-yaml": "^4.1.0",
"leven": "^4.0.0",
"lint-staged": "^13.0.3",
"mlly": "^1.7.4",
"nanoid": "^4.0.2",
"node-fetch": "^2",
"npmlog": "^7.0.0",
"open": "^8.4.0",
"p-limit": "^6.2.0",
"package-manager-detector": "^1.1.0",
"picocolors": "^1.1.0",
"picomatch": "^2.3.0",
"picoquery": "^1.4.0",
"pkg-up": "^5.0.0",
"prettier": "^2.8.1",
"pretty-hrtime": "^1.0.3",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"read-pkg-up": "^7.0.1",
"storybook": "next",
"sirv": "^2.0.4",
"slash": "^3.0.0",
"storybook": "^0.0.0-0 || ^8.2.0 || ^9.0.0 || ^9.1.0-0",
"storybook-src": "git+https://github.com/storybookjs/storybook.git#next",
"strip-ansi": "^7.1.0",
Copy link
Member

Choose a reason for hiding this comment

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

There are a lot of devDependencies being added here, and they don't all seem to be used. For example, searching for strip-ansi in this PR returns no results.

Copy link
Member Author

@ndelangen ndelangen Sep 18, 2025

Choose a reason for hiding this comment

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

Yes, I honestly never intentioned this to be the final way we do things.

So I performed no cleanup.

Though devDependencies should not impact users/usage, so the impact is neglectable.

Copy link
Member

Choose a reason for hiding this comment

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

Not users, but it will have an impact on contributors, since they'll have to download all of these. Not that it's a huge deal, but it's also somewhat confusing to see dependencies that aren't used in a package.json. But I wouldn't want a cleanup to block getting this released.

"strip-json-comments": "^5.0.1",
"telejson": "8.0.0",
"tempy": "^1.0.1",
"tiny-invariant": "^1.3.1",
"tinyspy": "^3.0.2",
"ts-dedent": "^2.0.0",
"ts-jest": "^29.0.0",
"tsconfig-paths": "^4.2.0",
"tsup": "^6.5.0",
"type-fest": "^4.18.1",
"typescript": "~4.9.4",
"unique-string": "^3.0.0",
"vite": "^6.3.2",
"wait-on": "^7.2.0"
"wait-on": "^7.2.0",
"watchpack": "^2.2.0"
},
"peerDependencies": {
"storybook": "^0.0.0-0 || ^8.2.0 || ^9.0.0 || ^9.1.0-0 || ^9.2.0-0"
"storybook": "^0.0.0-0 || ^8.2.0 || ^9.0.0 || ^9.1.0-0 || ^9.2.0-0 || ^10.0.0-0"
},
"engines": {
"node": ">=20.0.0"
Expand Down
6 changes: 4 additions & 2 deletions src/config/jest-playwright.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ describe('getJestConfig', () => {
'^.+\\.(story|stories)\\.[jt]sx?$': `${path.dirname(
require.resolve('@storybook/test-runner/playwright/transform')
)}/transform.js`,
'^.+\\.[jt]sx?$': path.resolve('../test-runner/node_modules/@swc/jest'),
'^.+\\.[jt]sx?$': expect.arrayContaining([
path.resolve('../test-runner/node_modules/@swc/jest'),
]),
},
snapshotSerializers: [path.resolve('../test-runner/node_modules/jest-serializer-html')],
testEnvironmentOptions: {
Expand Down Expand Up @@ -83,7 +85,7 @@ describe('getJestConfig', () => {
'^.+\\.(story|stories)\\.[jt]sx?$': `${path.dirname(
require.resolve('@storybook/test-runner/playwright/transform')
)}/transform.js`,
'^.+\\.[jt]sx?$': path.dirname(require.resolve('@swc/jest')),
'^.+\\.[jt]sx?$': expect.arrayContaining([path.dirname(require.resolve('@swc/jest'))]),
},
snapshotSerializers: [path.dirname(require.resolve('jest-serializer-html'))],
testEnvironmentOptions: {
Expand Down
7 changes: 4 additions & 3 deletions src/config/jest-playwright.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import path from 'path';
import { getProjectRoot } from 'storybook/internal/common';
import path from 'node:path';
import type { Config } from '@jest/types';

import { getProjectRoot } from '../util/projectRoot';

const getTestRunnerPath = () => process.env.STORYBOOK_TEST_RUNNER_PATH ?? '@storybook/test-runner';

/**
Expand Down Expand Up @@ -83,7 +84,7 @@ export const getJestConfig = (): Config.InitialOptions => {
'^.+\\.(story|stories)\\.[jt]sx?$': require.resolve(
`${TEST_RUNNER_PATH}/playwright/transform`
),
'^.+\\.[jt]sx?$': swcJestPath,
'^.+\\.[jt]sx?$': [swcJestPath, { jsc: { target: 'es2022' } }],
},
snapshotSerializers: [jestSerializerHtmlPath],
testEnvironmentOptions: {
Expand Down
10 changes: 9 additions & 1 deletion src/csf/transformCsf.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import { TestPrefixer, TransformOptions, transformCsf } from './transformCsf';
import { type TestPrefixer, type TransformOptions, transformCsf } from './transformCsf';
import { testPrefixer } from '../playwright/transformPlaywright';
import template from '@babel/template';

jest.mock('storybook/internal/common', () => ({}));
jest.mock('esbuild-register/dist/node', () => ({
register: jest.fn(),
}));
jest.mock('../util/serverRequire', () => ({
serverRequire: jest.fn(),
}));

describe('transformCsf', () => {
it('inserts a no-op test if there are no stories', () => {
const csfCode = `
Expand Down
15 changes: 8 additions & 7 deletions src/csf/transformCsf.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/* eslint-disable no-underscore-dangle */
import { toId, storyNameFromExport, combineTags } from 'storybook/internal/csf';
import { loadCsf } from 'storybook/internal/csf-tools';
import * as t from '@babel/types';
import generate from '@babel/generator';
import dedent from 'ts-dedent';
import { CsfFile, loadCsf } from 'storybook/internal/csf-tools';
import { generate, types as t } from 'storybook/internal/babel';
import { dedent } from 'ts-dedent';

import { getTagOptions } from '../util/getTagOptions';

Expand All @@ -28,7 +27,7 @@ export interface TransformOptions {
skipTags?: string[];
}

export const prefixFunction = ({
const prefixFunction = ({
key,
testPrefixer,
title,
Expand Down Expand Up @@ -113,7 +112,10 @@ export const transformCsf = (
) => {
const { includeTags, excludeTags, skipTags } = getTagOptions();

const csf = loadCsf(code, { makeTitle: makeTitle ?? ((userTitle: string) => userTitle) });
const csf: CsfFile = loadCsf(code, {
fileName: 'test.js',
makeTitle: makeTitle ?? ((userTitle: string) => userTitle),
});
csf.parse();

const storyExports = Object.keys(csf._stories);
Expand All @@ -124,7 +126,6 @@ export const transformCsf = (
const annotations = csf._storyAnnotations[key];
acc[key] = {};
if (annotations?.play) {
// @ts-expect-error type mismatch – check later
acc[key].play = annotations.play;
}

Expand Down
Loading