Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 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
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
2 changes: 1 addition & 1 deletion .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 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: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
"@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 @@ -81,7 +83,7 @@
"@storybook/addon-docs": "next",
"@storybook/react-vite": "next",
"@types/jest": "^29.0.0",
"@types/node": "^16.4.1",
"@types/node": "^20.0.0",
"@types/node-fetch": "^2.6.11",
"@vitejs/plugin-react": "^4.0.3",
"auto": "^11.1.6",
Expand Down
4 changes: 2 additions & 2 deletions src/util/getStorybookMain.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getStorybookMain, resetStorybookMainCache, storybookMainConfig } from './getStorybookMain';
import * as coreCommon from 'storybook/internal/common';
import * as coreCommon from './serverRequire';

jest.mock('storybook/internal/common');
jest.mock('./serverRequire');

describe('getStorybookMain', () => {
beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/util/getStorybookMain.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { join, resolve } from 'path';
import { serverRequire } from 'storybook/internal/common';
import type { StorybookConfig } from 'storybook/internal/types';
import dedent from 'ts-dedent';
import { serverRequire } from './serverRequire';

export const storybookMainConfig = new Map<string, StorybookConfig>();

Expand Down
12 changes: 4 additions & 8 deletions src/util/getTestRunnerConfig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const testRunnerConfig: TestRunnerConfig = {
},
};

jest.mock('storybook/internal/common', () => ({
jest.mock('./serverRequire', () => ({
serverRequire: jest.fn(),
}));

Expand All @@ -37,23 +37,19 @@ describe('getTestRunnerConfig', () => {

it('should load the test runner config', () => {
const configDir = '.storybook';
(require('storybook/internal/common').serverRequire as jest.Mock).mockReturnValueOnce(
testRunnerConfig
);
(require('./serverRequire').serverRequire as jest.Mock).mockReturnValueOnce(testRunnerConfig);

const result = getTestRunnerConfig(configDir);

expect(result).toEqual(testRunnerConfig);
expect(require('storybook/internal/common').serverRequire).toHaveBeenCalledWith(
expect(require('./serverRequire').serverRequire).toHaveBeenCalledWith(
join(resolve('.storybook', 'test-runner'))
);
});

it('should cache the test runner config', () => {
const configDir = '.storybook';
(require('storybook/internal/common').serverRequire as jest.Mock).mockReturnValueOnce(
testRunnerConfig
);
(require('./serverRequire').serverRequire as jest.Mock).mockReturnValueOnce(testRunnerConfig);

const result1 = getTestRunnerConfig(configDir);
const result2 = getTestRunnerConfig(configDir);
Expand Down
2 changes: 1 addition & 1 deletion src/util/getTestRunnerConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { join, resolve } from 'path';
import { serverRequire } from 'storybook/internal/common';
import { TestRunnerConfig } from '../playwright/hooks';
import { serverRequire } from './serverRequire';

let testRunnerConfig: TestRunnerConfig;
let loaded = false;
Expand Down
19 changes: 19 additions & 0 deletions src/util/serverRequire.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { serverResolve } from 'storybook/internal/common';
const { register } = require('esbuild-register/dist/node');

register();

export function serverRequire(path: string) {
const located = serverResolve(path);
if (!located) {
throw new Error(`Could not find ${path}`);
}

const result = require(located);

if (result.default) {
return result.default;
}

return result;
}
1 change: 0 additions & 1 deletion tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { defineConfig } from 'tsup';

export default defineConfig([
{
clean: true,
entry: ['./src/index.ts', './src/test-storybook.ts'],
format: ['cjs', 'esm'],
splitting: false,
Expand Down
55 changes: 18 additions & 37 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2946,7 +2946,7 @@ __metadata:
"@swc/core": "npm:^1.5.22"
"@swc/jest": "npm:^0.2.23"
"@types/jest": "npm:^29.0.0"
"@types/node": "npm:^16.4.1"
"@types/node": "npm:^20.0.0"
"@types/node-fetch": "npm:^2.6.11"
"@vitejs/plugin-react": "npm:^4.0.3"
auto: "npm:^11.1.6"
Expand All @@ -2956,6 +2956,8 @@ __metadata:
can-bind-to-host: "npm:^1.1.1"
commander: "npm:^9.0.0"
concurrently: "npm:^7.0.0"
esbuild: "npm:^0.18.0 || ^0.19.0 || ^0.20.0 || ^0.21.0 || ^0.22.0 || ^0.23.0 || ^0.24.0 || ^0.25.0"
esbuild-register: "npm:^3.6.0"
expect-playwright: "npm:^0.8.0"
glob: "npm:^10.2.2"
husky: "npm:^8.0.0"
Expand Down Expand Up @@ -3250,20 +3252,13 @@ __metadata:
languageName: node
linkType: hard

"@types/estree@npm:1.0.7":
"@types/estree@npm:1.0.7, @types/estree@npm:^1.0.0":
version: 1.0.7
resolution: "@types/estree@npm:1.0.7"
checksum: 10/419c845ece767ad4b21171e6e5b63dabb2eb46b9c0d97361edcd9cabbf6a95fcadb91d89b5fa098d1336fa0b8fceaea82fca97a2ef3971f5c86e53031e157b21
languageName: node
linkType: hard

"@types/estree@npm:^1.0.0":
version: 1.0.5
resolution: "@types/estree@npm:1.0.5"
checksum: 10/7de6d928dd4010b0e20c6919e1a6c27b61f8d4567befa89252055fad503d587ecb9a1e3eab1b1901f923964d7019796db810b7fd6430acb26c32866d126fd408
languageName: node
linkType: hard

"@types/graceful-fs@npm:^4.1.3":
version: 4.1.9
resolution: "@types/graceful-fs@npm:4.1.9"
Expand Down Expand Up @@ -3332,19 +3327,12 @@ __metadata:
languageName: node
linkType: hard

"@types/node@npm:*":
version: 20.9.0
resolution: "@types/node@npm:20.9.0"
"@types/node@npm:*, @types/node@npm:^20.0.0":
version: 20.19.1
resolution: "@types/node@npm:20.19.1"
dependencies:
undici-types: "npm:~5.26.4"
checksum: 10/a934f7645ed117a27857147403b0c657ffbca578c8f280e4c21d27dfb43e58dc4f24c4319d4335b8a4fa08e28fb2dc905a5bd5e4bc8878047164c56c1b162139
languageName: node
linkType: hard

"@types/node@npm:^16.4.1":
version: 16.18.61
resolution: "@types/node@npm:16.18.61"
checksum: 10/ea2fdb3876f77ef8be0bdeee7b0c301a6bf27ab743f55a10486725d8ddd51b84edea7c219e9d09fd24650e8b14c040207a48169bd396915e7a989bac1a7c0bee
undici-types: "npm:~6.21.0"
checksum: 10/2369a96a832a6e8111d2b996c56fb1b78b27fad0879de3e344ae2835697464e001d6fe813a11902348fc7dc63b9510000f3d2cd4bedadf2d3fce7b7bb7903444
languageName: node
linkType: hard

Expand Down Expand Up @@ -4924,14 +4912,14 @@ __metadata:
languageName: node
linkType: hard

"esbuild-register@npm:^3.5.0":
version: 3.5.0
resolution: "esbuild-register@npm:3.5.0"
"esbuild-register@npm:^3.5.0, esbuild-register@npm:^3.6.0":
version: 3.6.0
resolution: "esbuild-register@npm:3.6.0"
dependencies:
debug: "npm:^4.3.4"
peerDependencies:
esbuild: ">=0.12 <1"
checksum: 10/af6874ce9b5fcdb0974c9d9e9f16530a5b9bd80c699b2ba9d7ace33439c1af1be6948535c775d9a6439e2bf23fb31cfd54ac882cfa38308a3f182039f4b98a01
checksum: 10/4ae1a016e3dad5b53c3d68cf07e31d8c1cec1a0b584038ece726097ac80bd33ab48fb224c766c9b341c04793837e652461eaca9327a116e7564f553b61ccca71
languageName: node
linkType: hard

Expand Down Expand Up @@ -7110,14 +7098,7 @@ __metadata:
languageName: node
linkType: hard

"loupe@npm:^3.1.0":
version: 3.1.2
resolution: "loupe@npm:3.1.2"
checksum: 10/8f5734e53fb64cd914aa7d986e01b6d4c2e3c6c56dcbd5428d71c2703f0ab46b5ab9f9eeaaf2b485e8a1c43f865bdd16ec08ae1a661c8f55acdbd9f4d59c607a
languageName: node
linkType: hard

"loupe@npm:^3.1.3":
"loupe@npm:^3.1.0, loupe@npm:^3.1.3":
version: 3.1.3
resolution: "loupe@npm:3.1.3"
checksum: 10/9e98c34daf0eba48ccc603595e51f2ae002110982d84879cf78c51de2c632f0c571dfe82ce4210af60c32203d06b443465c269bda925076fe6d9b612cc65c321
Expand Down Expand Up @@ -9737,10 +9718,10 @@ __metadata:
languageName: node
linkType: hard

"undici-types@npm:~5.26.4":
version: 5.26.5
resolution: "undici-types@npm:5.26.5"
checksum: 10/0097779d94bc0fd26f0418b3a05472410408877279141ded2bd449167be1aed7ea5b76f756562cb3586a07f251b90799bab22d9019ceba49c037c76445f7cddd
"undici-types@npm:~6.21.0":
version: 6.21.0
resolution: "undici-types@npm:6.21.0"
checksum: 10/ec8f41aa4359d50f9b59fa61fe3efce3477cc681908c8f84354d8567bb3701fafdddf36ef6bff307024d3feb42c837cf6f670314ba37fc8145e219560e473d14
languageName: node
linkType: hard

Expand Down