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

Storyshots - Replace require_context.js with babel-plugin-require-context-hook #3757

Merged
merged 6 commits into from
Jun 16, 2018

Conversation

igor-dv
Copy link
Member

@igor-dv igor-dv commented Jun 12, 2018

Issue: #2894, #3406

What I did

Moved webpack's require.context() polyfilling out of the storyshots implementation to the babel. It removes the complexity of manual transpyling config.js, but just requiring it.

@igor-dv igor-dv self-assigned this Jun 12, 2018
@igor-dv igor-dv changed the title Storyshots - Replace require_context.js with babel-plugin-require-context-hook Storyshots - Replace require_context.js with babel-plugin-require-context-hook Jun 12, 2018
@codecov
Copy link

codecov bot commented Jun 12, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@b169f13). Click here to learn what that means.
The diff coverage is 80.95%.

Impacted file tree graph

@@           Coverage Diff            @@
##             master   #3757   +/-   ##
========================================
  Coverage          ?     41%           
========================================
  Files             ?     453           
  Lines             ?    5097           
  Branches          ?     858           
========================================
  Hits              ?    2090           
  Misses            ?    2491           
  Partials          ?     516
Impacted Files Coverage Δ
lib/core/src/server/config.js 0% <ø> (ø)
addons/storyshots/storyshots-core/src/api/index.js 82.35% <ø> (ø)
lib/core/server.js 0% <ø> (ø)
...hots/storyshots-core/src/frameworks/html/loader.js 14.28% <0%> (ø)
...shots/storyshots-core/src/frameworks/vue/loader.js 0% <0%> (ø)
...s/storyshots-core/src/frameworks/angular/loader.js 12.5% <0%> (ø)
...ots/storyshots-core/src/frameworks/react/loader.js 100% <100%> (ø)
...yshots/storyshots-core/src/frameworks/configure.js 100% <100%> (ø)
...s/storyshots-core/src/api/ensureOptionsDefaults.js 90% <90%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b169f13...34a4a08. Read the comment docs.

Copy link
Member

@tmeasday tmeasday left a comment

Choose a reason for hiding this comment

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

Looking forward to getting rid of that crazy code!

A couple small README comments

MIGRATION.md Outdated
@@ -46,6 +45,7 @@ The `@storybook/react-native` had built-in addons (`addon-actions` and `addon-li

1. `imageSnapshot` test function was extracted from `addon-storyshots` and moved to a new package - `addon-storyshots-puppeteer` that now will be dependant on puppeteer
2. `getSnapshotFileName` export was replaced with the `Stories2SnapsConverter` class that now can be overridden for a custom implementation of the snapshot-name generation
3. Storybook that was configured with Webpack's `require.context()` feature will need to add a babel plugin to polyfill this functionality. A possible plugin might be [babel-plugin-require-context-hook](https://github.com/smrq/babel-plugin-require-context-hook)
Copy link
Member

Choose a reason for hiding this comment

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

Is this advice for migrating users? Perhaps something more definite would be good here?

Copy link
Member Author

Choose a reason for hiding this comment

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

🤔 I can link to the README explanation about this. WDYT?

}
```

Make sure that it is added under the needed environment,
Copy link
Member

Choose a reason for hiding this comment

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

"Make sure not to include this babel plugin in the config environment that applies to webpack" -- might be a bit clearer?

@igor-dv igor-dv added the ready label Jun 13, 2018
@@ -1,43 +0,0 @@
import fs from 'fs';
import path from 'path';
import { getBabelConfig } from '@storybook/core/server';
Copy link
Member

Choose a reason for hiding this comment

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

This export can probably be removed from @storybook/core now, as well as @storybook/<framework>/options.js endpoints

Copy link
Member Author

Choose a reason for hiding this comment

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

Will remove

@Hypnosphi Hypnosphi merged commit 5468468 into master Jun 16, 2018
@Hypnosphi Hypnosphi deleted the storyshots-remove-require-context branch June 16, 2018 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants