@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 CHANGED
@@ -1,79 +1,85 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
23
- PLUGIN_MDX_NAME: () => PLUGIN_MDX_NAME,
24
- pluginMdx: () => pluginMdx
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
- module.exports = __toCommonJS(src_exports);
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
- const matcher = exts.map((ext) => ext.slice(1)).join("|");
36
- return new RegExp(
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
- var PLUGIN_MDX_NAME = "rsbuild:mdx";
42
- var pluginMdx = (options = {}) => ({
43
- name: PLUGIN_MDX_NAME,
44
- setup(api) {
45
- api.modifyBundlerChain((chain, { CHAIN_ID }) => {
46
- const { extensions = [".mdx", ".md"] } = options;
47
- for (const ext of extensions) {
48
- chain.resolve.extensions.add(ext);
49
- }
50
- const jsRule = chain.module.rules.get(CHAIN_ID.RULE.JS);
51
- const mdxRule = chain.module.rule("mdx");
52
- [CHAIN_ID.USE.SWC, CHAIN_ID.USE.BABEL].some((id) => {
53
- const use = jsRule.uses.get(id);
54
- if (use) {
55
- mdxRule.use(id).loader(use.get("loader")).options(use.get("options"));
56
- return true;
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
- // Annotate the CommonJS export names for ESM import in node:
76
- 0 && (module.exports = {
77
- PLUGIN_MDX_NAME,
78
- pluginMdx
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?: Options;
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
- const matcher = exts.map((ext) => ext.slice(1)).join("|");
5
- return new RegExp(
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
- var PLUGIN_MDX_NAME = "rsbuild:mdx";
11
- var pluginMdx = (options = {}) => ({
12
- name: PLUGIN_MDX_NAME,
13
- setup(api) {
14
- api.modifyBundlerChain((chain, { CHAIN_ID }) => {
15
- const { extensions = [".mdx", ".md"] } = options;
16
- for (const ext of extensions) {
17
- chain.resolve.extensions.add(ext);
18
- }
19
- const jsRule = chain.module.rules.get(CHAIN_ID.RULE.JS);
20
- const mdxRule = chain.module.rule("mdx");
21
- [CHAIN_ID.USE.SWC, CHAIN_ID.USE.BABEL].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;
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
- "name": "@rsbuild/plugin-mdx",
3
- "version": "1.0.2",
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": [
18
- "dist"
19
- ],
20
- "simple-git-hooks": {
21
- "pre-commit": "npx nano-staged"
22
- },
23
- "nano-staged": {
24
- "*.{js,jsx,ts,tsx,mjs,cjs}": [
25
- "biome check --write --no-errors-on-unmatched"
26
- ]
27
- },
28
- "dependencies": {
29
- "@mdx-js/loader": "^3.0.1"
30
- },
31
- "devDependencies": {
32
- "@biomejs/biome": "^1.8.3",
33
- "@playwright/test": "^1.45.3",
34
- "@rsbuild/core": "^1.0.1-beta.10",
35
- "@rsbuild/plugin-preact": "^1.0.1-beta.10",
36
- "@rsbuild/plugin-react": "^1.0.1-beta.10",
37
- "@rsbuild/plugin-svgr": "^1.0.1-beta.10",
38
- "@rsbuild/plugin-vue": "^1.0.1-beta.10",
39
- "@types/node": "^20.14.14",
40
- "nano-staged": "^0.8.0",
41
- "playwright": "^1.45.3",
42
- "preact": "^10.23.1",
43
- "react": "^18.3.1",
44
- "react-dom": "^18.3.1",
45
- "simple-git-hooks": "^2.11.1",
46
- "tsup": "^8.2.4",
47
- "typescript": "^5.5.4",
48
- "vue": "^3.4.35"
49
- },
50
- "peerDependencies": {
51
- "@rsbuild/core": "0.x || 1.x || ^1.0.1-beta.0"
52
- },
53
- "peerDependenciesMeta": {
54
- "@rsbuild/core": {
55
- "optional": true
56
- }
57
- },
58
- "publishConfig": {
59
- "access": "public",
60
- "registry": "https://registry.npmjs.org/"
61
- },
62
- "scripts": {
63
- "build": "tsup",
64
- "dev": "tsup --watch",
65
- "lint": "biome check .",
66
- "lint:write": "biome check . --write",
67
- "test": "playwright test"
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 };