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

Addon-storysource: Replace loader with source-loader ✂ #7272

Merged
merged 12 commits into from
Jul 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ Publish failed
- Addon-docs: Docs page bugfix
- Addon-docs: Fix source block for legacy stories

NOTE: use `@storybook/addon-storysource/loader` with option `injectParameters: true` for legacy source
NOTE: use `@storybook/source-loader` with option `injectParameters: true` for legacy source

## 5.2.0-alpha.6 (May 14, 2019)

Expand Down
12 changes: 6 additions & 6 deletions addons/storysource/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Use this hook to a custom webpack.config. This will generate a decorator call in
module.exports = function({ config }) {
config.module.rules.push({
test: /\.stories\.jsx?$/,
loaders: [require.resolve('@storybook/addon-storysource/loader')],
loaders: [require.resolve('@storybook/source-loader')],
enforce: 'pre',
});

Expand Down Expand Up @@ -56,7 +56,7 @@ module.exports = function({ config }) {
test: /\.stories\.jsx?$/,
loaders: [
{
loader: require.resolve('@storybook/addon-storysource/loader'),
loader: require.resolve('@storybook/source-loader'),
options: { parser: 'typescript' },
},
],
Expand Down Expand Up @@ -91,7 +91,7 @@ module.exports = function({ config }) {
test: /\.stories\.jsx?$/,
loaders: [
{
loader: require.resolve('@storybook/addon-storysource/loader'),
loader: require.resolve('@storybook/source-loader'),
options: {
prettierConfig: {
printWidth: 100,
Expand Down Expand Up @@ -125,7 +125,7 @@ module.exports = function({ config }) {
test: /\.stories\.jsx?$/,
loaders: [
{
loader: require.resolve('@storybook/addon-storysource/loader'),
loader: require.resolve('@storybook/source-loader'),
options: {
uglyCommentsRegex: [/^eslint-.*/, /^global.*/],
},
Expand All @@ -140,7 +140,7 @@ module.exports = function({ config }) {

### injectDecorator

Tell storysource whether you need inject decorator.If false, you need to add the decorator by yourself;
Tell storysource whether you need inject decorator. If false, you need to add the decorator by yourself;

Defaults: true

Expand All @@ -152,7 +152,7 @@ module.exports = function({ config }) {
test: /\.stories\.jsx?$/,
loaders: [
{
loader: require.resolve('@storybook/addon-storysource/loader'),
loader: require.resolve('@storybook/source-loader'),
options: { injectDecorator: false },
},
],
Expand Down
2 changes: 1 addition & 1 deletion addons/storysource/loader.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./dist/loader');
module.exports = require('@storybook/source-loader');
Copy link
Member Author

Choose a reason for hiding this comment

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

for backward compatibility, but it will be recommended to change the usage in webpack of course.

3 changes: 2 additions & 1 deletion addons/storysource/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"regenerator-runtime": "^0.12.1"
},
"peerDependencies": {
"react": "*"
"react": "*",
"@storybook/source-loader": "*"
Copy link
Member Author

Choose a reason for hiding this comment

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

we will ask the developer to pull the source-loader separately

Copy link
Member

@Hypnosphi Hypnosphi Jul 20, 2019

Choose a reason for hiding this comment

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

@shilman @ndelangen should we add this line to our docs?

Please don't use caret when depending on Storybook packages, as we regularly do breaking changes in minor releases

},
"publishConfig": {
"access": "public"
Expand Down
3 changes: 1 addition & 2 deletions addons/storysource/src/StoryPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ export default class StoryPanel extends Component {
this.selectedStoryRef = ref;
};

listener = ({ source, currentLocation, locationsMap }) => {
listener = ({ edition: { source }, location: { currentLocation, locationsMap } }) => {
const locationsKeys = getLocationKeys(locationsMap);

this.setState({
source,
currentLocation,
Expand Down
2 changes: 1 addition & 1 deletion addons/storysource/src/events.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const ADDON_ID = 'storybook/storysource';
export const ADDON_ID = 'storybook/source-loader';
export const PANEL_ID = `${ADDON_ID}/panel`;
export const EVENT_ID = `${ADDON_ID}/set`;
Loading