Skip to content

Commit

Permalink
fix: loader options update for instrument
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Mar 6, 2020
1 parent 93bc1f4 commit 89645a8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
6 changes: 3 additions & 3 deletions core/loader/src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ import { addStoriesKind } from './store';

module.exports.default = async function(source: string) {
const options: LoaderOptions = getOptions(this) || {};
const { type = 'csf', prettier } = options;
const { type = 'csf', ...instrumentOptions } = options;
const context = this as loader.LoaderContext;
const filePath = context.resourcePath;
let store: StoriesStore;
switch (type) {
case 'csf':
store = await parseCSF(source, filePath, prettier);
store = await parseCSF(source, filePath, instrumentOptions);
break;
case 'mdx':
store = await parseMDX(source, filePath, prettier);
store = await parseMDX(source, filePath, instrumentOptions);
break;
}
if (store) {
Expand Down
7 changes: 3 additions & 4 deletions core/loader/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { PrettierOptions } from '@component-controls/instrument';
import { InstrumentOptions } from '@component-controls/instrument';

export interface LoaderOptions {
export type LoaderOptions = {
type?: 'csf' | 'mdx';
prettier?: PrettierOptions;
}
} & InstrumentOptions;
2 changes: 1 addition & 1 deletion examples/storybook-5/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module.exports = {
options: {
type: 'csf',
prettier: {
tabWidth: 2,
tabWidth: 4,
}
},
},
Expand Down

0 comments on commit 89645a8

Please sign in to comment.