Skip to content

Commit

Permalink
fix: error log on stories not loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Mar 16, 2020
1 parent 5aeea92 commit 5452a1b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
46 changes: 25 additions & 21 deletions core/loader/src/story-store-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,34 @@ const loadStoryStore = (): StoriesStore | undefined => {
Object.keys(store.kinds).forEach(kindName => {
const kind = store.kinds[kindName];

if (kind.moduleId) {
try {
// './src/stories/smart-prop-type.stories.js'
const exports = __webpack_require__(kind.moduleId);
Object.keys(exports).forEach(key => {
const exported = exports[key];
if (key === 'default') {
const { storySource, ...rest } = exported;
Object.assign(kind, rest);
} else {
const story = store.stories[key];
if (story) {
story.renderFn = exported;
if (exported.story) {
Object.assign(story, exported.story);
if (kind.moduleId && __webpack_require__) {
if (!__webpack_require__.m[kind.moduleId].l) {
console.error(`module not loaded yet ${kind.moduleId}`);
} else {
try {
// './src/stories/smart-prop-type.stories.js'
const exports = __webpack_require__(kind.moduleId);
Object.keys(exports).forEach(key => {
const exported = exports[key];
if (key === 'default') {
const { storySource, ...rest } = exported;
Object.assign(kind, rest);
} else {
const story = store.stories[key];
if (story) {
story.renderFn = exported;
if (exported.story) {
Object.assign(story, exported.story);
}
}
}
}
});
} catch (e) {
console.error(`unable to load module ${kind.moduleId}`);
});
} catch (e) {
console.error(`unable to load module ${kind.moduleId}`);
}
// clean-up
delete kind.moduleId;
}
// clean-up
delete kind.moduleId;
}
globalStore.kinds[kindName] = kind;
Object.keys(store.stories).forEach(storyName => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
title: 'Storybook/Kind',
component: ControlsTable,
controls: {
name: { type: ControlTypes.TEXT, label: 'Name', value: 'Mark', order: 9999 },
name: { type: 'text', label: 'Name', value: 'Mark', order: 9999 },
},
};

Expand All @@ -24,6 +24,6 @@ export const docsControlsTable = ({ name, age }: DocsControlsTable) => {

docsControlsTable.story = {
controls: {
age: { type: ControlTypes.NUMBER, label: 'Age', value: 19, min: 10, max: 75, step: 5 },
age: { type: 'number', label: 'Age', value: 19, min: 10, max: 75, step: 5 },
},
};

0 comments on commit 5452a1b

Please sign in to comment.