From a52d9eadbb730229b1fc72acd704f0a3e4cf44d9 Mon Sep 17 00:00:00 2001 From: PeachScript Date: Sun, 8 Nov 2020 23:55:16 +0800 Subject: [PATCH] fix(preset): dynamic import maybe blocked by adblock --- packages/preset-dumi/src/plugins/features/demo/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/preset-dumi/src/plugins/features/demo/index.ts b/packages/preset-dumi/src/plugins/features/demo/index.ts index cf938b76ba..55a9e47d23 100644 --- a/packages/preset-dumi/src/plugins/features/demo/index.ts +++ b/packages/preset-dumi/src/plugins/features/demo/index.ts @@ -42,7 +42,10 @@ export default (api: IApi) => { }); demoComponent = `() => React.createElement(dynamic({ loader: async function() { - const { default: demos } = await import(/* webpackChunkName: "demos_${componentName}" */'./${componentName}'); + const { default: demos } = await import(/* webpackChunkName: "demos_${[...componentName] + // reverse component name to avoid some special component (such as Advertisement) be blocked by ADBlock when dynamic loading + .reverse() + .join('')}" */'./${componentName}'); return demos['${uuid}'].component; },