Skip to content

Commit

Permalink
fix: reslove conditionNames just for commonjs and supplement prod ski…
Browse files Browse the repository at this point in the history
…p error
  • Loading branch information
Jinbao1001 committed Apr 28, 2024
1 parent 0017934 commit fcbd8f5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
11 changes: 4 additions & 7 deletions src/client/theme-api/useLiveDemo.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { SHOULD_SKIP_LIVEDEMO_ERROR } from '@/constants';
import { useDemo } from 'dumi';
import throttle from 'lodash.throttle';
import {
Expand Down Expand Up @@ -174,13 +175,9 @@ export const useLiveDemo = (
try {
(await renderToStaticMarkupDeferred)(newDemoNode);
} catch (err: any) {
const shouldSkipError =
err.message.includes(
'Unable to find node on an unmounted component',
) ||
err.message.includes(
'Portals are not currently supported by the server renderer',
);
const shouldSkipError = SHOULD_SKIP_LIVEDEMO_ERROR.some((e) =>
err.message.includes(e),
);
if (!shouldSkipError) throw err;
}
console.error = oError;
Expand Down
7 changes: 7 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,10 @@ export const DEFAULT_DEMO_PLAIN_TEXT_EXTENSIONS = [
];

export const FS_CACHE_DIR = 'node_modules/.cache/dumi';

export const SHOULD_SKIP_LIVEDEMO_ERROR = [
'Unable to find node on an unmounted component',
'#188',
'Portals are not currently supported by the server renderer',
'#257',
];
2 changes: 1 addition & 1 deletion src/features/compile/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default (api: IApi) => {
const loaderPath = require.resolve('../../loaders/markdown');

// support require mjs packages(eg. element-plus/es)
memo.resolve.merge({
memo.resolve.byDependency.set('commonjs', {
conditionNames: ['require', 'node', 'import'],
});

Expand Down

0 comments on commit fcbd8f5

Please sign in to comment.