bit icon indicating copy to clipboard operation
bit copied to clipboard

error compiling mdx

Open KutnerUri opened this issue 5 years ago • 11 comments

Getting this error:

Failed to compile

Module parse failed: Assigning to rvalue (4:2)
File was processed with these loaders:
 * ../../../.bvm/versions/0.0.493/bit-0.0.493/node_modules/@pmmmwh/react-refresh-webpack-plugin/loader/index.js
You may need an additional loader to handle the result of these loaders.
| $RefreshSetup$(module.id);
| 
> ---
| labels: ['react', 'typescript', 'input', 'search']
| description: 'basic search bard'

It seems it's trying to load the mdx with the react fast refresh, before compiling it to JS.

I will investigate.

Describe the bug

A clear and concise description of the issue.

Steps to Reproduce

  1. Open workspace
  2. use bit create to make a new component, ie,

❯ bit create react-component ui/input/search-box

  1. bit start

--> get the error

Screenshots, exceptions and logs

Screen Shot 2021-08-25 at 18 38 09

Specifications

  • Bit version: 0.0.493
  • Workspace type: harmony
  • Node version:
  • npm / yarn version:
  • Platform: MacOS

for harmony workspace

  • relevant env: teambit.design/envs/react

KutnerUri avatar Aug 25 '21 15:08 KutnerUri

This happened from time to time to different users. It usually fixed by delete node_modules and re install. So make sure you are debugging it before deleting node_modules

GiladShoham avatar Aug 25 '21 16:08 GiladShoham

ah ok, it's not a blocker. Just tried it in a new project, and it doesn't happen (😥 )

I'll keep a zip of the workspace and try it again..

KutnerUri avatar Aug 25 '21 16:08 KutnerUri

For me this error happens when the server is started and I create a new component. To resolve it, I have to stop the server, execute bit compile and then start the server again.

dstoyanoff avatar Aug 26 '21 12:08 dstoyanoff

I've also seen this error if you happen to have invalid syntax in your mdx file. I've found it useful to remove all content from the file with the exception of the top line and see if the error goes away. If it does you can start adding back a few lines at a time.

blankenshipd001 avatar Sep 02 '21 15:09 blankenshipd001

This may be not installed bit components dependencies. Use bit install and bit compile. Then restart server. I resolved the error with this method.

ZyJoey avatar Oct 27 '21 10:10 ZyJoey

this is likely to have been solved by #5067, so it should not happen again from v0.0.570 onwards. The fix set react-fast-refresh loaders explicitly, making it's order preset, and should prevent incorrect loaders trying to parse markdown files.

repoen the issue if the problem resurfaces :)

KutnerUri avatar Nov 24 '21 13:11 KutnerUri

v0.0.638 the issue still exists:

image

aweiu avatar Jan 29 '22 07:01 aweiu

Still happens with yarn but not pnpm

pkhodaveissi avatar Feb 14 '22 14:02 pkhodaveissi

interesting. why would it happen on yarn? 🤔

also, I've noticed a distinction between *.docs.mdx and plain *.mdx files:

plugins-page/
  plugin-page.docs.mdx # <-- should work out of the box
  plugins-page.mdx # <-- needs env to be mdx
  index.ts

you can apply the mdx env by using this command:

❯ bit envs set my-component teambit.mdx/mdx 

KutnerUri avatar Feb 23 '22 10:02 KutnerUri

interesting. why would it happen on yarn? 🤔

also, I've noticed a distinction between *.docs.mdx and plain *.mdx files:


plugins-page/

  plugin-page.docs.mdx # <-- should work out of the box

  plugins-page.mdx # <-- needs env to be mdx

  index.ts

you can apply the mdx env by using this command:


❯ bit envs set my-component teambit.mdx/mdx 

You need to run a bit link after bit install if you're using yarn. But pnpm does that automatically I guess.

pkhodaveissi avatar Feb 23 '22 12:02 pkhodaveissi

interesting. @pkhodaveissi - can you open a new in depth issue about it? @GiladShoham will handle

KutnerUri avatar Feb 23 '22 17:02 KutnerUri