@rsbuild/plugin-mdx 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +78 -72
- package/dist/index.d.ts +6 -9
- package/dist/index.js +40 -42
- package/package.json +69 -68
- package/dist/index.d.cts +0 -18
package/dist/index.cjs
CHANGED
|
@@ -1,79 +1,85 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
2
|
+
const __rslib_import_meta_url__ = /*#__PURE__*/ function() {
|
|
3
|
+
return 'undefined' == typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
|
|
4
|
+
}();
|
|
5
|
+
var __webpack_require__ = {};
|
|
6
|
+
(()=>{
|
|
7
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
8
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: definition[key]
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
16
|
+
})();
|
|
17
|
+
(()=>{
|
|
18
|
+
__webpack_require__.r = (exports1)=>{
|
|
19
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
20
|
+
value: 'Module'
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
23
|
+
value: true
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
})();
|
|
27
|
+
var __webpack_exports__ = {};
|
|
28
|
+
__webpack_require__.r(__webpack_exports__);
|
|
29
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
30
|
+
PLUGIN_MDX_NAME: ()=>PLUGIN_MDX_NAME,
|
|
31
|
+
pluginMdx: ()=>pluginMdx
|
|
25
32
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
// node_modules/.pnpm/tsup@8.2.4_postcss@8.4.40_typescript@5.5.4/node_modules/tsup/assets/cjs_shims.js
|
|
29
|
-
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
30
|
-
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
31
|
-
|
|
32
|
-
// src/index.ts
|
|
33
|
-
var import_node_module = require("module");
|
|
33
|
+
const external_node_module_namespaceObject = require("node:module");
|
|
34
34
|
function createRegExp(exts) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
exts.length === 1 ? `\\.${matcher}$` : `\\.(?:${matcher})$`,
|
|
38
|
-
"i"
|
|
39
|
-
);
|
|
35
|
+
const matcher = exts.map((ext)=>ext.slice(1)).join('|');
|
|
36
|
+
return new RegExp(1 === exts.length ? `\\.${matcher}$` : `\\.(?:${matcher})$`, 'i');
|
|
40
37
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
38
|
+
const PLUGIN_MDX_NAME = 'rsbuild:mdx';
|
|
39
|
+
const pluginMdx = (options = {})=>({
|
|
40
|
+
name: PLUGIN_MDX_NAME,
|
|
41
|
+
setup (api) {
|
|
42
|
+
api.modifyBundlerChain((chain, { CHAIN_ID })=>{
|
|
43
|
+
const { extensions = [
|
|
44
|
+
'.mdx',
|
|
45
|
+
'.md'
|
|
46
|
+
] } = options;
|
|
47
|
+
for (const ext of extensions)chain.resolve.extensions.add(ext);
|
|
48
|
+
const jsRule = chain.module.rules.get(CHAIN_ID.RULE.JS);
|
|
49
|
+
const mdxRule = chain.module.rule('mdx');
|
|
50
|
+
[
|
|
51
|
+
CHAIN_ID.USE.SWC,
|
|
52
|
+
CHAIN_ID.USE.BABEL
|
|
53
|
+
].some((id)=>{
|
|
54
|
+
const use = jsRule.uses.get(id);
|
|
55
|
+
if (use) {
|
|
56
|
+
mdxRule.use(id).loader(use.get('loader')).options(use.get('options'));
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
});
|
|
61
|
+
const MDX_REGEXP = createRegExp(extensions);
|
|
62
|
+
const require1 = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__);
|
|
63
|
+
mdxRule.test(MDX_REGEXP).use('mdx').loader(require1.resolve('@mdx-js/loader')).options(options.mdxLoaderOptions ?? {});
|
|
64
|
+
const { REACT_FAST_REFRESH } = CHAIN_ID.PLUGIN;
|
|
65
|
+
if (chain.plugins.has(REACT_FAST_REFRESH)) chain.plugins.get(REACT_FAST_REFRESH).tap((options)=>{
|
|
66
|
+
const firstOption = options[0] ?? {};
|
|
67
|
+
firstOption.include = [
|
|
68
|
+
...firstOption.include || [],
|
|
69
|
+
MDX_REGEXP
|
|
70
|
+
];
|
|
71
|
+
options[0] = firstOption;
|
|
72
|
+
return options;
|
|
73
|
+
});
|
|
74
|
+
});
|
|
57
75
|
}
|
|
58
|
-
return false;
|
|
59
|
-
});
|
|
60
|
-
const MDX_REGEXP = createRegExp(extensions);
|
|
61
|
-
const require2 = (0, import_node_module.createRequire)(importMetaUrl);
|
|
62
|
-
mdxRule.test(MDX_REGEXP).use("mdx").loader(require2.resolve("@mdx-js/loader")).options(options.mdxLoaderOptions ?? {});
|
|
63
|
-
const { REACT_FAST_REFRESH } = CHAIN_ID.PLUGIN;
|
|
64
|
-
if (chain.plugins.has(REACT_FAST_REFRESH)) {
|
|
65
|
-
chain.plugins.get(REACT_FAST_REFRESH).tap((options2) => {
|
|
66
|
-
const firstOption = options2[0] ?? {};
|
|
67
|
-
firstOption.include = [...firstOption.include || [], MDX_REGEXP];
|
|
68
|
-
options2[0] = firstOption;
|
|
69
|
-
return options2;
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
76
|
});
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
exports.PLUGIN_MDX_NAME = __webpack_exports__.PLUGIN_MDX_NAME;
|
|
78
|
+
exports.pluginMdx = __webpack_exports__.pluginMdx;
|
|
79
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
80
|
+
"PLUGIN_MDX_NAME",
|
|
81
|
+
"pluginMdx"
|
|
82
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
83
|
+
Object.defineProperty(exports, '__esModule', {
|
|
84
|
+
value: true
|
|
79
85
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import { Options } from '@mdx-js/loader';
|
|
2
|
-
import { RsbuildPlugin } from '@rsbuild/core';
|
|
3
|
-
|
|
4
|
-
type PluginMdxOptions = {
|
|
1
|
+
import type { Options as MdxLoaderOptions } from '@mdx-js/loader';
|
|
2
|
+
import type { RsbuildPlugin } from '@rsbuild/core';
|
|
3
|
+
export type PluginMdxOptions = {
|
|
5
4
|
/**
|
|
6
5
|
* Options passed to `@mdx-js/loader`.
|
|
7
6
|
* @see https://npmjs.com/package/@mdx-js/loader#api
|
|
8
7
|
*/
|
|
9
|
-
mdxLoaderOptions?:
|
|
8
|
+
mdxLoaderOptions?: MdxLoaderOptions;
|
|
10
9
|
/**
|
|
11
10
|
* @default ['.mdx', '.md']
|
|
12
11
|
*/
|
|
13
12
|
extensions?: string[];
|
|
14
13
|
};
|
|
15
|
-
declare const PLUGIN_MDX_NAME = "rsbuild:mdx";
|
|
16
|
-
declare const pluginMdx: (options?: PluginMdxOptions) => RsbuildPlugin;
|
|
17
|
-
|
|
18
|
-
export { PLUGIN_MDX_NAME, type PluginMdxOptions, pluginMdx };
|
|
14
|
+
export declare const PLUGIN_MDX_NAME = "rsbuild:mdx";
|
|
15
|
+
export declare const pluginMdx: (options?: PluginMdxOptions) => RsbuildPlugin;
|
package/dist/index.js
CHANGED
|
@@ -1,47 +1,45 @@
|
|
|
1
|
-
// src/index.ts
|
|
2
1
|
import { createRequire } from "node:module";
|
|
3
2
|
function createRegExp(exts) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exts.length === 1 ? `\\.${matcher}$` : `\\.(?:${matcher})$`,
|
|
7
|
-
"i"
|
|
8
|
-
);
|
|
3
|
+
const matcher = exts.map((ext)=>ext.slice(1)).join('|');
|
|
4
|
+
return new RegExp(1 === exts.length ? `\\.${matcher}$` : `\\.(?:${matcher})$`, 'i');
|
|
9
5
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
6
|
+
const PLUGIN_MDX_NAME = 'rsbuild:mdx';
|
|
7
|
+
const pluginMdx = (options = {})=>({
|
|
8
|
+
name: PLUGIN_MDX_NAME,
|
|
9
|
+
setup (api) {
|
|
10
|
+
api.modifyBundlerChain((chain, { CHAIN_ID })=>{
|
|
11
|
+
const { extensions = [
|
|
12
|
+
'.mdx',
|
|
13
|
+
'.md'
|
|
14
|
+
] } = options;
|
|
15
|
+
for (const ext of extensions)chain.resolve.extensions.add(ext);
|
|
16
|
+
const jsRule = chain.module.rules.get(CHAIN_ID.RULE.JS);
|
|
17
|
+
const mdxRule = chain.module.rule('mdx');
|
|
18
|
+
[
|
|
19
|
+
CHAIN_ID.USE.SWC,
|
|
20
|
+
CHAIN_ID.USE.BABEL
|
|
21
|
+
].some((id)=>{
|
|
22
|
+
const use = jsRule.uses.get(id);
|
|
23
|
+
if (use) {
|
|
24
|
+
mdxRule.use(id).loader(use.get('loader')).options(use.get('options'));
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
});
|
|
29
|
+
const MDX_REGEXP = createRegExp(extensions);
|
|
30
|
+
const require = createRequire(import.meta.url);
|
|
31
|
+
mdxRule.test(MDX_REGEXP).use('mdx').loader(require.resolve('@mdx-js/loader')).options(options.mdxLoaderOptions ?? {});
|
|
32
|
+
const { REACT_FAST_REFRESH } = CHAIN_ID.PLUGIN;
|
|
33
|
+
if (chain.plugins.has(REACT_FAST_REFRESH)) chain.plugins.get(REACT_FAST_REFRESH).tap((options)=>{
|
|
34
|
+
const firstOption = options[0] ?? {};
|
|
35
|
+
firstOption.include = [
|
|
36
|
+
...firstOption.include || [],
|
|
37
|
+
MDX_REGEXP
|
|
38
|
+
];
|
|
39
|
+
options[0] = firstOption;
|
|
40
|
+
return options;
|
|
41
|
+
});
|
|
42
|
+
});
|
|
26
43
|
}
|
|
27
|
-
return false;
|
|
28
|
-
});
|
|
29
|
-
const MDX_REGEXP = createRegExp(extensions);
|
|
30
|
-
const require2 = createRequire(import.meta.url);
|
|
31
|
-
mdxRule.test(MDX_REGEXP).use("mdx").loader(require2.resolve("@mdx-js/loader")).options(options.mdxLoaderOptions ?? {});
|
|
32
|
-
const { REACT_FAST_REFRESH } = CHAIN_ID.PLUGIN;
|
|
33
|
-
if (chain.plugins.has(REACT_FAST_REFRESH)) {
|
|
34
|
-
chain.plugins.get(REACT_FAST_REFRESH).tap((options2) => {
|
|
35
|
-
const firstOption = options2[0] ?? {};
|
|
36
|
-
firstOption.include = [...firstOption.include || [], MDX_REGEXP];
|
|
37
|
-
options2[0] = firstOption;
|
|
38
|
-
return options2;
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
44
|
});
|
|
42
|
-
|
|
43
|
-
});
|
|
44
|
-
export {
|
|
45
|
-
PLUGIN_MDX_NAME,
|
|
46
|
-
pluginMdx
|
|
47
|
-
};
|
|
45
|
+
export { PLUGIN_MDX_NAME, pluginMdx };
|
package/package.json
CHANGED
|
@@ -1,69 +1,70 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
2
|
+
"name": "@rsbuild/plugin-mdx",
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"repository": "https://github.com/rspack-contrib/rsbuild-plugin-mdx",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.cjs"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"module": "./dist/index.mjs",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"files": ["dist"],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "rslib build",
|
|
20
|
+
"dev": "rslib build --watch",
|
|
21
|
+
"lint": "biome check .",
|
|
22
|
+
"lint:write": "biome check . --write",
|
|
23
|
+
"prepare": "simple-git-hooks && npm run build",
|
|
24
|
+
"test": "playwright test",
|
|
25
|
+
"bump": "npx bumpp"
|
|
26
|
+
},
|
|
27
|
+
"simple-git-hooks": {
|
|
28
|
+
"pre-commit": "npx nano-staged"
|
|
29
|
+
},
|
|
30
|
+
"nano-staged": {
|
|
31
|
+
"*.{js,jsx,ts,tsx,mjs,cjs}": [
|
|
32
|
+
"biome check --write --no-errors-on-unmatched"
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@mdx-js/loader": "^3.1.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@biomejs/biome": "^1.9.4",
|
|
40
|
+
"@playwright/test": "^1.54.1",
|
|
41
|
+
"@rsbuild/core": "^1.4.12",
|
|
42
|
+
"@rsbuild/plugin-preact": "^1.5.1",
|
|
43
|
+
"@rsbuild/plugin-react": "^1.3.4",
|
|
44
|
+
"@rsbuild/plugin-svgr": "^1.2.1",
|
|
45
|
+
"@rsbuild/plugin-vue": "^1.1.0",
|
|
46
|
+
"@rslib/core": "^0.11.0",
|
|
47
|
+
"@types/node": "^22.17.0",
|
|
48
|
+
"nano-staged": "^0.8.0",
|
|
49
|
+
"playwright": "^1.54.1",
|
|
50
|
+
"preact": "^10.27.0",
|
|
51
|
+
"react": "^19.1.1",
|
|
52
|
+
"react-dom": "^19.1.1",
|
|
53
|
+
"simple-git-hooks": "^2.13.1",
|
|
54
|
+
"typescript": "^5.9.2",
|
|
55
|
+
"vue": "^3.5.18"
|
|
56
|
+
},
|
|
57
|
+
"peerDependencies": {
|
|
58
|
+
"@rsbuild/core": "1.x"
|
|
59
|
+
},
|
|
60
|
+
"peerDependenciesMeta": {
|
|
61
|
+
"@rsbuild/core": {
|
|
62
|
+
"optional": true
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"packageManager": "pnpm@10.14.0",
|
|
66
|
+
"publishConfig": {
|
|
67
|
+
"access": "public",
|
|
68
|
+
"registry": "https://registry.npmjs.org/"
|
|
69
|
+
}
|
|
70
|
+
}
|
package/dist/index.d.cts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Options } from '@mdx-js/loader';
|
|
2
|
-
import { RsbuildPlugin } from '@rsbuild/core';
|
|
3
|
-
|
|
4
|
-
type PluginMdxOptions = {
|
|
5
|
-
/**
|
|
6
|
-
* Options passed to `@mdx-js/loader`.
|
|
7
|
-
* @see https://npmjs.com/package/@mdx-js/loader#api
|
|
8
|
-
*/
|
|
9
|
-
mdxLoaderOptions?: Options;
|
|
10
|
-
/**
|
|
11
|
-
* @default ['.mdx', '.md']
|
|
12
|
-
*/
|
|
13
|
-
extensions?: string[];
|
|
14
|
-
};
|
|
15
|
-
declare const PLUGIN_MDX_NAME = "rsbuild:mdx";
|
|
16
|
-
declare const pluginMdx: (options?: PluginMdxOptions) => RsbuildPlugin;
|
|
17
|
-
|
|
18
|
-
export { PLUGIN_MDX_NAME, type PluginMdxOptions, pluginMdx };
|