Skip to content

Commit

Permalink
docs: add transformImport scope tip (#1604)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan authored Feb 20, 2024
1 parent 00a0d5a commit c14bb42
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/document/docs/en/config/source/transform-import.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,20 @@ import _ from 'lodash';
import lodash from 'lodash';
```

## Scope

`transformImport` is only applicable to modules compiled by Rsbuild. Note that Rsbuild does not compile JavaScript files in the node_modules by default. This means that the code in the node_modules directory will not be processed by `transformImport`.

If you want to process the code in node_modules through `transformImport`, please add the relevant modules to the [source.include](/config/source/include) config.

```ts
export default {
source: {
include: [/[\\/]node_modules[\\/]some-package[\\/]/],
},
};
```

## Options

### libraryName
Expand Down
14 changes: 14 additions & 0 deletions packages/document/docs/zh/config/source/transform-import.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,20 @@ import _ from 'lodash';
import lodash from 'lodash';
```

## 适用范围

`transformImport` 只适用于经过 Rsbuild 编译的模块。需要注意的是,Rsbuild 默认并不会编译位于 node_modules 目录下的 JavaScript 文件。这意味着,node_modules 目录内的代码将不会被 `transformImport` 处理。

如果你希望通过 `transformImport` 对 node_modules 下的代码进行处理,请将相关模块添加到 [source.include](/config/source/include) 配置中。

```ts
export default {
source: {
include: [/[\\/]node_modules[\\/]some-package[\\/]/],
},
};
```

## 选项

### libraryName
Expand Down

0 comments on commit c14bb42

Please sign in to comment.