-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Conversation
require_context.js
with babel-plugin-require-context-hook
Codecov Report
@@ Coverage Diff @@
## master #3757 +/- ##
========================================
Coverage ? 41%
========================================
Files ? 453
Lines ? 5097
Branches ? 858
========================================
Hits ? 2090
Misses ? 2491
Partials ? 516
Continue to review full report at Codecov.
|
There was a problem hiding this 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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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?
@@ -1,43 +0,0 @@ | |||
import fs from 'fs'; | |||
import path from 'path'; | |||
import { getBabelConfig } from '@storybook/core/server'; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will remove
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 transpylingconfig.js
, but just requiring it.