-
-
Notifications
You must be signed in to change notification settings - Fork 58
docs(zh): translate /config/lib to Chinese #526
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
53e6e58
docs(zh): translate /config/lib to Chinese
fi3ework 251f785
Update website/docs/zh/config/lib/bundle.mdx
fi3ework 47df9a3
Update website/docs/zh/config/lib/syntax.mdx
fi3ework 795c300
Update website/docs/zh/config/lib/redirect.mdx
fi3ework a8444d6
up
fi3ework File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,52 @@ | ||
| # lib.autoExtension | ||
|
|
||
| - **类型:** `boolean` | ||
| - **默认值:** `true` | ||
|
|
||
| 是否根据 [`format`](/config/lib/format) 配置项自动设置 JavaScript 输出文件的扩展名。 | ||
|
|
||
| ## 默认扩展名 | ||
|
|
||
| 默认情况下,当 `autoExtension` 设置为 `true` 时,文件扩展名将会是: | ||
|
|
||
| - 当 `package.json` 中设置 `type: module` 时,`esm` 格式使用 `.js`,`cjs` 格式使用 `.cjs`。 | ||
|
|
||
| - 当 `package.json` 中设置 `type: commonjs` 或没有 `type` 字段时,`cjs` 格式使用 `.js`,`esm` 格式使用 `.mjs`。 | ||
|
|
||
| :::warning | ||
|
|
||
| 当 [bundle](/config/lib/bundle) 设置为 `false`(即 bundleless 模式)时,你需要在源代码中写完整的路径,而不是省略目录索引(例如,用 `'./foo'` 作为 `'./foo/index.js'` 的简写)。 | ||
|
|
||
| 举例来说,如果 `foo` 是一个文件夹,你需要将 `import * from './foo'` 改写为 `import * from './foo/index'`。 | ||
|
|
||
| ::: | ||
|
|
||
| 当 `autoExtension` 设置为 `false` 时,文件扩展名将默认为 `.js`。 | ||
|
|
||
| ## 自定义扩展名 | ||
|
|
||
| 你可以将 `autoExtension` 设置为 `false`,并使用 [output.filename](https://rsbuild.dev/zh/config/output/filename) 来自定义 JavaScript 输出文件。 | ||
|
|
||
| ```ts title="rslib.config.ts" | ||
| export default defineConfig({ | ||
| lib: [ | ||
| { | ||
| format: 'cjs', | ||
| autoExtension: false, | ||
| output: { | ||
| filename: { | ||
| js: '[name].cjs', | ||
| }, | ||
| }, | ||
| }, | ||
| { | ||
| format: 'esm', | ||
| output: { | ||
| filename: { | ||
| js: '[name].mjs', | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| }); | ||
| ``` |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.