Skip to content

You may need an appropriate loader to handle this file type #5286

Closed

Description

@hhimanshu

🐛 Bug Report

Prerequisites

Description

I am following the example of https://docusaurus.io/docs/markdown-features/react#importing-markdown and it fails

Have you read the [Contributing Guidelines on issues]

Steps to reproduce

  1. Clone https://github.com/hhimanshu/docusaurus-101
  2. yarn install and yarn start

Expected behavior

The app should have loaded correctly as per documentation

Actual behavior

The app fails with following error

Failed to compile
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> <span>Hello {props.name}</span>
| 
| This is text some content from `_markdown-partial-example.mdx`.
This error occurred during the build time and cannot be dismissed.

Your environment

Reproducible demo

Use https://new.docusaurus.io to create a CodeSandbox reproducible demo of the bug.

(Paste the link to an example repo, including a docusaurus.config.js, and exact instructions to reproduce the issue.)

Activity

  1. added
    bug
    status: needs triage
    on Aug 4, 2021
  2. slorber commented on Aug 4, 2021

    @slorber
    Collaborator
  3. hhimanshu commented on Aug 4, 2021

    @hhimanshu
    Author

    Hey @slorber , the file I am trying to import is a relative import. See here

    Ideally, I would like blogs to have folders like

    blog/
           2021-08-01/
                               index.md
                               _partial.md
                              images/
                                          one.jpeg
                                          two.jpeg
    
          2021-08-04/
                               index.md
                               _partial-1.md
                              images/
                                          three.jpeg
                                          four.jpeg
    
    

    But, I am not sure if this is a possibility

  4. cveilleux commented on Aug 4, 2021

    @cveilleux

    I don't know if it is related, but we have started having build failures in the last 4 hours:

    Module parse failed: Unexpected token (6:128)
    File was processed with these loaders:
     * ./node_modules/babel-loader/lib/index.js
    You may need an additional loader to handle the result of these loaders.
    |  * This source code is licensed under the MIT license found in the
    |  * LICENSE file in the root directory of this source tree.
    >  */import React from'react';var ThemeContext=/*#__PURE__*/React.createContext(undefined);ThemeContext.displayName="ThemeContext"export default ThemeContext;
    Client bundle compiled with errors therefore further build is impossible.
    

    package.json:

      "dependencies": {
        "@docusaurus/core": "2.0.0-beta.4d06f26c1",
        "@docusaurus/preset-classic": "2.0.0-beta.4d06f26c1",
        "@mdx-js/react": "^1.6.21",
        "clsx": "^1.1.1",
        "react": "^17.0.1",
        "react-dom": "^17.0.1"
      },
    

    I have a build that passed at 3pm today and is now failing at 6pm (same exact code-base).

  5. Josh-Cena commented on Aug 5, 2021

    @Josh-Cena
    Collaborator

    @cveilleux Can verify. Even the CI in this repo is failing:

    https://github.com/facebook/docusaurus/pull/5284/checks?check_run_id=3247384304

    Maybe you can open another issue as this looks like a different bug, but keeping it here is fine as well

  6. lex111 commented on Aug 5, 2021

    @lex111
    Contributor

    Apparently a bug was in our dependency babel core, so they just released new version, which should fix this issue.
    Try to reinstall all dependencies completely, removing your node_modules directory and lock file beforehand.

  7. slorber commented on Aug 5, 2021

    @slorber
    Collaborator

    @hhimanshu there are 2 bugs here.

    • The first is a known limitation of Docusaurus that we'll fix. MD files must currently be in docs, blog or src/pages folder, unfortunately, other places like src/components/_markdownPartial.mdx do not work.
    • Second is a temporary babel bug that we have since a few hours: Brand new docusaurus installation not building #5287
  8. hhimanshu commented on Aug 5, 2021

    @hhimanshu
    Author

    @slorber , I changed the location of mdx file AND also re-installed dependencies. I confirm that it work for me.
    Here is the commit

    image

    THANK YOU for all your help, very much appreciate it

  9. slorber commented on Aug 5, 2021

    @slorber
    Collaborator

    @hhimanshu with #5299 you should be able to put mdx files in src/components soon

  10. hhimanshu commented on Aug 5, 2021

    @hhimanshu
    Author

    Fantastic, thank you @slorber.

  11. added
    external
    and removed
    status: needs triage
    on Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugexternal

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions