mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-02 05:03:44 +08:00
Merge pull request #8773 from donaldpipowitch/fix-8294-source-loader
Source-loader: Warn if applied to non-stories file
This commit is contained in:
commit
52a5dc554d
@ -29,6 +29,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@storybook/addons": "5.3.0-alpha.42",
|
"@storybook/addons": "5.3.0-alpha.42",
|
||||||
|
"@storybook/client-logger": "5.3.0-alpha.42",
|
||||||
"@storybook/router": "5.3.0-alpha.42",
|
"@storybook/router": "5.3.0-alpha.42",
|
||||||
"core-js": "^3.0.1",
|
"core-js": "^3.0.1",
|
||||||
"estraverse": "^4.2.0",
|
"estraverse": "^4.2.0",
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import addons from '@storybook/addons';
|
import addons from '@storybook/addons';
|
||||||
|
import { logger } from '@storybook/client-logger';
|
||||||
import { STORY_EVENT_ID } from './events';
|
import { STORY_EVENT_ID } from './events';
|
||||||
|
|
||||||
const getLocation = (context, locationsMap) => locationsMap[context.id];
|
const getLocation = (context, locationsMap) => locationsMap[context.id];
|
||||||
@ -13,6 +14,14 @@ function sendEvent(
|
|||||||
prefix,
|
prefix,
|
||||||
idsToFrameworks
|
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 channel = addons.getChannel();
|
||||||
const currentLocation = getLocation(context, locationsMap);
|
const currentLocation = getLocation(context, locationsMap);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user