Skip to content

Commit

Permalink
Merge pull request #19300 from storybookjs/remove-react-classes-global
Browse files Browse the repository at this point in the history
Docs: Remove STORYBOOK_REACT_CLASSES and global/globals.ts
  • Loading branch information
ndelangen authored Oct 3, 2022
2 parents b2ad45c + bba5c8c commit a14ca00
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 27 deletions.
6 changes: 5 additions & 1 deletion MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
- [7.0 feature flags removed](#70-feature-flags-removed)
- [Vite builder uses vite config automatically](#vite-builder-uses-vite-config-automatically)
- [Removed docs.getContainer and getPage parameters](#removed-docsgetcontainer-and-getpage-parameters)
- [Removed STORYBOOK_REACT_CLASSES global](#removed-storybook_react_classes-global)
- [Icons API changed](#icons-api-changed)
- ['config' preset entry replaced with 'previewAnnotations'](#config-preset-entry-replaced-with-previewannotations)
- [Vue2 DOM structure changed](#vue2-dom-structure-changed)
- [Docs Changes](#docs-changes)
- [Standalone docs files](#standalone-docs-files)
- [Referencing stories in docs files](#referencing-stories-in-docs-files)
Expand Down Expand Up @@ -530,6 +530,10 @@ If you were using `viteFinal` in 6.5 to simply merge in your project's standard

It is no longer possible to set `parameters.docs.getContainer()` and `getPage()`. Instead use `parameters.docs.container` or `parameters.docs.page` directly.

#### Removed STORYBOOK_REACT_CLASSES global

This was a legacy global variable from the early days of react docgen. If you were using this variable, you can instead use docgen information which is added directly to components using `.__docgenInfo`.

#### Icons API changed

For addon authors who use the `Icons` component, its API has been updated in Storybook 7.
Expand Down
1 change: 0 additions & 1 deletion code/addons/storyshots/storyshots-core/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import loadFramework from '../frameworks/frameworkLoader';
import { StoryshotsOptions } from './StoryshotsOptions';

const { describe, window: globalWindow } = global;
global.STORYBOOK_REACT_CLASSES = global.STORYBOOK_REACT_CLASSES || {};

type TestMethod = 'beforeAll' | 'beforeEach' | 'afterEach' | 'afterAll';
const methods: TestMethod[] = ['beforeAll', 'beforeEach', 'afterEach', 'afterAll'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,6 @@ const newWebpackConfiguration = (
devtool: 'cheap-module-source-map',
entry: [
'/Users/joe/storybook/lib/core-server/dist/esm/globals/polyfills.js',
'/Users/joe/storybook/lib/core-server/dist/esm/globals/globals.js',
'/Users/joe/storybook/examples/angular-cli/.storybook/storybook-init-framework-entry.js',
'/Users/joe/storybook/addons/docs/dist/esm/frameworks/common/config.js-generated-other-entry.js',
'/Users/joe/storybook/addons/docs/dist/esm/frameworks/angular/config.js-generated-other-entry.js',
Expand Down
5 changes: 0 additions & 5 deletions code/lib/core-client/src/globals/globals.ts

This file was deleted.

2 changes: 1 addition & 1 deletion code/lib/core-server/src/presets/common-preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const previewAnnotations = async (base: any, options: Options) => {

if (config.length > 0) warnConfigField();

return [...config, require.resolve('@storybook/core-client/dist/esm/globals/globals'), ...base];
return [...config, ...base];
};

export const features = async (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,7 @@ describe('framework-preset-react-docgen', () => {
overrides: [
{
test: /\.(cjs|mjs|tsx?|jsx?)$/,
plugins: [
[
babelPluginReactDocgenPath,
{
DOC_GEN_COLLECTION_NAME: 'STORYBOOK_REACT_CLASSES',
},
],
],
plugins: [[babelPluginReactDocgenPath]],
},
],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,7 @@ export const babel: StorybookConfig['babel'] = async (config, options) => {
...(config?.overrides || []),
{
test: reactDocgen === 'react-docgen' ? /\.(cjs|mjs|tsx?|jsx?)$/ : /\.(cjs|mjs|jsx?)$/,
plugins: [
[
require.resolve('babel-plugin-react-docgen'),
{
DOC_GEN_COLLECTION_NAME: 'STORYBOOK_REACT_CLASSES',
},
],
],
plugins: [[require.resolve('babel-plugin-react-docgen')]],
},
],
};
Expand Down
1 change: 0 additions & 1 deletion code/renderers/vue/src/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ import global from 'global';

const { window: globalWindow } = global;

globalWindow.STORYBOOK_REACT_CLASSES = {};
globalWindow.STORYBOOK_ENV = 'vue';
1 change: 0 additions & 1 deletion code/renderers/vue3/src/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ import global from 'global';

const { window: globalWindow } = global;

globalWindow.STORYBOOK_REACT_CLASSES = {};
globalWindow.STORYBOOK_ENV = 'vue3';

0 comments on commit a14ca00

Please sign in to comment.