forked from reg-viz/storycap
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Alias 'storycap' to '@remix/storycap' for Storybook v7+
Storybook v7+ uses Webpack 5, which follows a different module resolution strategy than Webpack 4. This is mostly irrelevant for this fork of reg-viz/storycap, but it proves to be problematic in test. The package generated from this fork goes by the name '@remix/storycap' instead of 'storycap', and we made edits to the root `package.json` file to reflect the name difference. Among other things, the test harness for 'storycap' copies the root package.json and the package's compiled JS into the `node_modules` subdirectories under `examples/*`, simulating the installation of 'storycap' via npm/yarn. Each 'storybook' version (v5, v6, and v7) has at least one set of examples so that 'storycap' can be tested against each one. For 'storybook' v5 and v6, the tests pass successfully. However, for 'storybook' v7, the use of Webpack 5 and its module resolution strategy causes module lookup issues for 'storycap'; the 'storycap' directory can be found under `node_modules`, but the custom package name ('@remix/storycap') causes the module lookup to ultimately fail. For consistency, this commit simulates the installation of a '@remix/storycap' package instead of a 'storycap' package, since this is what we'd like to test anyways. Now, the name of the directory under `node_modules` matches the declared package name in `package.json`. We don't want to tinker with the test setup too much further, so instead of replacing all references to 'storycap' with '@remix/storycap', we instead update the Storybook Webpack config to alias 'storycap' to '@remix/storycap', which works in all places but one. This solution isn't ideal, but it prevents us from drifting further from upstream, which is nice. At current date, there's only a 2 line diff that forces us to keep this fork: exposing `setViewport` so that the viewport can be set dynamically before the test is run. In the future, we would love to get this change merged into upstream. In the meantime, we try to keep the set of changes to this fork as minimal as possible to make the eventual cleanup straightforward.
- Loading branch information
1 parent
270565d
commit ecf696b
Showing
7 changed files
with
59 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,16 @@ | ||
module.exports = { | ||
stories: ['../src/**/*.stories.@(js|jsx|mdx)'], | ||
addons: ['@storybook/addon-actions', '@storybook/addon-links', 'storycap'], | ||
webpackFinal: async (config) => { | ||
return { | ||
...config, | ||
resolve: { | ||
...config.resolve, | ||
alias: { | ||
...config.resolve.alias, | ||
storycap: '@remix/storycap', | ||
} | ||
} | ||
}; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters