Skip to content

Commit

Permalink
chore(bridge-react): adjust bridge-react to structure directory (#3509)
Browse files Browse the repository at this point in the history
  • Loading branch information
danpeen authored Feb 11, 2025
1 parent 0e6f1f5 commit 4ef21d2
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 21 deletions.
5 changes: 5 additions & 0 deletions .changeset/thirty-llamas-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@module-federation/bridge-react': patch
---

chore: adjust bridge-react to structure directory
4 changes: 2 additions & 2 deletions packages/bridge/bridge-react/__tests__/router.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
Outlet,
createBrowserRouter,
} from 'react-router-dom';
import { BrowserRouter, RouterProvider } from '../src/router';
import { RouterContext } from '../src/context';
import { BrowserRouter, RouterProvider } from '../src/router/default';
import { RouterContext } from '../src/provider/context';
import { getHtml, getWindowImpl } from './util';

describe('react router proxy', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/bridge/bridge-react/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { createRemoteComponent } from './create';
export { createBridgeComponent } from './provider';
export { createRemoteComponent } from './remote/create';
export { createBridgeComponent } from './provider/create';
export type {
ProviderParams,
RenderFnParams,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
} from '@module-federation/bridge-shared';
import { ErrorBoundary } from 'react-error-boundary';
import { RouterContext } from './context';
import { LoggerInstance } from './utils';
import { LoggerInstance } from '../utils';
import { federationRuntime } from './plugin';
import { createRoot } from './compat';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { FederationRuntimePlugin } from '@module-federation/runtime';
import type { FederationHost } from '@module-federation/runtime';
import type {
FederationRuntimePlugin,
FederationHost,
} from '@module-federation/runtime';

export type FederationRuntimeType = {
instance: FederationHost | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { ProviderParams } from '@module-federation/bridge-shared';
import { dispatchPopstateEnv } from '@module-federation/bridge-shared';
import { ErrorBoundaryPropsWithComponent } from 'react-error-boundary';
import { LoggerInstance, pathJoin, getRootDomDefaultClassName } from '../utils';
import { federationRuntime } from '../plugin';
import { federationRuntime } from '../provider/plugin';

declare const __APP_VERSION__: string;
export interface RenderFnParams extends ProviderParams {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {
ErrorBoundary,
ErrorBoundaryPropsWithComponent,
} from 'react-error-boundary';
import { LoggerInstance } from './utils';
import RemoteApp from './remote';
import { LoggerInstance } from '../utils';
import RemoteApp from './component';
import type { ProviderParams } from '@module-federation/bridge-shared';

export interface RenderFnParams extends ProviderParams {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { useContext } from 'react';
// The upper alias react-router-dom$ into this file avoids the loop
import * as ReactRouterDom from 'react-router-dom/';
import { RouterContext } from './context';
import { LoggerInstance } from './utils';
import { RouterContext } from '../provider/context';
import { LoggerInstance } from '../utils';

function WrapperRouter(
props:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React, { useContext } from 'react';
// The upper alias react-router-dom$ into this file avoids the loop
// @ts-ignore
import * as ReactRouterDom from 'react-router-dom/index.js';
import { RouterContext } from './context';
import { LoggerInstance } from './utils';
import { RouterContext } from '../provider/context';
import { LoggerInstance } from '../utils';

function WraperRouter(
props:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React, { useContext } from 'react';
// The upper alias react-router-dom$ into this file avoids the loop
import * as ReactRouterDom from 'react-router-dom/dist/index.js';

import { RouterContext } from './context';
import { LoggerInstance } from './utils';
import { RouterContext } from '../provider/context';
import { LoggerInstance } from '../utils';

function WraperRouter(
props:
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions packages/bridge/bridge-react/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ export default defineConfig({
lib: {
entry: {
index: path.resolve(__dirname, 'src/index.ts'),
plugin: path.resolve(__dirname, 'src/plugin.ts'),
router: path.resolve(__dirname, 'src/router.tsx'),
'router-v5': path.resolve(__dirname, 'src/router-v5.tsx'),
'router-v6': path.resolve(__dirname, 'src/router-v6.tsx'),
plugin: path.resolve(__dirname, 'src/provider/plugin.ts'),
router: path.resolve(__dirname, 'src/router/default.tsx'),
'router-v5': path.resolve(__dirname, 'src/router/v5.tsx'),
'router-v6': path.resolve(__dirname, 'src/router/v6.tsx'),
},
formats: ['cjs', 'es'],
fileName: (format, entryName) => `${entryName}.${format}.js`,
Expand Down

0 comments on commit 4ef21d2

Please sign in to comment.