From 01ca39589b5f1fed3c92131eee5632cf04bdc2a9 Mon Sep 17 00:00:00 2001 From: Donald Pipowitch Date: Sat, 9 Nov 2019 14:33:43 +0100 Subject: [PATCH 1/3] check context in source-loader --- lib/source-loader/src/client/preview.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/source-loader/src/client/preview.js b/lib/source-loader/src/client/preview.js index 7a03d3f576bd..fede46c93c5b 100644 --- a/lib/source-loader/src/client/preview.js +++ b/lib/source-loader/src/client/preview.js @@ -13,6 +13,14 @@ function sendEvent( prefix, idsToFrameworks ) { + if (!context || !context.id || !context.kind || !context.story) { + console.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:' + ); + console.warn(source); + return; + } + const channel = addons.getChannel(); const currentLocation = getLocation(context, locationsMap); From e4ab56d9a319caf60845ba201964e4188ece9ede Mon Sep 17 00:00:00 2001 From: Donald Pipowitch Date: Sun, 10 Nov 2019 19:51:49 +0100 Subject: [PATCH 2/3] updated logging based on feedback --- lib/source-loader/package.json | 1 + lib/source-loader/src/client/preview.js | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/source-loader/package.json b/lib/source-loader/package.json index 6e8c7c70af20..7dc8c5309400 100644 --- a/lib/source-loader/package.json +++ b/lib/source-loader/package.json @@ -29,6 +29,7 @@ }, "dependencies": { "@storybook/addons": "5.3.0-alpha.42", + "@storybook/node-logger": "5.3.0-alpha.42", "@storybook/router": "5.3.0-alpha.42", "core-js": "^3.0.1", "estraverse": "^4.2.0", diff --git a/lib/source-loader/src/client/preview.js b/lib/source-loader/src/client/preview.js index fede46c93c5b..00c15d9afeb7 100644 --- a/lib/source-loader/src/client/preview.js +++ b/lib/source-loader/src/client/preview.js @@ -1,4 +1,5 @@ import addons from '@storybook/addons'; +import { logger } from '@storybook/node-logger'; import { STORY_EVENT_ID } from './events'; const getLocation = (context, locationsMap) => locationsMap[context.id]; @@ -14,10 +15,10 @@ function sendEvent( idsToFrameworks ) { if (!context || !context.id || !context.kind || !context.story) { - console.warn( + 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:' ); - console.warn(source); + logger.warn(source); return; } From 0e80a46d4d4b64ebc41467a9a3256edd5c25de90 Mon Sep 17 00:00:00 2001 From: Donald Pipowitch Date: Mon, 11 Nov 2019 07:26:38 +0100 Subject: [PATCH 3/3] fixed logger --- lib/source-loader/package.json | 2 +- lib/source-loader/src/client/preview.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/source-loader/package.json b/lib/source-loader/package.json index 7dc8c5309400..b6ed56b19a48 100644 --- a/lib/source-loader/package.json +++ b/lib/source-loader/package.json @@ -29,7 +29,7 @@ }, "dependencies": { "@storybook/addons": "5.3.0-alpha.42", - "@storybook/node-logger": "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", diff --git a/lib/source-loader/src/client/preview.js b/lib/source-loader/src/client/preview.js index 00c15d9afeb7..05491f18cf8b 100644 --- a/lib/source-loader/src/client/preview.js +++ b/lib/source-loader/src/client/preview.js @@ -1,5 +1,5 @@ import addons from '@storybook/addons'; -import { logger } from '@storybook/node-logger'; +import { logger } from '@storybook/client-logger'; import { STORY_EVENT_ID } from './events'; const getLocation = (context, locationsMap) => locationsMap[context.id];