Skip to content

Commit

Permalink
fix(storybook-builder): import both globals and globalsNameReferenceM…
Browse files Browse the repository at this point in the history
…ap from @storybook/preview/globals
  • Loading branch information
jdevega committed Jan 24, 2024
1 parent 78abb0a commit 201887e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
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';
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

0 comments on commit 201887e

Please sign in to comment.