Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: rework imports in preview virtual module to fix Yarn 2 comp…
…atibility Using ES6 import directly in `preview.js-generated-config-entry.js` module definition is causing the following error when using Yarn 2: ``` ERROR in ./.storybook/preview.js-generated-config-entry.js Module not found: Error: Something that got detected as your top-level application (because it doesn't seem to belong to any package) tried to access a package that is not declared in your dependencies Required package: @storybook/client-api (via "@storybook/client-api") Required by: /Users/dev/project/.storybook/preview.js-generated-config-entry.js ``` This is because the code of the virtual module is importing @storybook/client-api and @storybook/client-logger. When the code is executed these packages are required in the context of SB user project and not in the one of `@storybook/core` causing Yarn 2 to throw. To avoid this, we are now resolving theses deps directly when webpack config is built (so in `@storybook/core` context) and then using the resolved values in the virtual module. The change is done only for PnP users to avoid issues when running SB examples available in this monorepo, if examples are extracted somewhere else the `require.resolve` behavior can be applied in a non PnP situation.
- Loading branch information