vue-styleguidist: Error: import or require() statements can be added only by editing a Markdown example file
Hi!
I updated vue-styleguidist from 2.1.2 to 3.13.4. After the update requiring json-data for the documentation examples in the markdown does not work. The example below works on 2.1.2 but is broken on 3.13.4. I did not notice any comments related to this in the release-notes.
My markdown looks something like this:
const tableData = require('./tabledata.json')
<div>
<my-fancy-table
:data="tableData" />
</div>
Current behavior
Does not render the component, but it renders an error:
“Error: import or require() statements can be added only by editing a Markdown example file”
Expected behavior
Should render the component with required sample data.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 23 (12 by maintainers)
Commits related to this issue
- fix(core): example loader needs to require only on the script Closes #421 — committed to vue-styleguidist/vue-styleguidist by elevatebart 5 years ago
I found the issue and it was easy to fix 😉 Thank you @RyanHavoc for setting up the repro
@elevatebart Sure. I’ve created this: https://github.com/RyanHavoc/vue-sg
Note the example in the cookbook for accessing components in markdown files: https://vue-styleguidist.github.io/docs/Cookbook.html#how-to-hide-some-components-in-style-guide-but-make-them-available-in-examples
I see this:
If I remove the
Vue
require I get the error everyones talking about here.