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

fix(storybook-builder): import both globals and globalsNameReferenceM… #2620

Merged
merged 1 commit into from
Jan 24, 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
5 changes: 5 additions & 0 deletions .changeset/khaki-melons-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@web/storybook-builder': patch
---

fix: import both globals and globalsNameReferenceMap from @storybook/preview/globals and use the one that is set. This fixes issue https://github.com/modernweb-dev/web/issues/2619
8 changes: 5 additions & 3 deletions packages/storybook-builder/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import rollupPluginNodeResolve from '@rollup/plugin-node-resolve';
import { getBuilderOptions } from '@storybook/core-common';
import { logger } from '@storybook/node-logger';
import { globals } from '@storybook/preview/globals';
// Import both globals and globalsNameReferenceMap to prevent retrocompatibility.
// @ts-ignore
import { globals, globalsNameReferenceMap } from '@storybook/preview/globals';
Copy link
Member

Choose a reason for hiding this comment

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

wouldnt just the globalsNameReferenceMap be enough? Why are we using both?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for retrocompatibility. Those using 7.5.3 or lower will have an error if we don't support the previous behaviour.

Copy link
Member

Choose a reason for hiding this comment

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

Ah I see. Could you add a comment to the import that we import both for this reason? Just so we'll know why this is in the future :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

Choose a reason for hiding this comment

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

Thanks :) just running CI to make sure everything passes, then we can merge it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, fixed linting problems

import type { Builder, Options, StorybookConfig as StorybookConfigBase } from '@storybook/types';
import { DevServerConfig, mergeConfigs, startDevServer } from '@web/dev-server';
import type { DevServer } from '@web/dev-server-core';
Expand Down Expand Up @@ -74,7 +76,7 @@ export const start: WdsBuilder['start'] = async ({ startTime, options, router, s
},
wdsPluginPrebundleModules(env),
wdsPluginStorybookBuilder(options),
wdsPluginExternalGlobals(globals),
wdsPluginExternalGlobals(globalsNameReferenceMap || globals),
],
};

Expand Down Expand Up @@ -146,7 +148,7 @@ export const build: WdsBuilder['build'] = async ({ startTime, options }) => {
rollupPluginNodeResolve(),
rollupPluginPrebundleModules(env),
rollupPluginStorybookBuilder(options),
rollupPluginExternalGlobals(globals),
rollupPluginExternalGlobals(globalsNameReferenceMap || globals),
],
};

Expand Down
Loading