Coder Social home page Coder Social logo

remark-mdx-filter-imports's People

Contributors

antonk52 avatar jknoxville avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

antonk52

remark-mdx-filter-imports's Issues

Package does not declare dependencies correctly

This package only declare devDependencies, for many dependencies that are actually used at runtime:

"devDependencies": {
    "unist-util-visit": "^2.0.3",
    "@babel/parser": "^7.12.7",
    "@babel/generator": "^7.12.5",
    "@mdx-js/mdx": "^1.6.22",
    "jest": "^26.6.3",
    "prettier": "1.19.1",
    "remark-mdx": "^1.6.22",
    "remark-parse": "^9.0.0",
    "remark-stringify": "^9.0.0",
    "unified": "^9.2.0"
  },

https://github.com/jknoxville/remark-mdx-filter-imports/blob/master/index.js

const fs = require('fs');
const path = require('path');
const visit = require('unist-util-visit');
const {parse}  = require('@babel/parser');
const generate = require('@babel/generator').default;

I think this is important that those deps are declared correctly (even if docusaurus-plugin-internaldocs-fb also declare those)

I tried to upgrade the Metro website to Docusaurus v3, but it failed due to an ESM error, because all newer versions of MDX/Unified/Remark etc are on ESM now.

This happens because Docusaurus v3 now runs on unist-util-visit@4

And Docusaurus v3 has a deps:

docusaurus-plugin-internaldocs-fb > remark-mdx-filter-imports > unist-util-visit@2

The unist-util-visit@4 is hoisted at the root of the Yarn monorepo, and remark-mdx-filter-imports tries to use it in v4 (ESM only) instead of using a local copy of unist-util-visit@2 (supports CJS)

This leads to an error while trying to run the site:

Error [ERR_REQUIRE_ESM]: require() of ES Module /home/ozaki/dev/metro/website/node_modules/unist-util-visit/index.js from /home/ozaki/dev/metro/website/node_modules/remark-mdx-filter-imports/index.js not supported.
Instead change the require of /home/ozaki/dev/metro/website/node_modules/unist-util-visit/index.js in /home/ozaki/dev/metro/website/node_modules/remark-mdx-filter-imports/index.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/home/ozaki/dev/metro/website/node_modules/remark-mdx-filter-imports/index.js:3:15)
    at Object.<anonymous> (/home/ozaki/dev/metro/website/node_modules/docusaurus-plugin-internaldocs-fb/docusaurus-preset.js:10:53)
    at module.exports (/home/ozaki/dev/metro/website/node_modules/import-fresh/index.js:32:59)
    at /home/ozaki/dev/metro/website/node_modules/@docusaurus/core/lib/server/plugins/presets.js:38:57
    at Array.forEach (<anonymous>)
    at loadPresets 

The shame is that Metro doesn't even use any Remark plugin of the docusaurus-plugin-internaldocs-fb, so it could actually work out of the box if the dependency was correct.


(there are other problems in docusaurus-plugin-internaldocs-fb, like throwin an error for React 18, but that's a separate problems)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.