jknoxville / remark-mdx-filter-imports Goto Github PK
View Code? Open in Web Editor NEWRemark plugin to strip mdx imports matching a given pattern
License: MIT License
Remark plugin to strip mdx imports matching a given pattern
License: MIT License
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)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.