@rsbuild/plugin-mdx 0.6.15 → 0.7.0-beta.0

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 ADDED
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ pluginMdx: () => pluginMdx
34
+ });
35
+ module.exports = __toCommonJS(src_exports);
36
+ function createRegExp(exts) {
37
+ const matcher = exts.map((ext) => ext.slice(1)).join("|");
38
+ return new RegExp(
39
+ exts.length === 1 ? `\\.${matcher}$` : `\\.(?:${matcher})$`,
40
+ "i"
41
+ );
42
+ }
43
+ var pluginMdx = (options = {}) => ({
44
+ name: "rsbuild:mdx",
45
+ setup(api) {
46
+ api.modifyBundlerChain((chain, { CHAIN_ID }) => {
47
+ const { extensions = [".mdx", ".md"] } = options;
48
+ for (const ext of extensions) {
49
+ chain.resolve.extensions.add(ext);
50
+ }
51
+ const jsRule = chain.module.rules.get(CHAIN_ID.RULE.JS);
52
+ const mdxRule = chain.module.rule("mdx");
53
+ [CHAIN_ID.USE.SWC, CHAIN_ID.USE.BABEL].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
+ mdxRule.test(MDX_REGEXP).use("mdx").loader(require.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
+ });
73
+ }
74
+ });
75
+ // Annotate the CommonJS export names for ESM import in node:
76
+ 0 && (module.exports = {
77
+ pluginMdx
78
+ });
package/dist/index.d.ts CHANGED
@@ -1,17 +1,14 @@
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 pluginMdx: (options?: PluginMdxOptions) => RsbuildPlugin;
16
-
17
- export { type PluginMdxOptions, pluginMdx };
14
+ export declare const pluginMdx: (options?: PluginMdxOptions) => RsbuildPlugin;
package/dist/index.js CHANGED
@@ -1,38 +1,19 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ import { createRequire } from 'module';
2
+ var require = createRequire(import.meta['url']);
29
3
 
30
- // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
33
- pluginMdx: () => pluginMdx
4
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
5
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
6
+ }) : x)(function(x) {
7
+ if (typeof require !== "undefined")
8
+ return require.apply(this, arguments);
9
+ throw Error('Dynamic require of "' + x + '" is not supported');
34
10
  });
35
- module.exports = __toCommonJS(src_exports);
11
+
12
+ // ../../node_modules/.pnpm/@modern-js+module-tools@2.49.3_eslint@8.57.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js
13
+ import { fileURLToPath } from "url";
14
+ import path from "path";
15
+
16
+ // src/index.ts
36
17
  function createRegExp(exts) {
37
18
  const matcher = exts.map((ext) => ext.slice(1)).join("|");
38
19
  return new RegExp(
@@ -59,7 +40,7 @@ var pluginMdx = (options = {}) => ({
59
40
  return false;
60
41
  });
61
42
  const MDX_REGEXP = createRegExp(extensions);
62
- mdxRule.test(MDX_REGEXP).use("mdx").loader(require.resolve("@mdx-js/loader")).options(options.mdxLoaderOptions ?? {});
43
+ mdxRule.test(MDX_REGEXP).use("mdx").loader(__require.resolve("@mdx-js/loader")).options(options.mdxLoaderOptions ?? {});
63
44
  const { REACT_FAST_REFRESH } = CHAIN_ID.PLUGIN;
64
45
  if (chain.plugins.has(REACT_FAST_REFRESH)) {
65
46
  chain.plugins.get(REACT_FAST_REFRESH).tap((options2) => {
@@ -72,7 +53,6 @@ var pluginMdx = (options = {}) => ({
72
53
  });
73
54
  }
74
55
  });
75
- // Annotate the CommonJS export names for ESM import in node:
76
- 0 && (module.exports = {
56
+ export {
77
57
  pluginMdx
78
- });
58
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-mdx",
3
- "version": "0.6.15",
3
+ "version": "0.7.0-beta.0",
4
4
  "description": "Mdx plugin for Rsbuild",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "repository": {
@@ -9,30 +9,30 @@
9
9
  "directory": "packages/plugin-mdx"
10
10
  },
11
11
  "license": "MIT",
12
- "type": "commonjs",
12
+ "type": "module",
13
13
  "exports": {
14
14
  ".": {
15
15
  "types": "./dist/index.d.ts",
16
- "import": "./dist/index.mjs",
17
- "default": "./dist/index.js"
16
+ "import": "./dist/index.js",
17
+ "require": "./dist/index.cjs"
18
18
  }
19
19
  },
20
- "main": "./dist/index.js",
20
+ "main": "./dist/index.cjs",
21
21
  "types": "./dist/index.d.ts",
22
22
  "files": [
23
23
  "dist"
24
24
  ],
25
25
  "dependencies": {
26
26
  "@mdx-js/loader": "^3.0.1",
27
- "@rsbuild/shared": "0.6.15"
27
+ "@rsbuild/shared": "0.7.0-beta.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "typescript": "^5.4.2",
31
- "@rsbuild/core": "0.6.15",
32
- "@scripts/test-helper": "0.6.15"
31
+ "@rsbuild/core": "0.7.0-beta.0",
32
+ "@scripts/test-helper": "0.7.0-beta.0"
33
33
  },
34
34
  "peerDependencies": {
35
- "@rsbuild/core": "^0.6.15"
35
+ "@rsbuild/core": "^0.7.0-beta.0"
36
36
  },
37
37
  "publishConfig": {
38
38
  "access": "public",
package/dist/index.mjs DELETED
@@ -1,58 +0,0 @@
1
- import { createRequire } from 'module';
2
- var require = createRequire(import.meta['url']);
3
-
4
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
5
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
6
- }) : x)(function(x) {
7
- if (typeof require !== "undefined")
8
- return require.apply(this, arguments);
9
- throw Error('Dynamic require of "' + x + '" is not supported');
10
- });
11
-
12
- // ../../node_modules/.pnpm/@modern-js+module-tools@2.49.3_eslint@8.57.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js
13
- import { fileURLToPath } from "url";
14
- import path from "path";
15
-
16
- // src/index.ts
17
- function createRegExp(exts) {
18
- const matcher = exts.map((ext) => ext.slice(1)).join("|");
19
- return new RegExp(
20
- exts.length === 1 ? `\\.${matcher}$` : `\\.(?:${matcher})$`,
21
- "i"
22
- );
23
- }
24
- var pluginMdx = (options = {}) => ({
25
- name: "rsbuild:mdx",
26
- setup(api) {
27
- api.modifyBundlerChain((chain, { CHAIN_ID }) => {
28
- const { extensions = [".mdx", ".md"] } = options;
29
- for (const ext of extensions) {
30
- chain.resolve.extensions.add(ext);
31
- }
32
- const jsRule = chain.module.rules.get(CHAIN_ID.RULE.JS);
33
- const mdxRule = chain.module.rule("mdx");
34
- [CHAIN_ID.USE.SWC, CHAIN_ID.USE.BABEL].some((id) => {
35
- const use = jsRule.uses.get(id);
36
- if (use) {
37
- mdxRule.use(id).loader(use.get("loader")).options(use.get("options"));
38
- return true;
39
- }
40
- return false;
41
- });
42
- const MDX_REGEXP = createRegExp(extensions);
43
- mdxRule.test(MDX_REGEXP).use("mdx").loader(__require.resolve("@mdx-js/loader")).options(options.mdxLoaderOptions ?? {});
44
- const { REACT_FAST_REFRESH } = CHAIN_ID.PLUGIN;
45
- if (chain.plugins.has(REACT_FAST_REFRESH)) {
46
- chain.plugins.get(REACT_FAST_REFRESH).tap((options2) => {
47
- const firstOption = options2[0] ?? {};
48
- firstOption.include = [...firstOption.include || [], MDX_REGEXP];
49
- options2[0] = firstOption;
50
- return options2;
51
- });
52
- }
53
- });
54
- }
55
- });
56
- export {
57
- pluginMdx
58
- };