Skip to content

Commit 2a604f0

Browse files
committed
docs(cn): resolve conflicts
1 parent 9a1e183 commit 2a604f0

File tree

5 files changed

+24
-362
lines changed

5 files changed

+24
-362
lines changed

README.md

-70
Original file line numberDiff line numberDiff line change
@@ -48,77 +48,7 @@
4848
</a>
4949
</p>
5050

51-
<<<<<<< HEAD
5251
## Rollup 贡献者
53-
=======
54-
These commands assume the entry point to your application is named main.js, and that you'd like all imports compiled into a single file named bundle.js.
55-
56-
For browsers:
57-
58-
```bash
59-
# compile to a <script> containing a self-executing function
60-
rollup main.js --format iife --name "myBundle" --file bundle.js
61-
```
62-
63-
For Node.js:
64-
65-
```bash
66-
# compile to a CommonJS module
67-
rollup main.js --format cjs --file bundle.js
68-
```
69-
70-
For both browsers and Node.js:
71-
72-
```bash
73-
# UMD format requires a bundle name
74-
rollup main.js --format umd --name "myBundle" --file bundle.js
75-
```
76-
77-
## Why
78-
79-
Developing software is usually easier if you break your project into smaller separate pieces, since that often removes unexpected interactions and dramatically reduces the complexity of the problems you'll need to solve, and simply writing smaller projects in the first place [isn't necessarily the answer](https://medium.com/@Rich_Harris/small-modules-it-s-not-quite-that-simple-3ca532d65de4). Unfortunately, JavaScript has not historically included this capability as a core feature in the language.
80-
81-
This finally changed with ES modules support in JavaScript, which provides a syntax for importing and exporting functions and data so they can be shared between separate scripts. Most browsers and Node.js support ES modules. However, Node.js releases before 12.17 support ES modules only behind the `--experimental-modules` flag, and older browsers like Internet Explorer do not support ES modules at all. Rollup allows you to write your code using ES modules, and run your application even in environments that do not support ES modules natively. For environments that support them, Rollup can output optimized ES modules; for environments that don't, Rollup can compile your code to other formats such as CommonJS modules, AMD modules, and IIFE-style scripts. This means that you get to _write future-proof code_, and you also get the tremendous benefits of...
82-
83-
## Tree Shaking
84-
85-
In addition to enabling the use of ES modules, Rollup also statically analyzes and optimizes the code you are importing, and will exclude anything that isn't actually used. This allows you to build on top of existing tools and modules without adding extra dependencies or bloating the size of your project.
86-
87-
For example, with CommonJS, the _entire tool or library must be imported_.
88-
89-
```js
90-
// import the entire utils object with CommonJS
91-
var utils = require('node:utils');
92-
var query = 'Rollup';
93-
// use the ajax method of the utils object
94-
utils.ajax('https://api.example.com?search=' + query).then(handleResponse);
95-
```
96-
97-
But with ES modules, instead of importing the whole `utils` object, we can just import the one `ajax` function we need:
98-
99-
```js
100-
// import the ajax function with an ES import statement
101-
import { ajax } from 'node:utils';
102-
103-
var query = 'Rollup';
104-
// call the ajax function
105-
ajax('https://api.example.com?search=' + query).then(handleResponse);
106-
```
107-
108-
Because Rollup includes the bare minimum, it results in lighter, faster, and less complicated libraries and applications. Since this approach is based on explicit `import` and `export` statements, it is vastly more effective than simply running an automated minifier to detect unused variables in the compiled output code.
109-
110-
## Compatibility
111-
112-
### Importing CommonJS
113-
114-
Rollup can import existing CommonJS modules [through a plugin](https://github.com/rollup/plugins/tree/master/packages/commonjs).
115-
116-
### Publishing ES Modules
117-
118-
To make sure your ES modules are immediately usable by tools that work with CommonJS such as Node.js and webpack, you can use Rollup to compile to UMD or CommonJS format, and then point to that compiled version with the `main` property in your `package.json` file. If your `package.json` file also has a `module` field, ES-module-aware tools like Rollup and [webpack](https://webpack.js.org/) will [import the ES module version](https://github.com/rollup/rollup/wiki/pkg.module) directly.
119-
120-
## Contributors
121-
>>>>>>> 91352494fc722bcd5e8e922cd1497b34aec57a67
12252

12353
This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)]. <a href="https://github.com/rollup/rollup/graphs/contributors"><img src="https://opencollective.com/rollup/contributors.svg?width=890" /></a>. If you want to contribute yourself, head over to the [contribution guidelines](CONTRIBUTING.md).
12454

docs/command-line-interface/index.md

+4-120
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,10 @@ rollup --config rollup.config.ts --configPlugin typescript
4141
```javascript twoslash
4242
// rollup.config.js
4343

44-
<<<<<<< HEAD
4544
// 可以是数组(即多个输入源)
46-
=======
47-
// can be an array (for multiple inputs)
4845
// ---cut-start---
4946
/** @type {import('rollup').RollupOptions} */
5047
// ---cut-end---
51-
>>>>>>> 91352494fc722bcd5e8e922cd1497b34aec57a67
5248
export default {
5349
// 核心输入选项
5450
external,
@@ -237,16 +233,7 @@ export default commandLineArgs => {
237233
export default commandLineArgs => {
238234
const inputBase = commandLineArgs.input || 'main.js';
239235

240-
<<<<<<< HEAD
241-
// 这会使 Rollup 忽略 CLI 参数
242-
delete commandLineArgs.input;
243-
return {
244-
input: 'src/entries/' + inputBase,
245-
output: { ... }
246-
}
247-
}
248-
=======
249-
// this will make Rollup ignore the CLI argument
236+
// 这会使 Rollup 忽略 CLI 参数
250237
delete commandLineArgs.input;
251238
return {
252239
input: 'src/entries/' + inputBase,
@@ -255,7 +242,6 @@ export default commandLineArgs => {
255242
}
256243
};
257244
};
258-
>>>>>>> 91352494fc722bcd5e8e922cd1497b34aec57a67
259245
```
260246

261247
### 填写配置时的智能提示 {#config-intellisense}
@@ -334,15 +320,9 @@ rollup --config node:my-special-config
334320
import { fileURLToPath } from 'node:url';
335321

336322
export default {
337-
<<<<<<< HEAD
338-
...,
339-
// 为 <currentdir>/src/some-file.js 生成绝对路径
340-
external: [fileURLToPath(new URL('src/some-file.js', import.meta.url))]
341-
=======
342323
/* ..., */
343-
// generates an absolute path for <currentdir>/src/some-file.js
324+
// <currentdir>/src/some-file.js 生成绝对路径
344325
external: [fileURLToPath(new URL('src/some-file.js', import.meta.url))]
345-
>>>>>>> 91352494fc722bcd5e8e922cd1497b34aec57a67
346326
};
347327
```
348328
@@ -393,7 +373,6 @@ export default {
393373
许多选项都有等效的命令行标志。在这些情况下,如果你正在使用配置文件,则此处传递的任何参数都将覆盖配置文件。以下是所有支持的选项列表:
394374
395375
```
396-
<<<<<<< HEAD
397376
-c, --config <filename> 使用此配置文件
398377
(如果使用参数但未指定值,则默认为 rollup.config.js
399378
-d, --dir <dirname> 用于块的目录(如果不存在,则打印到 stdout)
@@ -424,7 +403,7 @@ export default {
424403
--no-esModule 不添加 __esModule 属性
425404
--exports <mode> 指定导出模式(auto、default、named、none)
426405
--extend 扩展由 --name 定义的全局变量
427-
--no-externalImportAssertions"es" 输出中省略导入断言
406+
--no-externalImportAttributes"es" 格式输出中省略导入属性
428407
--no-externalLiveBindings 不生成支持实时绑定的代码
429408
--failAfterWarnings 如果生成的构建产生警告,则退出并显示错误
430409
--filterLogs <filter> 过滤日志信息
@@ -439,6 +418,7 @@ export default {
439418
--generatedCode.symbols 在生成的代码中使用符号
440419
--hashCharacters <name> 使用指定的字符集来生成文件的哈希值
441420
--no-hoistTransitiveImports 不将中转导入提升到入口块中
421+
--importAttributesKey <name> 使用特定的关键词作为导入属性
442422
--no-indent 不缩进结果
443423
--inlineDynamicImports 使用动态导入时创建单次打包
444424
--no-interop 不包括交互操作块
@@ -487,102 +467,6 @@ export default {
487467
--watch.onError <cmd>"ERROR" 事件上运行的 Shell 命令
488468
--watch.onStart <cmd>"START" 事件上运行的 Shell 命令
489469
--watch.skipWrite 在监视时不要将文件写入磁盘
490-
=======
491-
-c, --config <filename> Use this config file (if argument is used but value
492-
is unspecified, defaults to rollup.config.js)
493-
-d, --dir <dirname> Directory for chunks (if absent, prints to stdout)
494-
-e, --external <ids> Comma-separate list of module IDs to exclude
495-
-f, --format <format> Type of output (amd, cjs, es, iife, umd, system)
496-
-g, --globals <pairs> Comma-separate list of `moduleID:Global` pairs
497-
-h, --help Show this help message
498-
-i, --input <filename> Input (alternative to <entry file>)
499-
-m, --sourcemap Generate sourcemap (`-m inline` for inline map)
500-
-n, --name <name> Name for UMD export
501-
-o, --file <output> Single output file (if absent, prints to stdout)
502-
-p, --plugin <plugin> Use the plugin specified (may be repeated)
503-
-v, --version Show version number
504-
-w, --watch Watch files in bundle and rebuild on changes
505-
--amd.autoId Generate the AMD ID based off the chunk name
506-
--amd.basePath <prefix> Path to prepend to auto generated AMD ID
507-
--amd.define <name> Function to use in place of `define`
508-
--amd.forceJsExtensionForImports Use `.js` extension in AMD imports
509-
--amd.id <id> ID for AMD module (default is anonymous)
510-
--assetFileNames <pattern> Name pattern for emitted assets
511-
--banner <text> Code to insert at top of bundle (outside wrapper)
512-
--chunkFileNames <pattern> Name pattern for emitted secondary chunks
513-
--compact Minify wrapper code
514-
--context <variable> Specify top-level `this` value
515-
--no-dynamicImportInCjs Write external dynamic CommonJS imports as require
516-
--entryFileNames <pattern> Name pattern for emitted entry chunks
517-
--environment <values> Settings passed to config file (see example)
518-
--no-esModule Do not add __esModule property
519-
--exports <mode> Specify export mode (auto, default, named, none)
520-
--extend Extend global variable defined by --name
521-
--no-externalImportAttributes Omit import attributes in "es" output
522-
--no-externalLiveBindings Do not generate code to support live bindings
523-
--failAfterWarnings Exit with an error if the build produced warnings
524-
--filterLogs <filter> Filter log messages
525-
--footer <text> Code to insert at end of bundle (outside wrapper)
526-
--forceExit Force exit the process when done
527-
--no-freeze Do not freeze namespace objects
528-
--generatedCode <preset> Which code features to use (es5/es2015)
529-
--generatedCode.arrowFunctions Use arrow functions in generated code
530-
--generatedCode.constBindings Use "const" in generated code
531-
--generatedCode.objectShorthand Use shorthand properties in generated code
532-
--no-generatedCode.reservedNamesAsProps Always quote reserved names as props
533-
--generatedCode.symbols Use symbols in generated code
534-
--hashCharacters <name> Use the specified character set for file hashes
535-
--no-hoistTransitiveImports Do not hoist transitive imports into entry chunks
536-
--importAttributesKey <name> Use the specified keyword for import attributes
537-
--no-indent Don't indent result
538-
--inlineDynamicImports Create single bundle when using dynamic imports
539-
--no-interop Do not include interop block
540-
--intro <text> Code to insert at top of bundle (inside wrapper)
541-
--logLevel <level> Which kind of logs to display
542-
--no-makeAbsoluteExternalsRelative Prevent normalization of external imports
543-
--maxParallelFileOps <value> How many files to read in parallel
544-
--minifyInternalExports Force or disable minification of internal exports
545-
--noConflict Generate a noConflict method for UMD globals
546-
--outro <text> Code to insert at end of bundle (inside wrapper)
547-
--perf Display performance timings
548-
--no-preserveEntrySignatures Avoid facade chunks for entry points
549-
--preserveModules Preserve module structure
550-
--preserveModulesRoot Put preserved modules under this path at root level
551-
--preserveSymlinks Do not follow symlinks when resolving files
552-
--no-reexportProtoFromExternal Ignore `__proto__` in star re-exports
553-
--no-sanitizeFileName Do not replace invalid characters in file names
554-
--shimMissingExports Create shim variables for missing exports
555-
--silent Don't print warnings
556-
--sourcemapBaseUrl <url> Emit absolute sourcemap URLs with given base
557-
--sourcemapExcludeSources Do not include source code in source maps
558-
--sourcemapFile <file> Specify bundle position for source maps
559-
--sourcemapFileNames <pattern> Name pattern for emitted sourcemaps
560-
--stdin=ext Specify file extension used for stdin input
561-
--no-stdin Do not read "-" from stdin
562-
--no-strict Don't emit `"use strict";` in the generated modules
563-
--strictDeprecations Throw errors for deprecated features
564-
--no-systemNullSetters Do not replace empty SystemJS setters with `null`
565-
--no-treeshake Disable tree-shaking optimisations
566-
--no-treeshake.annotations Ignore pure call annotations
567-
--treeshake.correctVarValueBeforeDeclaration Deoptimize variables until declared
568-
--treeshake.manualPureFunctions <names> Manually declare functions as pure
569-
--no-treeshake.moduleSideEffects Assume modules have no side effects
570-
--no-treeshake.propertyReadSideEffects Ignore property access side effects
571-
--no-treeshake.tryCatchDeoptimization Do not turn off try-catch-tree-shaking
572-
--no-treeshake.unknownGlobalSideEffects Assume unknown globals do not throw
573-
--validate Validate output
574-
--waitForBundleInput Wait for bundle input files
575-
--watch.buildDelay <number> Throttle watch rebuilds
576-
--no-watch.clearScreen Do not clear the screen when rebuilding
577-
--watch.exclude <files> Exclude files from being watched
578-
--watch.include <files> Limit watching to specified files
579-
--watch.onBundleEnd <cmd> Shell command to run on `"BUNDLE_END"` event
580-
--watch.onBundleStart <cmd> Shell command to run on `"BUNDLE_START"` event
581-
--watch.onEnd <cmd> Shell command to run on `"END"` event
582-
--watch.onError <cmd> Shell command to run on `"ERROR"` event
583-
--watch.onStart <cmd> Shell command to run on `"START"` event
584-
--watch.skipWrite Do not write files to disk when watching
585-
>>>>>>> 91352494fc722bcd5e8e922cd1497b34aec57a67
586470
```
587471
588472
以下标志仅通过命令行界面可用。所有其他标志都对应并覆盖其配置文件等效项,请参阅[选项大列表](../configuration-options/index.md)获取详细信息。

docs/configuration-options/index.md

+9-27
Original file line numberDiff line numberDiff line change
@@ -650,13 +650,8 @@ export default {
650650

651651
虽然 CommonJS 输出最初只支持 `require(…)` 语法来引入依赖,但最近的 Node 版本也开始支持 `import(…)` 语法,这是从 CommonJS 文件中引入 ES 模块的唯一方法。如果这个选项默认值为 `true`,表示 Rollup 会在 CommonJS 输出中保持外部依赖以 `import(…)` 表达式动态引入。将值设置为 `false`,以使用 `require(…)` 语法重写动态引入。
652652

653-
<<<<<<< HEAD
654-
```js
655-
// 输入
656-
=======
657653
```js twoslash
658-
// input
659-
>>>>>>> 91352494fc722bcd5e8e922cd1497b34aec57a67
654+
// 输入
660655
import('external').then(console.log);
661656

662657
// 设置 dynamicImportInCjs 为 true 或不设置的 cjs 输出
@@ -766,13 +761,8 @@ Promise.resolve()
766761

767762
该选项表示在某些地方和辅助函数中使用 `const` 而不是 `var`。由于代码块的作用域,会使 Rollup 产生更有效的辅助函数。
768763

769-
<<<<<<< HEAD
770-
```js
771-
// 输入
772-
=======
773764
```js twoslash
774-
// input
775-
>>>>>>> 91352494fc722bcd5e8e922cd1497b34aec57a67
765+
// 输入
776766
export * from 'external';
777767

778768
// 设置 constBindings 为 false 的 cjs 输出
@@ -940,21 +930,17 @@ exports.foo = foo;
940930

941931
默认情况下,创建多个 chunk 时,入口 chunk 的可传递引入将以空引入的形式被打包。详细信息和背景请查看 ["Why do additional imports turn up in my entry chunks when code-splitting?"](../faqs/index.md#why-do-additional-imports-turn-up-in-my-entry-chunks-when-code-splitting)。该选项的值为 `false` 将禁用此行为。当使用 [`output.preserveModules`](#output-preservemodules) 选项时,该选项会被忽略,使得永远不会取消引入。
942932

943-
<<<<<<< HEAD
944-
### output.inlineDynamicImports {#output-inlinedynamicimports}
945-
=======
946933
### output.importAttributesKey
947934

948-
| | |
949-
| -------: | :----------------------------- |
950-
| Type: | `"with" \| "assert"` |
951-
| CLI: | `--importAttributesKey <name>` |
952-
| Default: | `"assert"` |
935+
| | |
936+
| -----: | :----------------------------- |
937+
| 类型: | `"with" \| "assert"` |
938+
| CLI | `--importAttributesKey <name>` |
939+
| 默认: | `"assert"` |
953940

954-
This determines the keyword set that Rollup will use for import attributes.
941+
该选项决定 Rollup 用于导入属性的关键词集合。
955942

956-
### output.inlineDynamicImports
957-
>>>>>>> 91352494fc722bcd5e8e922cd1497b34aec57a67
943+
### output.inlineDynamicImports {#output-inlinedynamicimports}
958944

959945
| | |
960946
| -----: | :--------------------------------------------------- |
@@ -1312,14 +1298,10 @@ function getTranslatedStrings(currentLanguage) {
13121298
function manualChunks(id, { getModuleInfo }) {
13131299
const match = /.*\.strings\.(\w+)\.js/.exec(id);
13141300
if (match) {
1315-
<<<<<<< HEAD
13161301
const language = match[1]; // 例如 “en”
1317-
=======
1318-
const language = match[1]; // e.g. "en"
13191302
// ---cut-start---
13201303
/** @type {string[]} */
13211304
// ---cut-end---
1322-
>>>>>>> 91352494fc722bcd5e8e922cd1497b34aec57a67
13231305
const dependentEntryPoints = [];
13241306

13251307
// 在这里,我们使用 Set 一次性处理每个依赖模块

0 commit comments

Comments
 (0)