Merge pull request #8773 from donaldpipowitch/fix-8294-source-loader

Source-loader: Warn if applied to non-stories file
This commit is contained in:
Michael Shilman 2019-11-11 17:55:09 +08:00 committed by GitHub
commit 52a5dc554d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View File

@ -29,6 +29,7 @@
},
"dependencies": {
"@storybook/addons": "5.3.0-alpha.42",
"@storybook/client-logger": "5.3.0-alpha.42",
"@storybook/router": "5.3.0-alpha.42",
"core-js": "^3.0.1",
"estraverse": "^4.2.0",

View File

@ -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];
@ -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);