Open tmeasday opened 5 years ago
I ended up publishing a macro here.
https://github.com/storybooks/require-context.macro
I saw that there's been a PR open for a few weeks and figured you were busy.
Let me know if you'll accept a PR that essentially brings in the above library! I'd rather have the macro exported here, since it's basically all your work.
Hi @smrq thanks again for this plugin!
For storybook users using setups like create-react-app, using a babel plugin may not be an option; however a babel macro is. (This may only apply to CRA but it's a lot of folks I guess).
Would you consider adding a babel macro? I've done a POC here: https://github.com/tmeasday/require-context.macro/blob/master/require-context.macro.js
The basic idea is, you use it like:
When babel is run via storybook (i.e.
NODE_ENV !== 'test'
), it will output:When babel is run via jest (i.e. `NODE_ENV === 'test'), it will output:
Does this make sense to you? I can submit a PR? (I'm not really sure what I am doing with babel though)