From 3912bdc78247d64dcb602682cf65189f9ac55a64 Mon Sep 17 00:00:00 2001 From: Belinda Cao Date: Mon, 15 Jul 2024 16:19:26 +0800 Subject: [PATCH] feat: the runtime path use the meta alias in garfish provider (#5949) --- .changeset/curvy-mangos-collect.md | 8 ++++++++ packages/runtime/plugin-garfish/src/cli/index.ts | 2 ++ packages/runtime/plugin-garfish/src/global.d.ts | 8 ++++++++ packages/runtime/plugin-garfish/src/runtime/provider.tsx | 2 +- packages/runtime/plugin-garfish/src/runtime/render.tsx | 4 ++-- packages/runtime/plugin-router-v5/package.json | 3 ++- tests/integration/garfish/app-dashboard/src/index.tsx | 4 ++-- 7 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 .changeset/curvy-mangos-collect.md diff --git a/.changeset/curvy-mangos-collect.md b/.changeset/curvy-mangos-collect.md new file mode 100644 index 000000000000..5dfdfa0e1ca3 --- /dev/null +++ b/.changeset/curvy-mangos-collect.md @@ -0,0 +1,8 @@ +--- +'@modern-js/plugin-router-v5': patch +'@modern-js/plugin-garfish': patch +--- + +feat: the runtime path use the meta alias in garfish provider + +feat: 在 garfish provider 函数中使用 runtime 别名路径 diff --git a/packages/runtime/plugin-garfish/src/cli/index.ts b/packages/runtime/plugin-garfish/src/cli/index.ts index 5134180abc48..fdf44f928e2c 100644 --- a/packages/runtime/plugin-garfish/src/cli/index.ts +++ b/packages/runtime/plugin-garfish/src/cli/index.ts @@ -141,6 +141,8 @@ export const garfishPlugin = (): CliPlugin< source: { alias: { [`@${metaName}/runtime/garfish`]: `@${metaName}/plugin-garfish/runtime`, + '@meta/runtime/browser': '@modern-js/runtime/browser', + '@meta/runtime/react': '@modern-js/runtime/react', }, }, tools: { diff --git a/packages/runtime/plugin-garfish/src/global.d.ts b/packages/runtime/plugin-garfish/src/global.d.ts index 9392c84ca34c..a34ff5bcaed6 100644 --- a/packages/runtime/plugin-garfish/src/global.d.ts +++ b/packages/runtime/plugin-garfish/src/global.d.ts @@ -1 +1,9 @@ /// + +declare module '@meta/runtime/react' { + export * from '@modern-js/runtime/react'; +} + +declare module '@meta/runtime/browser' { + export * from '@modern-js/runtime/browser'; +} diff --git a/packages/runtime/plugin-garfish/src/runtime/provider.tsx b/packages/runtime/plugin-garfish/src/runtime/provider.tsx index fce4d1f980c8..a20825dc089a 100644 --- a/packages/runtime/plugin-garfish/src/runtime/provider.tsx +++ b/packages/runtime/plugin-garfish/src/runtime/provider.tsx @@ -1,4 +1,4 @@ -import { createRoot } from '@modern-js/runtime/react'; +import { createRoot } from '@meta/runtime/react'; import type { Root } from 'react-dom/client'; import { createPortal, unmountComponentAtNode } from 'react-dom'; import { garfishRender } from './render'; diff --git a/packages/runtime/plugin-garfish/src/runtime/render.tsx b/packages/runtime/plugin-garfish/src/runtime/render.tsx index b89185bb9950..40425fc67b2b 100644 --- a/packages/runtime/plugin-garfish/src/runtime/render.tsx +++ b/packages/runtime/plugin-garfish/src/runtime/render.tsx @@ -1,5 +1,5 @@ -import { render } from '@modern-js/runtime/browser'; -import { createRoot } from '@modern-js/runtime/react'; +import { render } from '@meta/runtime/browser'; +import { createRoot } from '@meta/runtime/react'; declare const __GARFISH_EXPORTS__: string; diff --git a/packages/runtime/plugin-router-v5/package.json b/packages/runtime/plugin-router-v5/package.json index 340c886bd764..f3e0030c6093 100644 --- a/packages/runtime/plugin-router-v5/package.json +++ b/packages/runtime/plugin-router-v5/package.json @@ -73,7 +73,8 @@ }, "peerDependencies": { "react": ">=17", - "react-dom": ">=17" + "react-dom": ">=17", + "@modern-js/runtime": "workspace:^2.55.0" }, "devDependencies": { "@modern-js/app-tools": "workspace:*", diff --git a/tests/integration/garfish/app-dashboard/src/index.tsx b/tests/integration/garfish/app-dashboard/src/index.tsx index afeac4e2287f..dac660c8d1bf 100644 --- a/tests/integration/garfish/app-dashboard/src/index.tsx +++ b/tests/integration/garfish/app-dashboard/src/index.tsx @@ -6,7 +6,7 @@ const sleep = () => export default (_App: React.ComponentType, bootstrap: () => void) => { // do something before bootstrap... - sleep().then(() => { - bootstrap(); + return sleep().then(() => { + return bootstrap(); }); };