@umijs/plugin-docs 4.0.0-canary.20220429.1 → 4.0.0-canary.20220429.4

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.
@@ -1,5 +1,6 @@
1
1
  export declare function compile(opts: {
2
2
  content: string;
3
+ fileName: string;
3
4
  }): Promise<{
4
5
  result: string;
5
6
  }>;
package/dist/compiler.js CHANGED
@@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.compile = void 0;
16
+ const plugin_utils_1 = require("umi/plugin-utils");
16
17
  const rehype_pretty_code_1 = __importDefault(require("rehype-pretty-code"));
17
18
  // @ts-ignore
18
19
  const mdx_1 = require("../compiled/@mdx-js/mdx");
@@ -48,8 +49,9 @@ function compile(opts) {
48
49
  remarkPlugins: [remark_gfm_1.default],
49
50
  rehypePlugins: [rehype_slug_1.default, [rehype_pretty_code_1.default, rehypePrettyCodeOptions]],
50
51
  });
51
- let result = String(yield compiler.process(opts.content));
52
- result = result.replace('function MDXContent(props = {}) {', `
52
+ try {
53
+ let result = String(yield compiler.process(opts.content));
54
+ result = result.replace('function MDXContent(props = {}) {', `
53
55
  import { useEffect } from 'react';
54
56
 
55
57
  function MDXContent(props = {}) {
@@ -68,7 +70,18 @@ function MDXContent(props = {}) {
68
70
  }, []);
69
71
 
70
72
  `);
71
- return { result };
73
+ return { result };
74
+ }
75
+ catch (e) {
76
+ plugin_utils_1.logger.error(e.reason);
77
+ plugin_utils_1.logger.error(`Above error occurred in ${opts.fileName} at line ${e.line}`);
78
+ plugin_utils_1.logger.error(opts.content
79
+ .split('\n')
80
+ .filter((_, i) => i == e.line - 1)
81
+ .join('\n'));
82
+ plugin_utils_1.logger.error(' '.repeat(e.column - 1) + '^');
83
+ return { result: '' };
84
+ }
72
85
  });
73
86
  }
74
87
  exports.compile = compile;
package/dist/loader.js CHANGED
@@ -19,6 +19,7 @@ function default_1(content) {
19
19
  try {
20
20
  const { result } = yield (0, compiler_1.compile)({
21
21
  content,
22
+ fileName: filename,
22
23
  });
23
24
  return callback(null, result);
24
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/plugin-docs",
3
- "version": "4.0.0-canary.20220429.1",
3
+ "version": "4.0.0-canary.20220429.4",
4
4
  "description": "@umijs/plugin-docs",
5
5
  "homepage": "https://github.com/umijs/umi-next/tree/master/packages/plugin-docs#readme",
6
6
  "bugs": "https://github.com/umijs/umi-next/issues",
@@ -39,7 +39,7 @@
39
39
  "rehype-slug": "5.0.1",
40
40
  "remark-gfm": "^3.0.1",
41
41
  "tailwindcss": "^3.0.23",
42
- "umi": "4.0.0-canary.20220429.1"
42
+ "umi": "4.0.0-canary.20220429.4"
43
43
  },
44
44
  "publishConfig": {
45
45
  "access": "public"