Skip to content

Commit

Permalink
Merge pull request #119 from rollup/sync-27690dc0
Browse files Browse the repository at this point in the history
docs(en): merge rollup/master into rollup-docs-cn/master @ 27690dc
  • Loading branch information
waynzh committed Feb 28, 2024
2 parents f3b5f44 + b57cc2a commit efe2119
Show file tree
Hide file tree
Showing 621 changed files with 6,464 additions and 3,870 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ module.exports = {
'unicorn/no-null': 'off',
'unicorn/no-this-assignment': 'off',
'unicorn/no-useless-undefined': 'off',
'unicorn/number-literal-case': 'off',
'unicorn/prefer-at': 'off',
'unicorn/prefer-code-point': 'off',
'unicorn/prefer-math-trunc': 'off',
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/build-and-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ jobs:
run: npm audit
- name: Optional Dependencies
run: npm run test:package
- name: CLI Docs
run: npm run test:options
- name: Generated Code
run: |
npm run build:ast-converters
Expand Down Expand Up @@ -318,11 +316,10 @@ jobs:
env:
CI: true
- name: Upload coverage
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
if: matrix.coverage
with:
# It appears adding the token may result in the coverage comment not being added
# token: ${{ secrets.CODECOV_TOKEN }}
token: ${{ secrets.CODECOV_TOKEN }}
commit_parent: ${{ github.event.pull_request.head.sha }}

publish:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/repl-artefacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ jobs:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Find Comment
uses: peter-evans/find-comment@v2
uses: peter-evans/find-comment@v3
id: findComment
with:
issue-number: ${{ github.event.number }}
comment-author: 'github-actions[bot]'
body-includes: 'Thank you for your contribution!'
- name: Create or update comment
uses: peter-evans/create-or-update-comment@v3
uses: peter-evans/create-or-update-comment@v4
id: createInitialComment
with:
comment-id: ${{ steps.findComment.outputs.comment-id }}
Expand All @@ -124,7 +124,7 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Update comment with Vercel preview URL
uses: peter-evans/create-or-update-comment@v3
uses: peter-evans/create-or-update-comment@v4
if: ${{ steps.waitForVercel.outputs.url }}
with:
comment-id: ${{ steps.createInitialComment.outputs.comment-id }}
Expand Down
7 changes: 1 addition & 6 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx zhlint docs/**/*.md --fix
if [ \"$SKIP_BUILD\" != \"true\" ]; then npm run build:docs; fi
git add -A
npx lint-staged
62 changes: 62 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,67 @@
# rollup changelog

## 4.12.0

_2024-02-16_

### Features

- Improve raw bundling performance by 10-15% when not using the cache or plugins that return an AST (#5391)

### Pull Requests

- [#5391](https://github.com/rollup/rollup/pull/5391): Improve performance by directly constructing AST from buffer (@lukastaegert)
- [#5393](https://github.com/rollup/rollup/pull/5393): chore(deps): update dependency eslint-plugin-unicorn to v51 (@renovate[bot])
- [#5394](https://github.com/rollup/rollup/pull/5394): chore(deps): update typescript-eslint monorepo to v7 (major) (@renovate[bot])
- [#5395](https://github.com/rollup/rollup/pull/5395): chore(deps): lock file maintenance minor/patch updates (@renovate[bot])

## 4.11.0

_2024-02-15_

### Features

- Add `output.reexportProtoFromExternal` option to disable special code for handling `__proto__` reexports (#5380)

### Bug Fixes

- Ensure namespace reexport code can be parsed by cjs-module-lexer (#5380)
- Throw when trying to reassing `const` variables (#5388)

### Pull Requests

- [#5380](https://github.com/rollup/rollup/pull/5380): fix: separately export `__proto__` for compatibility with CJS Transpiler Re-exports (@TrickyPi)
- [#5388](https://github.com/rollup/rollup/pull/5388): Add const reassign rule (@TrickyPi)

## 4.10.0

_2024-02-10_

### Features

- Support base-36 and base-16 hashes again via new `output.hashCharacters` option (#5371)

### Bug Fixes

- Do not crash process for panics in native code but throw them as JavaScript errors (#5383)

### Pull Requests

- [#5359](https://github.com/rollup/rollup/pull/5359): chore(deps): update actions/cache action to v4 (@renovate[bot])
- [#5360](https://github.com/rollup/rollup/pull/5360): chore(deps): update dependency pretty-ms to v9 (@renovate[bot])
- [#5366](https://github.com/rollup/rollup/pull/5366): chore(deps): update dependency husky to v9 (@renovate[bot])
- [#5367](https://github.com/rollup/rollup/pull/5367): chore(deps): update peter-evans/create-or-update-comment action to v4 (@renovate[bot])
- [#5368](https://github.com/rollup/rollup/pull/5368): chore(deps): update peter-evans/find-comment action to v3 (@renovate[bot])
- [#5369](https://github.com/rollup/rollup/pull/5369): chore(deps): lock file maintenance minor/patch updates (@renovate[bot])
- [#5370](https://github.com/rollup/rollup/pull/5370): Fix dependency range for Node types (@lukastaegert)
- [#5371](https://github.com/rollup/rollup/pull/5371): Implement "output.hashCharacters" option to define character set for file hashes (@lukastaegert)
- [#5372](https://github.com/rollup/rollup/pull/5372): Roll back vitepress as 1.0.0-rc.40 breaks the development build (@lukastaegert)
- [#5382](https://github.com/rollup/rollup/pull/5382): Update documentation (@TrickyPi)
- [#5383](https://github.com/rollup/rollup/pull/5383): Catch Rust panics and then throw them in JS (@TrickyPi)
- [#5384](https://github.com/rollup/rollup/pull/5384): chore(deps): update codecov/codecov-action action to v4 (@renovate[bot])
- [#5385](https://github.com/rollup/rollup/pull/5385): chore(deps): lock file maintenance minor/patch updates (@renovate[bot])
- [#5386](https://github.com/rollup/rollup/pull/5386): Resolve all rollup imports to node_modules to avoid type conflict (@TrickyPi)

## 4.9.6

_2024-01-21_
Expand Down
51 changes: 49 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,28 @@ Working on your first Pull Request? You can learn how from this _free_ course, [

### Setting up the Rust toolchain

Rollup now includes some Rust code. To compile it, you need to set up Rust nightly. If you haven't installed it yet, please first see https://www.rust-lang.org/tools/install to learn how to download Rustup and install Rust, then see https://rust-lang.github.io/rustup/concepts/channels.html to learn how to install Rust nightly. If everything is set up correctly, `npm run build` should complete successfully. The first build will be rather slow, but subsequent builds will be much faster.
Rollup now includes some Rust code. To compile it, you need to set up Rust nightly. If you haven't installed it yet, please first see https://www.rust-lang.org/tools/install to learn how to download Rustup and install Rust, then see https://rust-lang.github.io/rustup/concepts/channels.html to learn how to install Rust nightly.

Make sure you use the same nightly version as specified in the `/rust/rust-toolchain.toml` file. You should be able to install it with the following commands:

```shell
rustup toolchain install nightly-2023-10-05
rustup default nightly-2023-10-05
```

You should also install the `wasm32-unknown-unknown` target:

```shell
rustup target add wasm32-unknown-unknown
```

In the end, run

```shell
rustup update
```

If everything is set up correctly, `npm run build` should complete successfully. The first build will be rather slow, but subsequent builds will be much faster.

For local development and tests, it is even faster to run `npm run build:quick`, which does not perform a Rust production build, does not build WASM artefacts, and only builds the CommonJS version of Rollup. Note that with this build, a few tests will fail that rely on the other artefacts, see below.

Expand Down Expand Up @@ -56,6 +77,32 @@ npm run test:quick

Note that this does not run the browser tests and a few CLI tests will fail.

### How to write tests

For any new feature or bug fix, sufficient test coverage is crucial.

Note that Rollup does not really have unit tests, only the external APIs are tested with the full Rollup build. While this may seem unusual, the tests are still very stable and fast. This provides us with the ability to perform major refactorings of the code base while ensuring full compatibility with the previous versions.

There are different test categories. Most of these tests are directory-based where you have a directory with a `_config.js` file that contains the test description and configuration and several code files. See [/test/types.d.ts](./test/types.d.ts) for a full list of available test configuration options for all directory based test types. By default, unless specified otherwise, the `main.js` file is the entry point for the test. To run the tests in an IDE, configure a ["Mocha" compatible test runner](https://mochajs.org/#editor-plugins) that uses `test/test.js` as the entry point.

- **[`test/function`](./test/function/samples)**: These tests bundle to CommonJS and then run the entry point provided by `main.js`. The `assert` function from `node:assert` is injected as a global variable, so you can make inline assertions in the code. You can also use the `exports` configuration key to make assertions on the exported values. These are very stable and meaningful tests and should be your first choice for new tests.
- For regression testing when Rollup produces invalid code or crashes
- For testing plugin interactions. To do so, import `node:assert` in your `_config.js` file and make assertions in your plugin hooks as needed.
- For testing expected bundling errors, warnings and logs (use the `error`, `generateError`, `warnings` and `logs` configuration keys)
- For asserting on the generated bundle object (use the `bundle` configuration key)
- **[`test/form`](./test/form/samples)**: These tests bundle to all output formats and do not run the code. They compare the bundled code against an `_expected` directory that contains the output for all formats. If the format is not important, you can specify an `_expected.js` file instead, which will be compared against the output when bundling to ES module format.
- For testing tree-shaking
- For testing code that does not run on all supported NodeJS platforms
- **[`test/chunking-form`](./test/chunking-form/samples)**: Similar to the `form` tests, these tests support multiple output files and assets. Instead of a single file, there is a directory for each output format.
- **[`test/cli`](./test/cli/samples)**: These tests run the Rollup CLI with a given configuration. They can compare the generated files against provided files and make assertions on stderr output. They can also optionally run the generated files.
- **[`test/watch`](./test/watch)**: Test that watch mode works as expected. These tests are actually in the `index.js` file and only use the `samples` directory for input files.
- **[`test/browser`](./test/browser/samples)**: These tests bundle with the browser build of Rollup. They compare the output to an `_expected` directory and allow to make assertions on bundling errors. Note that you need to provide all input files via plugins.
- **[`test/sourcemaps`](./test/sourcemaps/samples)**: Tests to make assertions on the generated sourcemaps.
- **[`test/incremental`](./test/incremental)**: For testing the caching behaviour of Rollup. As these tests need to run Rollup more than once, it was not easily possible to implement them as directory-based tests.
- **[`test/file-hashes`](./test/file-hashes/samples)**: Relevant for testing that different outputs have different file hashes. With the new hashing algorithm, these tests are not as important as they used to be and are kept mostly for historical reasons.
- **[`test/hooks`](./test/hooks)**: Do not add new tests here. These tests were the original tests for the plugin interface. For new tests, `function` tests are preferred as they are much easier to maintain.
- **[`test/misc`](./test/misc)**: General tests that do not fit into the other categories.

### Developing with the website

Running
Expand Down Expand Up @@ -84,7 +131,7 @@ We also welcome financial contributions in full transparency on our [open collec

## Questions

If you require technical assistance, [Stackoverflow](https://stackoverflow.com/questions/tagged/rollupjs) or [Discord](https://is.gd/rollup_chat) are usually the best places to start. You can also create an [issue](issue) (protip: do a quick search first to see if someone else didn't ask the same question before!).
If you require technical assistance, [Stackoverflow](https://stackoverflow.com/questions/tagged/rollupjs) or [Discord](https://is.gd/rollup_chat) are usually the best places to start. You can also create an [issue](issue) ( protip: do a quick search first to see if someone else didn't ask the same question before!).

## Credits

Expand Down
2 changes: 1 addition & 1 deletion browser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rollup/browser",
"version": "4.9.6",
"version": "4.12.0",
"description": "Next-generation ES module bundler browser build",
"main": "dist/rollup.browser.js",
"module": "dist/es/rollup.browser.js",
Expand Down
2 changes: 1 addition & 1 deletion browser/src/wasm.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// eslint-disable-next-line import/no-unresolved
export { parse, xxhashBase64Url } from '../../wasm/bindings_wasm.js';
export { parse, xxhashBase64Url, xxhashBase36, xxhashBase16 } from '../../wasm/bindings_wasm.js';

// eslint-disable-next-line import/no-unresolved
import { parse } from '../../wasm/bindings_wasm.js';
Expand Down
2 changes: 2 additions & 0 deletions cli/help.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Basic options:
--generatedCode.objectShorthand Use shorthand properties in generated code
--no-generatedCode.reservedNamesAsProps Always quote reserved names as props
--generatedCode.symbols Use symbols in generated code
--hashCharacters <name> Use the specified character set for file hashes
--no-hoistTransitiveImports Do not hoist transitive imports into entry chunks
--no-indent Don't indent result
--inlineDynamicImports Create single bundle when using dynamic imports
Expand All @@ -64,6 +65,7 @@ Basic options:
--preserveModules Preserve module structure
--preserveModulesRoot Put preserved modules under this path at root level
--preserveSymlinks Do not follow symlinks when resolving files
--no-reexportProtoFromExternal Ignore `__proto__` in star re-exports
--no-sanitizeFileName Do not replace invalid characters in file names
--shimMissingExports Create shim variables for missing exports
--silent Don't print warnings
Expand Down
6 changes: 6 additions & 0 deletions cli/run/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ export default async function runRollup(command: Record<string, any>): Promise<v
const { options, warnings } = await getConfigs(command);
try {
for (const inputOptions of options) {
if (!inputOptions.cache) {
// We explicitly disable the cache when unused as the CLI will not
// use the cache object on the bundle when not in watch mode. This
// improves performance as the cache is not generated.
inputOptions.cache = false;
}
await build(inputOptions, warnings, command.silent);
}
if (command.failAfterWarnings && warnings.warningOccurred) {
Expand Down
2 changes: 1 addition & 1 deletion cli/run/watch-cli.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { FSWatcher } from 'node:fs';
import { readFile } from 'node:fs/promises';
import process from 'node:process';
import type { FSWatcher } from 'chokidar';
import chokidar from 'chokidar';
import dateTime from 'date-time';
import ms from 'pretty-ms';
Expand Down
5 changes: 5 additions & 0 deletions docs/command-line-interface/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export default {
externalImportAttributes,
footer,
generatedCode,
hashCharacters,
hoistTransitiveImports,
inlineDynamicImports,
interop,
Expand Down Expand Up @@ -390,13 +391,15 @@ export default {
--failAfterWarnings 如果生成的构建产生警告,则退出并显示错误
--filterLogs <filter> 过滤日志信息
--footer <text> 在产物底部插入的代码(位于包装器之外)
--forceExit 当任务完成后,强制结束进程
--no-freeze 不冻结命名空间对象
--generatedCode <preset> 使用哪些代码特性(es5/es2015)
--generatedCode.arrowFunctions 在生成的代码中使用箭头函数
--generatedCode.constBindings 在生成的代码中使用 "const"
--generatedCode.objectShorthand 在生成的代码中使用简写属性
--no-generatedCode.reservedNamesAsProps 始终引用保留名称作为 props
--generatedCode.symbols 在生成的代码中使用符号
--hashCharacters <name> 使用指定的字符集来生成文件的哈希值
--no-hoistTransitiveImports 不将中转导入提升到入口块中
--no-indent 不缩进结果
--inlineDynamicImports 使用动态导入时创建单次打包
Expand All @@ -413,6 +416,7 @@ export default {
--preserveModules 保留模块结构
--preserveModulesRoot 将保留的模块放置在根路径下的此路径下
--preserveSymlinks 解析文件时不要跟随符号链接
--no-reexportProtoFromExternal 在使用重新导出星号('*')时,忽略 __proto__
--no-sanitizeFileName 不要替换文件名中的无效字符
--shimMissingExports 为丢失的导出创建卡扣变量
--silent 不打印警告
Expand Down Expand Up @@ -510,6 +514,7 @@ npm run build -- --environment BUILD:development
```shell
rollup -c --filterLogs code:EVAL
```
仅会展示 `log.code === 'EVAL'` 的日志消息。可以通过使用逗号分隔它们或多次使用该选项来指定多个过滤器:
```shell
Expand Down
Loading

0 comments on commit efe2119

Please sign in to comment.