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

Maintenance: Merge @storybook/core with storybook #30168

Open
wants to merge 10 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions code/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { join } from 'node:path';

import type { StorybookConfig } from '../frameworks/react-vite';

const componentsPath = join(__dirname, '../core/src/components');
const managerApiPath = join(__dirname, '../core/src/manager-api');
const imageContextPath = join(__dirname, '..//frameworks/nextjs/src/image-context.ts');
const componentsPath = join(__dirname, '../core/src/components/index.ts');
const managerApiPath = join(__dirname, '../core/src/manager-api/index.ts');
const imageContextPath = join(__dirname, '../frameworks/nextjs/src/image-context.ts');

const config: StorybookConfig = {
stories: [
Expand Down
4 changes: 2 additions & 2 deletions code/addons/a11y/src/postinstall.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { PostinstallOptions } from '@storybook/cli/src/add';

// eslint-disable-next-line depend/ban-dependencies
import { execa } from 'execa';

import type { PostinstallOptions } from '../../../lib/cli-storybook/src/add';

const $ = execa({
preferLocal: true,
stdio: 'inherit',
Expand Down
16 changes: 8 additions & 8 deletions code/addons/docs/src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ async function webpack(
* In the future the `@storybook/theming` and `@storybook/components` can be removed, as they
* should be singletons in the future due to the peerDependency on `storybook` package.
*/
const cliPath = dirname(require.resolve('storybook/package.json'));
const themingPath = join(cliPath, 'core', 'theming', 'index.js');
const themingCreatePath = join(cliPath, 'core', 'theming', 'create.js');
const corePath = dirname(require.resolve('storybook/package.json'));
const themingPath = join(corePath, 'dist', 'theming', 'index.js');
const themingCreatePath = join(corePath, 'dist', 'theming', 'create.js');

const componentsPath = join(cliPath, 'core', 'components', 'index.js');
const componentsPath = join(corePath, 'dist', 'components', 'index.js');
const blocksPath = dirname(require.resolve('@storybook/blocks/package.json'));
if (Array.isArray(webpackConfig.resolve?.alias)) {
alias = [...webpackConfig.resolve?.alias];
Expand Down Expand Up @@ -181,10 +181,10 @@ export const viteFinal = async (config: any, options: Options) => {
// Use the resolvedReact preset to alias react and react-dom to either the users version or the version shipped with addon-docs
const { react, reactDom, mdx } = await getResolvedReact(options);

const cliPath = dirname(require.resolve('storybook/package.json'));
const themingPath = join(cliPath, 'core', 'theming', 'index.js');
const themingCreatePath = join(cliPath, 'core', 'theming', 'create.js');
const componentsPath = join(cliPath, 'core', 'components', 'index.js');
const corePath = dirname(require.resolve('storybook/package.json'));
const themingPath = join(corePath, 'dist', 'theming', 'index.js');
const themingCreatePath = join(corePath, 'dist', 'theming', 'create.js');
const componentsPath = join(corePath, 'dist', 'components', 'index.js');
const blocksPath = dirname(require.resolve('@storybook/blocks/package.json'));

const packageDeduplicationPlugin = {
Expand Down
1 change: 1 addition & 0 deletions code/addons/essentials/src/actions/manager.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
// @ts-expect-error (no types needed for this)
export * from '@storybook/addon-actions/manager';
1 change: 0 additions & 1 deletion code/addons/essentials/src/backgrounds/preview.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
// @ts-expect-error (no types needed for this)
export * from '@storybook/addon-backgrounds/preview';
1 change: 0 additions & 1 deletion code/addons/essentials/src/docs/manager.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
// @ts-expect-error (no types needed for this)
export * from '@storybook/addon-docs/manager';
1 change: 0 additions & 1 deletion code/addons/essentials/src/highlight/preview.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
// @ts-expect-error (no types needed for this)
export * from '@storybook/addon-highlight/preview';
1 change: 0 additions & 1 deletion code/addons/essentials/src/outline/preview.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
// @ts-expect-error (no types needed for this)
export * from '@storybook/addon-outline/preview';
1 change: 0 additions & 1 deletion code/addons/essentials/src/viewport/preview.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
// @ts-expect-error (no types needed for this)
export * from '@storybook/addon-viewport/preview';
5 changes: 2 additions & 3 deletions code/addons/test/src/node/boot-test-runner.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';

import { Channel, type ChannelTransport } from '@storybook/core/channels';

import { Channel, type ChannelTransport } from 'storybook/internal/channels';
import {
TESTING_MODULE_CANCEL_TEST_RUN_REQUEST,
TESTING_MODULE_PROGRESS_REPORT,
TESTING_MODULE_RUN_REQUEST,
TESTING_MODULE_WATCH_MODE_REQUEST,
} from '@storybook/core/core-events';
} from 'storybook/internal/core-events';

// eslint-disable-next-line depend/ban-dependencies
import { execaNode } from 'execa';
Expand Down
4 changes: 2 additions & 2 deletions code/addons/test/src/node/test-manager.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { describe, expect, it, vi } from 'vitest';
import { createVitest as actualCreateVitest } from 'vitest/node';

import { Channel, type ChannelTransport } from '@storybook/core/channels';
import type { StoryIndex } from '@storybook/types';
import { Channel, type ChannelTransport } from 'storybook/internal/channels';
import type { StoryIndex } from 'storybook/internal/types';

import path from 'pathe';

Expand Down
5 changes: 2 additions & 3 deletions code/addons/test/src/postinstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,7 @@ export default async function postInstall(options: PostinstallOptions) {
args: ['playwright', 'install', 'chromium', '--with-deps'],
});

const fileExtension =
allDeps['typescript'] || (await findFile('tsconfig', ['.json'])) ? 'ts' : 'js';
const fileExtension = allDeps.typescript || (await findFile('tsconfig', ['.json'])) ? 'ts' : 'js';

const vitestSetupFile = resolve(options.configDir, `vitest.setup.${fileExtension}`);
if (existsSync(vitestSetupFile)) {
Expand Down Expand Up @@ -542,7 +541,7 @@ async function getStorybookInfo({ configDir, packageManager: pkgMgr }: Postinsta
const presets = await loadAllPresets({
corePresets: [join(frameworkName, 'preset')],
overridePresets: [
require.resolve('@storybook/core/core-server/presets/common-override-preset'),
require.resolve('storybook/internal/core-server/presets/common-override-preset'),
],
configDir,
packageJson,
Expand Down
2 changes: 0 additions & 2 deletions code/addons/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "../../../",
"module": "Preserve",
"moduleResolution": "Bundler",
"types": ["vitest"],
"strict": true
},
Expand Down
5 changes: 3 additions & 2 deletions code/builders/builder-webpack5/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { cp } from 'node:fs/promises';
import { join, parse } from 'node:path';
import { dirname, join, parse } from 'node:path';

import { PREVIEW_BUILDER_PROGRESS } from 'storybook/internal/core-events';
import { logger } from 'storybook/internal/node-logger';
Expand All @@ -14,7 +14,6 @@ import { checkWebpackVersion } from '@storybook/core-webpack';

import prettyTime from 'pretty-hrtime';
import sirv from 'sirv';
import { corePath } from 'storybook/core-path';
import type { Configuration, Stats, StatsOptions } from 'webpack';
import webpackDep, { DefinePlugin, ProgressPlugin } from 'webpack';
import webpackDevMiddleware from 'webpack-dev-middleware';
Expand All @@ -31,6 +30,8 @@ export const printDuration = (startTime: [number, number]) =>
.replace(' s', ' seconds')
.replace(' m', ' minutes');

const corePath = dirname(require.resolve('storybook/package.json'));

let compilation: ReturnType<typeof webpackDevMiddleware> | undefined;
let reject: (reason?: any) => void;

Expand Down
2 changes: 1 addition & 1 deletion code/lib/cli/bin/index.cjs → code/core/bin/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ process.once('uncaughtException', (error) => {
throw error;
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Re-throwing error prevents proper error reporting to users. Consider handling the error gracefully instead of throwing

});

require('../dist/proxy.cjs');
require('../dist/bin/index.cjs');
Loading
Loading