Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix!: remove context.tsconfigPath #2690

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions packages/core/src/createContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,22 +159,12 @@ export async function updateEnvironmentContext(
}
}

export function updateContextByNormalizedConfig(
context: RsbuildContext,
config: NormalizedConfig,
) {
export function updateContextByNormalizedConfig(context: RsbuildContext) {
// Try to get the parent dist path from all environments
const distPaths = Object.values(context.environments).map(
(item) => item.distPath,
);
context.distPath = getCommonParentPath(distPaths);

if (config.source.tsconfigPath) {
context.tsconfigPath = getAbsolutePath(
context.rootPath,
config.source.tsconfigPath,
);
}
}

export function createPublicContext(
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/provider/initConfigs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ export async function initRsbuildConfig({
};

await updateEnvironmentContext(context, environments);

updateContextByNormalizedConfig(context, context.normalizedConfig);
updateContextByNormalizedConfig(context);

return context.normalizedConfig;
}
Expand Down
22 changes: 12 additions & 10 deletions website/docs/en/api/javascript-api/instance.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,6 @@ The absolute path of the build cache files.
type CachePath = string;
```

### context.tsconfigPath

The absolute path of the tsconfig.json file, or `undefined` if the tsconfig.json file does not exist in current project.

- **Type:**

```ts
type TsconfigPath = string | undefined;
```

### context.devServer

Dev Server information, including the current Dev Server hostname and port number.
Expand All @@ -107,6 +97,18 @@ type bundlerType = 'rspack' | 'webpack';

> Rsbuild internally supports switching to webpack for comparative testing, so this field is provided for differentiation. Usually, you do not need to use this field.

## rsbuild.environments

### tsconfigPath

The absolute path of the tsconfig.json file, or `undefined` if the tsconfig.json file does not exist in current project.

- **Type:**

```ts
type TsconfigPath = string | undefined;
```

## rsbuild.build

Perform a production build.
Expand Down
2 changes: 1 addition & 1 deletion website/docs/en/api/javascript-api/types.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ import type {

## NormalizedEnvironmentConfig

The type of Rsbuild environment configuration after normalization, corresponding to the return value of the [getNormalizedConfig({ environment })](/plugins/dev/core#apigetnormalizedconfig) method.
The type of Rsbuild environment configuration after normalization, corresponding to the return value of the [`getNormalizedConfig({ environment })`](/plugins/dev/core#apigetnormalizedconfig) method.

```ts
import type { NormalizedEnvironmentConfig } from '@rsbuild/core';
Expand Down
22 changes: 12 additions & 10 deletions website/docs/zh/api/javascript-api/instance.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,6 @@ type DistPath = string;
type CachePath = string;
```

### context.tsconfigPath

tsconfig.json 文件的绝对路径,若项目中不存在 tsconfig.json 文件,则为 `undefined`。

- **类型:**

```ts
type TsconfigPath = string | undefined;
```

### context.devServer

Dev Server 相关信息,包含了当前 Dev Server 的 hostname 和端口号。
Expand All @@ -107,6 +97,18 @@ type bundlerType = 'rspack' | 'webpack';

> Rsbuild 内部支持切换到 webpack 进行对照测试,因此提供了该字段进行区分,通常你不需要使用此字段。

## rsbuild.environments

### tsconfigPath

tsconfig.json 文件的绝对路径,若项目中不存在 tsconfig.json 文件,则为 `undefined`。

- **类型:**

```ts
type TsconfigPath = string | undefined;
```

## rsbuild.build

调用 build 方法时,会执行一次生产环境构建。
Expand Down
2 changes: 1 addition & 1 deletion website/docs/zh/api/javascript-api/types.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ import type {

## NormalizedEnvironmentConfig

指定环境下的 Rsbuild 归一化配置类型,对应 [getNormalizedConfig({ environment })](/plugins/dev/core#apigetnormalizedconfig) 方法的返回值。
指定环境下的 Rsbuild 归一化配置类型,对应 [`getNormalizedConfig({ environment })`](/plugins/dev/core#apigetnormalizedconfig) 方法的返回值。

```ts
import type { NormalizedEnvironmentConfig } from '@rsbuild/core';
Expand Down
4 changes: 4 additions & 0 deletions website/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module '*.mdx' {
let MDXComponent: () => JSX.Element;
export default MDXComponent;
}
2 changes: 1 addition & 1 deletion website/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
"mdx": {
"checkMdx": true
},
"include": ["docs", "rspress.config.ts", "theme", "components"]
"include": ["docs", "rspress.config.ts", "theme", "components", "env.d.ts"]
}
Loading