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

docs: add importModule for api.transform #4255

Merged
merged 1 commit into from
Dec 24, 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
3 changes: 1 addition & 2 deletions .github/workflows/issue-close-require.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ on:
- cron: '0 0 * * *'

permissions:
issues: write
contents: read

jobs:
issue-close-require:
permissions:
issues: write
runs-on: ubuntu-latest
if: github.repository == 'web-infra-dev/rsbuild'
steps:
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ on:
required: false
default: true

permissions:
id-token: write

jobs:
release:
name: Release
Expand Down
9 changes: 3 additions & 6 deletions website/docs/en/plugins/dev/core.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,8 @@ type TransformContext = {
resourceQuery: string;
environment: EnvironmentContext;
addDependency: (file: string) => void;
emitFile: (
name: string,
content: string | Buffer,
sourceMap?: string,
assetInfo?: Record<string, any>,
) => void;
emitFile: Rspack.LoaderContext['emitFile'];
importModule: Rspack.LoaderContext['importModule'];
};

type TransformResult =
Expand All @@ -304,6 +300,7 @@ The `handler` function provides the following params:
- `environment`: The [environment context](/api/javascript-api/environment-api#environment-context) for current build.
- `addDependency`: Add an additional file as the dependency. The file will be watched and changes to the file will trigger rebuild. The same as Rspack loader's [this.addDependency](https://rspack.dev/api/loader-api/context#thisadddependency).
- `emitFile`: Emits a file to the build output. The same as Rspack loader's [this.emitFile](https://rspack.dev/api/loader-api/context#thisemitfile).
- `importModule`: Compile and execute a module at the build time. The same as Rspack loader's [this.importModule](https://rspack.dev/api/loader-api/context#thisimportmodule).

For example:

Expand Down
11 changes: 4 additions & 7 deletions website/docs/zh/plugins/dev/core.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,8 @@ type TransformContext = {
resourceQuery: string;
environment: EnvironmentContext;
addDependency: (file: string) => void;
emitFile: (
name: string,
content: string | Buffer,
sourceMap?: string,
assetInfo?: Record<string, any>,
) => void;
emitFile: Rspack.LoaderContext['emitFile'];
importModule: Rspack.LoaderContext['importModule'];
};

type TransformResult =
Expand All @@ -301,7 +297,8 @@ handler 函数提供以下参数:
- `resourceQuery`:模块路径上的 query。
- `environment`: 当前构建的 [environment 上下文](/api/javascript-api/environment-api#environment-context).
- `addDependency`:添加一个额外的文件作为依赖。该文件将被监听,并在发生变更时触发重新构建。与 Rspack loader 的 [this.addDependency](https://rspack.dev/api/loader-api/context#thisadddependency) 相同。
- `emitFile`:将一个文件输出到构建结果中。与 Rspack loader 的 [this.emitFile](https://rspack.dev/api/loader-api/context#thisemitfile) 相同。
- `emitFile`:将一个文件输出到构建结果中。与 Rspack loader 的 [this.emitFile](https://rspack.dev/zh/api/loader-api/context#thisemitfile) 相同。
- `importModule`:在构建时编译并执行一个模块。与 Rspack loader 的 [this.importModule](https://rspack.dev/zh/api/loader-api/context#thisimportmodule) 相同。

比如:

Expand Down
Loading