Skip to content

Commit

Permalink
Merge pull request #8773 from donaldpipowitch/fix-8294-source-loader
Browse files Browse the repository at this point in the history
Source-loader: Warn if applied to non-stories file
  • Loading branch information
shilman committed Dec 2, 2019
1 parent a03c730 commit a815e55
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/source-loader/package.json
Expand Up @@ -29,6 +29,7 @@
},
"dependencies": {
"@storybook/addons": "5.2.7",
"@storybook/client-logger": "5.2.7",
"@storybook/router": "5.2.7",
"core-js": "^3.0.1",
"estraverse": "^4.2.0",
Expand Down
9 changes: 9 additions & 0 deletions lib/source-loader/src/client/preview.js
@@ -1,4 +1,5 @@
import addons from '@storybook/addons';
import { logger } from '@storybook/client-logger';
import { STORY_EVENT_ID } from './events';

const getLocation = (context, locationsMap) => locationsMap[context.id];
Expand All @@ -13,6 +14,14 @@ function sendEvent(
prefix,
idsToFrameworks
) {
if (!context || !context.id || !context.kind || !context.story) {
logger.warn(
'@storybook/source-loader was applied to a file which does not contain a story. Please check your webpack configuration and make sure to apply @storybook/source-loader only to files containg stories. Related file:'
);
logger.warn(source);
return;
}

const channel = addons.getChannel();
const currentLocation = getLocation(context, locationsMap);

Expand Down

0 comments on commit a815e55

Please sign in to comment.