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

feat: upgrade to storybook 8 #28

Merged
merged 2 commits into from
Mar 19, 2024
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/giant-laws-promise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@storybook/marko-webpack": major
"@storybook/marko-vite": major
"@storybook/marko": major
---

Upgrade to storybook 8. See https://storybook.js.org/docs/migration-guide for changes
6,306 changes: 2,175 additions & 4,131 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,29 @@
"@babel/register": "^7.23.7",
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.1",
"@marko/compiler": "^5.34.7",
"@marko/compiler": "^5.35.7",
"@marko/testing-library": "^6.2.0",
"@marko/type-check": "^1.1.7",
"@playwright/test": "^1.42.1",
"@testing-library/dom": "^9.3.4",
"@types/babel__register": "^7.17.3",
"@types/node": "^20.11.24",
"@types/node": "^20.11.28",
"@types/resolve": "^1.20.6",
"@typescript-eslint/eslint-plugin": "^7.1.0",
"@typescript-eslint/parser": "^7.1.0",
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"c8": "^9.1.0",
"esbuild": "^0.20.1",
"esbuild": "^0.20.2",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"husky": "^9.0.11",
"jsdom": "^24.0.0",
"lint-staged": "^15.2.2",
"marko": "^5.32.15",
"marko": "^5.33.8",
"prettier": "^3.2.5",
"sort-package-json": "^2.8.0",
"typescript": "^5.3.3",
"typescript": "^5.4.2",
"~preload": "file:scripts/preload.js"
}
}
9 changes: 3 additions & 6 deletions packages/frameworks/marko-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,11 @@
"!**/*.tsbuildinfo"
],
"dependencies": {
"@babel/core": "^7",
"@marko/compiler": "^5",
"@marko/vite": "^4",
"@storybook/builder-vite": "^7.6.4",
"@storybook/core-common": "^7.6.4",
"@storybook/builder-vite": "^8.0.0",
"@storybook/core-common": "^8.0.0",
"@storybook/global": "^5.0.0",
"@storybook/types": "^7.6.4",
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
"@storybook/types": "^8.0.0"
}
}
8 changes: 2 additions & 6 deletions packages/frameworks/marko-vite/src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@ import { hasVitePlugins } from "@storybook/builder-vite";
import type { PresetProperty } from "@storybook/types";
import type { StorybookConfig } from "./types";

export const core: PresetProperty<"core", StorybookConfig> = async (
config,
options,
) => {
const framework =
await options.presets.apply<StorybookConfig["framework"]>("framework");
export const core: PresetProperty<"core"> = async (config, options) => {
const framework = await options.presets.apply("framework");

return {
...config,
Expand Down
4 changes: 2 additions & 2 deletions packages/frameworks/marko-vite/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import type {
TypescriptOptions as TypescriptOptionsBase,
} from "@storybook/types";

type FrameworkName = "@storybook/marko-vite" | (string & NonNullable<unknown>);
type BuilderName = "@storybook/builder-vite" | (string & NonNullable<unknown>);
type FrameworkName = "@storybook/marko-vite";
type BuilderName = "@storybook/builder-vite";

export type FrameworkOptions = {
builder?: BuilderOptions;
Expand Down
9 changes: 3 additions & 6 deletions packages/frameworks/marko-webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,11 @@
"!**/*.tsbuildinfo"
],
"dependencies": {
"@babel/core": "^7",
"@marko/compiler": "^5",
"@marko/webpack": "^9",
"@storybook/builder-webpack5": "^7.6.4",
"@storybook/core-common": "^7.6.4",
"@storybook/builder-webpack5": "^8.0.0",
"@storybook/core-common": "^8.0.0",
"@storybook/global": "^5.0.0",
"@storybook/types": "^7.6.4",
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
"@storybook/types": "^8.0.0"
}
}
12 changes: 2 additions & 10 deletions packages/frameworks/marko-webpack/src/preset.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import type { PresetProperty } from "@storybook/types";
import type { StorybookConfig } from "./types";

export const core: PresetProperty<"core", StorybookConfig> = async (
config,
options,
) => {
const framework =
await options.presets.apply<StorybookConfig["framework"]>("framework");
export const core: PresetProperty<"core"> = async (config, options) => {
const framework = await options.presets.apply("framework");

return {
...config,
Expand Down Expand Up @@ -35,9 +31,5 @@ export const webpackFinal: StorybookConfig["webpackFinal"] = async (
},
],
},
resolve: {
...baseConfig.resolve,
extensions: [...baseConfig.resolve!.extensions!, ".marko"],
},
};
};
8 changes: 2 additions & 6 deletions packages/frameworks/marko-webpack/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@ import type {
TypescriptOptions as TypescriptOptionsBase,
} from "@storybook/types";

type FrameworkName =
| "@storybook/marko-webpack"
| (string & NonNullable<unknown>);
type BuilderName =
| "@storybook/builder-webpack5"
| (string & NonNullable<unknown>);
type FrameworkName = "@storybook/marko-webpack";
type BuilderName = "@storybook/builder-webpack5";

export type FrameworkOptions = {
builder?: BuilderOptions;
Expand Down
16 changes: 8 additions & 8 deletions packages/renderers/marko/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"exports": {
"./package.json": "./package.json",
"./*.d.ts": "./*.d.ts",
"./preview": {
"types": "./dist/config.d.ts",
"import": "./dist/config.mjs",
"default": "./dist/config.js"
"./preset": {
"types": "./dist/preset.d.ts",
"import": "./dist/preset.mjs",
"default": "./dist/preset.js"
},
".": {
"types": "./dist/index.d.ts",
Expand All @@ -36,10 +36,10 @@
"!**/*.tsbuildinfo"
],
"dependencies": {
"@storybook/core-client": "^7.6.4",
"@storybook/docs-tools": "^7.6.4",
"@storybook/core-client": "^7.6.17",
"@storybook/docs-tools": "^8.0.0",
"@storybook/global": "^5.0.0",
"@storybook/preview-api": "^7.6.4",
"@storybook/types": "^7.6.4"
"@storybook/preview-api": "^8.0.0",
"@storybook/types": "^8.0.0"
}
}
1 change: 1 addition & 0 deletions packages/renderers/marko/preset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("./dist/preset");
1 change: 0 additions & 1 deletion packages/renderers/marko/preview.js

This file was deleted.

6 changes: 0 additions & 6 deletions packages/renderers/marko/src/config.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/renderers/marko/src/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { sanitizeStoryContextUpdate } from "@storybook/preview-api";
import type { Args, DecoratorApplicator, StoryContext } from "@storybook/types";
import type { MarkoRenderer, MarkoStoryResult } from "./types";

export const decorateStory: DecoratorApplicator<MarkoRenderer, Args> = (
export const applyDecorators: DecoratorApplicator<MarkoRenderer, Args> = (
storyFn,
decorators,
) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
ArgTypesEnhancer,
} from "@storybook/types";

import type { MarkoStoryResult } from "../types";
import type { MarkoStoryResult } from "./types";

export const decorators: Addon_DecoratorFunction<MarkoStoryResult>[] = [];

Expand All @@ -19,3 +19,5 @@ export const parameters = {
};

export const argTypesEnhancers: ArgTypesEnhancer[] = [enhanceArgTypes];

export { applyDecorators } from "./decorators";
3 changes: 3 additions & 0 deletions packages/renderers/marko/src/entry-preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { renderToCanvas, render } from "./render";

export const parameters = { renderer: "marko" };
1 change: 0 additions & 1 deletion packages/renderers/marko/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/// <reference types="marko" />

import "./globals";
export * from "./public-api";
export * from "./public-types";
export * from "./testing-api";

Expand Down
15 changes: 15 additions & 0 deletions packages/renderers/marko/src/preset.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { join } from "path";
import type { PresetProperty } from "@storybook/types";

export const previewAnnotations: PresetProperty<"previewAnnotations"> = async (
input = [],
options,
) => {
const docsEnabled =
Object.keys(await options.presets.apply("docs", {}, options)).length > 0;
return [
...input,
join(__dirname, "entry-preview.mjs"),
...(docsEnabled ? [join(__dirname, "entry-preview-docs.mjs")] : []),
];
};
50 changes: 0 additions & 50 deletions packages/renderers/marko/src/public-api.ts

This file was deleted.

16 changes: 2 additions & 14 deletions packages/renderers/marko/src/testing-api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { deprecate } from "@storybook/client-logger";
import {
composeStories as originalComposeStories,
composeStory as originalComposeStory,
Expand All @@ -11,7 +10,7 @@ import type {
StoryAnnotationsOrFn,
} from "@storybook/types";

import { decorateStory } from "./decorators";
import { applyDecorators } from "./decorators";
import type { Meta, Story, Preview } from "./public-types";
import { render } from "./render";
import type { MarkoRenderer } from "./types";
Expand Down Expand Up @@ -50,21 +49,10 @@ export function setProjectAnnotations(projectAnnotations: Preview | Preview[]) {
originalSetProjectAnnotations<MarkoRenderer>(projectAnnotations);
}

/** Preserved for users migrating from `@storybook/marko@7`.
*
* @deprecated Use setProjectAnnotations instead
*/
export function setGlobalConfig(projectAnnotations: Preview | Preview[]) {
deprecate(
`setGlobalConfig is deprecated. Use setProjectAnnotations instead.`,
);
setProjectAnnotations(projectAnnotations);
}

// This will not be necessary once we have auto preset loading
const defaultProjectAnnotations: Preview = {
render,
applyDecorators: decorateStory,
applyDecorators,
};

/**
Expand Down
Loading