From 4fd88967023eb9964aa089e980a79e8fe1a5af29 Mon Sep 17 00:00:00 2001 From: pomelo-nwu Date: Mon, 12 Jun 2023 08:32:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=20ESM=20=E5=BC=95?= =?UTF-8?q?=E5=85=A5=E7=9A=84=E8=B5=84=E6=BA=90=E5=8C=85=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/gi-site/src/hooks/common.ts | 12 ++++++++++-- packages/gi-site/src/hooks/useNodeModule.ts | 15 +++++++++++---- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/packages/gi-site/src/hooks/common.ts b/packages/gi-site/src/hooks/common.ts index 5cdbd9fa1..eaf92a307 100644 --- a/packages/gi-site/src/hooks/common.ts +++ b/packages/gi-site/src/hooks/common.ts @@ -25,7 +25,7 @@ export function beautifyCode(code: string) { } export const getActivePackage = (activeAssets: GIAssets) => { - const { services, components, elements, layouts } = activeAssets; + const { components, elements, layouts } = activeAssets; const componentsMap = new Map(); const elementsMap = new Map(); @@ -108,7 +108,15 @@ export const getActivePackageName = (activeAssets: GIAssets): string[] => { }; export const getConstantFiles = opts => { - const { config, id, engineId, activeAssets, theme = 'light', data, schemaData } = opts; + const { config, id, engineId, theme = 'light', data, schemaData } = opts; + + const activeAssets = { + ...opts.activeAssets, + services: opts.activeAssets.services.filter(item => { + return item.id === 'GI' || item.id === engineId; + }), + }; + // const GI_SERVICES_OPTIONS = beautifyCode(JSON.stringify(serviceConfig)); const THEME_STYLE = Object.entries(ThemeVars[theme]) //@ts-ignore diff --git a/packages/gi-site/src/hooks/useNodeModule.ts b/packages/gi-site/src/hooks/useNodeModule.ts index 84a72dc0b..4dd9ba151 100644 --- a/packages/gi-site/src/hooks/useNodeModule.ts +++ b/packages/gi-site/src/hooks/useNodeModule.ts @@ -14,7 +14,14 @@ function serialize(data: Record) { } function getCSBData(opts) { - const { activeAssets, activeAssetsKeys, theme } = opts; + const { activeAssetsKeys, theme, engineId } = opts; + const activeAssets = { + ...opts.activeAssets, + services: opts.activeAssets.services.filter(item => { + return item.id === 'GI' || item.id === engineId; + }), + }; + const nodemodules = getActivePackage(activeAssets); const ext = '.tsx'; @@ -55,7 +62,7 @@ function getCSBData(opts) { return itemComponent.info.id; }) .join(','); - console.log('umd', UMD); + return `const { ${componentIds} } = ${UMD}.components;`; }) .join('\n'); @@ -70,7 +77,7 @@ function getCSBData(opts) { return itemComponent.info.id; }) .join(','); - console.log('umd', UMD); + return `const { ${componentIds} } = ${UMD}.elements;`; }) .join('\n'); @@ -84,7 +91,7 @@ function getCSBData(opts) { return itemComponent.info.id; }) .join(','); - console.log('umd', UMD); + return `const { ${componentIds} } = ${UMD}.layouts;`; }) .join('\n');