Skip to content

Commit af66421

Browse files
committed
refactor: remove insternal alias
1 parent 69ca88d commit af66421

File tree

52 files changed

+135
-186
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+135
-186
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,4 @@ playground/
5656
.cursor
5757
.claude
5858
AGENTS.md
59+
.specify/

packages/cli/plugin-bff/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"jsnext:source": "./src/cli.ts",
3333
"default": "./dist/cjs/cli.js"
3434
},
35-
"./server": {
35+
"./server-plugin": {
3636
"types": "./dist/types/server.d.ts",
3737
"jsnext:source": "./src/server.ts",
3838
"default": "./dist/cjs/server.js"
@@ -42,12 +42,12 @@
4242
"jsnext:source": "./src/loader.ts",
4343
"default": "./dist/cjs/loader.js"
4444
},
45-
"./hono": {
45+
"./server": {
4646
"types": "./dist/types/runtime/hono/index.d.ts",
4747
"jsnext:source": "./src/runtime/hono/index.ts",
4848
"default": "./dist/cjs/runtime/hono/index.js"
4949
},
50-
"./runtime/create-request": {
50+
"./client": {
5151
"types": "./dist/types/create-request/index.d.ts",
5252
"jsnext:source": "./src/runtime/create-request/index.ts",
5353
"default": "./dist/cjs/runtime/create-request/index.js"
@@ -61,13 +61,13 @@
6161
"cli": [
6262
"./dist/types/cli.d.ts"
6363
],
64-
"server": [
64+
"server-plugin": [
6565
"./dist/types/server.d.ts"
6666
],
67-
"hono": [
67+
"server": [
6868
"./dist/types/runtime/hono/index.d.ts"
6969
],
70-
"runtime/create-request": [
70+
"client": [
7171
"./dist/types/runtime/create-request/index.d.ts"
7272
]
7373
}

packages/cli/plugin-bff/src/cli.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import runtimeGenerator from './utils/runtimeGenerator';
1919

2020
const DEFAULT_API_PREFIX = '/api';
2121
const TS_CONFIG_FILENAME = 'tsconfig.json';
22-
const RUNTIME_CREATE_REQUEST = '@modern-js/plugin-bff/runtime/create-request';
23-
const RUNTIME_HONO = '@modern-js/plugin-bff/hono';
22+
const RUNTIME_CREATE_REQUEST = '@modern-js/plugin-bff/client';
23+
const RUNTIME_HONO = '@modern-js/plugin-bff/server';
2424

2525
export const bffPlugin = (): CliPlugin<AppTools> => ({
2626
name: '@modern-js/plugin-bff',
@@ -230,13 +230,6 @@ export const bffPlugin = (): CliPlugin<AppTools> => ({
230230
requestCreator: (bff as any)?.requestCreator,
231231
httpMethodDecider,
232232
});
233-
234-
chain.resolve.alias.set('@api', apiDirectory);
235-
236-
chain.resolve.alias.set(
237-
'@modern-js/runtime/bff',
238-
RUNTIME_CREATE_REQUEST,
239-
);
240233
},
241234
},
242235
output: {
@@ -284,7 +277,7 @@ export const bffPlugin = (): CliPlugin<AppTools> => ({
284277

285278
api._internalServerPlugins(({ plugins }) => {
286279
plugins.push({
287-
name: '@modern-js/plugin-bff/server',
280+
name: '@modern-js/plugin-bff/server-plugin',
288281
});
289282
return { plugins };
290283
});

packages/cli/plugin-bff/src/helper.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

packages/cli/plugin-bff/types.d.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/document/main-doc/docs/en/apis/app/runtime/bff/use-hono-context.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Used to obtain Hono context in an integrated BFF function.
88
## Usage
99

1010
```ts
11-
import { useHonoContext } from '@modern-js/plugin-bff/hono';
11+
import { useHonoContext } from '@modern-js/plugin-bff/server';
1212
```
1313

1414
## Function Signature
@@ -20,7 +20,7 @@ import { useHonoContext } from '@modern-js/plugin-bff/hono';
2020
Developers can use `context` to obtain more request information, such as setting response headers:
2121

2222
```ts
23-
import { useHonoContext } from '@modern-js/plugin-bff/hono';
23+
import { useHonoContext } from '@modern-js/plugin-bff/server';
2424

2525
export async function get() {
2626
const c = useHonoContext();

packages/document/main-doc/docs/en/configure/app/server/ssr.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ When the value type is `Object`, the following properties can be configured:
2929
| ---------------- | ------------------------------------------------------------- | -------------------------------------- | ---------------------------------------------------------------------------- |
3030
| mode | `string` | `string` | which defaults to using `renderToString` for rendering. Configure `stream` to enable streaming rendering |
3131
| forceCSR | `boolean` | `false` | which is off by default for forcing CSR rendering. Configure `true` to force CSR by adding `?csr=true` or adding `x-modern-ssr-fallback` header when accessing the page |
32-
| disablePrerender | `boolean` | `fasle` | To ensure compatibility with the old data request method (`useLoader`), by default, Modern.js performs pre-rendering of components.However, if developers want to reduce one rendering when there is no use of the useLoader API in your project, you can set the configuration `disablePrerender=true` |
3332
| unsafeHeaders | `string[]` | `[]` | For safety reasons, Modern.js does not add excessive content to SSR_DATA. Developers can use this configuration to specify the headers that need to be injected |
3433
| loaderFailureMode| `clientRender \| errorBoundary` | `errorBoundary` | The default configuration is `'errorBoundary'`, when an error occurs in [data loader](/en/guides/basic-features/data/data-fetch.html#data-loader-recommended), it will default to rendering the [`Error`](/en/guides/basic-features/routes.html#errorboundary) component of the route. When configured as `'clientRender'`, if a loader throws an error, it switch to client-side rendering,you can use it with [Client Loader](/en/guides/basic-features/data/data-fetch.html#client-loader) |
3534

packages/document/main-doc/docs/en/guides/advanced-features/bff/cross-project.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ The `configure` function from `${package_name}/runtime` supports domain configur
9090

9191
```ts title="src/routes/page.tsx"
9292
import { configure } from '${package_name}/runtime';
93-
import { configure as innerConfigure } from '@modern-js/runtime/bff';
93+
import { configure as innerConfigure } from '@modern-js/plugin-bff/client';
9494
import axios from 'axios';
9595

9696
configure({

packages/document/main-doc/docs/en/guides/advanced-features/bff/frameworks.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Modern.js uses [Hono.js](https://hono.dev/) as the BFF and Server runtime framew
1212
Sometimes in BFF functions, it's necessary to obtain the request context to handle more logic. In such cases, you can use `useHonoContext` to get it:
1313

1414
```ts title="api/lambda/hello.ts"
15-
import { useHonoContext } from '@modern-js/plugin-bff/hono'
15+
import { useHonoContext } from '@modern-js/plugin-bff/server'
1616
export const get = async () => {
1717
const c = useHonoContext();
1818
console.info(`access url: ${c.req.url}`);

packages/document/main-doc/docs/en/guides/advanced-features/bff/sdk.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The `configure` function needs to be called before all BFF requests are sent to
1313
:::
1414

1515
```tsx title="routes/page.tsx"
16-
import { configure } from '@modern-js/runtime/bff';
16+
import { configure } from '@modern-js/plugin-bff/client';
1717

1818
configure({
1919
// ...
@@ -90,7 +90,7 @@ There are some conventions when configuring custom request functions:
9090
Below is an example of using axios to customize a request function:
9191

9292
```tsx title="App.tsx"
93-
import { configure } from '@modern-js/runtime/bff';
93+
import { configure } from '@modern-js/plugin-bff/client';
9494
import type { Method, AxiosRequestHeaders as Headers } from 'axios';
9595

9696
configure({
@@ -105,4 +105,4 @@ configure({
105105
return res.data;
106106
},
107107
});
108-
```
108+
```

0 commit comments

Comments
 (0)