Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: import or require() statements can be added only by editing a Markdown #1312

Closed
davidpaley opened this issue Mar 7, 2019 · 6 comments

Comments

@davidpaley
Copy link

I'm trying to make an example of my component in the Markdown file (.md). The problem is when I try to import something inside this markdown file:

import { validateEmail } from '../../utils/validation';

initialState = {
  value: 'asdas',
}

function updateValue(name, value) {
  setState({ [name]: value });  
}

<Input
  placeholder="Name"
  value={value}
  type="text"
  required={true}
  name="value"
  onChangeFunction={updateValue}
  validations={[validateEmail]}
/>;

When I go to the component it says:
Error: import or require() statements can be added only by editing a Markdown example file: ../../utils/validation

image

I tried also with require but it didn't work.

versions:

  • react-styleguidist": "^9.0.3"
  • "react": "^16.7.0",

Example of my project:
https://github.com/aimementoring/blueprint
branch: feature/validations

To reproduce

  • download the project and execute:
  • yarn
  • yarn deploy
  • serve -s styleguide
  • go to the input component.
@kopax
Copy link
Collaborator

kopax commented Mar 7, 2019

I think this is the same as #1310, we are currently invistagating for the root cause but we couldn't find, let us know if you get why. To me, all the module aliases are not working within examples.

The one think we can import is react. Can you please confirm that you can't import dependencies listed in package.json dependencies ?

@davidpaley
Copy link
Author

davidpaley commented Mar 7, 2019

Yes, me too. I have the error if I try to import any of the package.json dependencies except for react.

@timsnadden
Copy link
Contributor

timsnadden commented Mar 7, 2019

Try deleting yarn.lock|package-lock.json and reinstalling. I'm not sure which dependency is causing the issue but this fixes it

@kopax
Copy link
Collaborator

kopax commented Mar 7, 2019

@timsnadden I don´t know where you got this. I am a package maintainer and we allow the wider range of semver for our users, We want to see things break and we do not use lock file for that reason (except in app). The only thing it could have change on your side is that it upgraded version on your particular host. To me, I already have the latest version and this bug is still present. You´re advice won´t help.

@timsnadden
Copy link
Contributor

@kopax For me the issue was resolved by removing yarn.lock and reinstalling. It's a hacky solution but can perhaps provide a clue to identify the root cause. I'm sorry it didn't resolve the issue for you

@kopax
Copy link
Collaborator

kopax commented Mar 9, 2019

Ok, now I got it and you are right. Let's continue in #1278

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants