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

Sync updates from storycap upstream #7

Merged
merged 246 commits into from
Oct 4, 2023
Merged

Sync updates from storycap upstream #7

merged 246 commits into from
Oct 4, 2023

Conversation

throwandgo
Copy link

@throwandgo throwandgo commented Oct 3, 2023

Pull in new changes from reg-viz/storycap, including the ability to shard screenshot captures across machines. We anticipate using this feature to ease the burden placed on individual CircleCI instances, since screenshot captures can be resource- and time-intensive.

Resolved conflicts on:

  • packages/storycap/package.json
  • packages/storycap/src/node/capturing-browser.ts
  • packages/storycap/src/shared/screenshot-options-helper.ts

Since we last synced from upstream, the following changes have been accepted:

We continue to maintain this fork because we're waiting for this issue to be addressed:

This sync is reflected in a version bump of our fork from 1.0.4 to 1.1.0.

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.
The previous commit updates the test harness to simulate the
installation of a '@remix/storycap' package instead of a 'storycap'
package, which requires us to introduce a Webpack alias so all of the
Storybook code points to our custom package. This is difficult to do
in Storybook v5, which structures its configuration files differently
(at least, before v5.3). Rather than spending time trying to figure out
how to make this work, we opt to skip the tests for Storybook v5, since
we're already on Storybook v6 in the Remix monorepo anyways.

See:
https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#from-version-52x-to-53x.
@throwandgo
Copy link
Author

@Jamie5 and @davidmh, I'm curious to get your take on the last two commits in particular. There is additional detail in the individual commit messages: 270565d..b8ba72a.

@throwandgo
Copy link
Author

Got Jamie's approval offline!

@throwandgo throwandgo merged commit 64f5866 into master Oct 4, 2023
6 checks passed
@davidmh davidmh deleted the austin-david/sync branch October 4, 2023 20:22
if (prjDir === dist) {
console.error(`target dir shold not be "${prjDir}".`);
console.error(`target dir should not be "${prjDir}".`);

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet