Skip to content

Commit

Permalink
Merge pull request #142 from rollup/sync-8ad322cc
Browse files Browse the repository at this point in the history
docs(en): merge rollup/master into rollup-docs-cn/master @ 8ad322c
  • Loading branch information
waynzh authored Jun 5, 2024
2 parents 943f255 + fa04a7e commit 14d8db0
Show file tree
Hide file tree
Showing 29 changed files with 637 additions and 716 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build-and-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ jobs:
build: >-
set -e &&
export JEMALLOC_SYS_WITH_LG_PAGE=16 &&
rustup default nightly-2023-10-05 &&
rustup default stable &&
rustup target add aarch64-unknown-linux-gnu &&
npm run build:napi -- --release --target aarch64-unknown-linux-gnu
- host: ubuntu-latest
Expand All @@ -156,7 +156,7 @@ jobs:
build: >-
set -e &&
export JEMALLOC_SYS_WITH_LG_PAGE=16 &&
rustup default nightly-2023-10-05 &&
rustup default stable &&
rustup target add aarch64-unknown-linux-musl &&
RUSTFLAGS='-C target-feature=-crt-static -C linker=aarch64-linux-musl-gcc' npm run build:napi -- --release --target aarch64-unknown-linux-musl
- host: ubuntu-latest
Expand Down Expand Up @@ -212,7 +212,7 @@ jobs:
uses: dtolnay/rust-toolchain@stable
if: ${{ !matrix.settings.docker }}
with:
toolchain: nightly-2023-10-05
toolchain: stable
targets: ${{ matrix.settings.target }}
- name: Cache cargo
uses: actions/cache@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/performance-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Install Toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly-2023-10-05
toolchain: stable
targets: x86_64-unknown-linux-gnu
- name: Cache cargo
uses: actions/cache@v4
Expand Down Expand Up @@ -84,7 +84,7 @@ jobs:
- name: Install Toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly-2023-10-05
toolchain: stable
targets: x86_64-unknown-linux-gnu
- name: Cache cargo
uses: actions/cache@v4
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/repl-artefacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ jobs:
- name: Install Toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly-2023-10-05
targets: x86_64-unknown-linux-gnu
toolchain: stable
targets: wasm32-unknown-unknown
- name: Cache cargo
uses: actions/cache@v4
with:
Expand Down Expand Up @@ -114,7 +114,7 @@ jobs:
npm install ${{ github.event.pull_request.head.repo.full_name }}#${{ github.event.pull_request.head.ref }}
```
Notice: Ensure you have installed 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.
Notice: Ensure you have installed the latest stable Rust toolchain. If you haven't installed it yet, please see https://www.rust-lang.org/tools/install to learn how to download Rustup and install Rust.
or load it into the REPL:
https://rollupjs.org/repl/?pr=${{ github.event.number }}
Expand All @@ -139,7 +139,7 @@ jobs:
npm install ${{ github.event.pull_request.head.repo.full_name }}#${{ github.event.pull_request.head.ref }}
```
Notice: Ensure you have installed 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.
Notice: Ensure you have installed the latest stable Rust toolchain. If you haven't installed it yet, please see https://www.rust-lang.org/tools/install to learn how to download Rustup and install Rust.
or load it into the REPL:
${{ steps.waitForVercel.outputs.url }}/repl/?pr=${{ github.event.number }}
10 changes: 5 additions & 5 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

- The [`rollup`](https://www.npmjs.com/package/rollup) npm package contains both Rollup's Node.js JavaScript interface and the command-line-interface (CLI).
- There is a separate browser build available as [`@rollup/browser`](https://www.npmjs.com/package/@rollup/browser). It exposes the same JavaScript interface as the Node.js build but does not include the CLI and also requires writing a plugin to encapsulate file reading. Instead of native code dependencies, this build has a bundled WASM artifact included that can be loaded in the browser. This is what the [Rollup REPL](https://rollupjs.org/repl) uses.
- For every supported platform-architecture combination, there is a separate pacakge containing the native code. These are not listed in the committed `package.json` file but are added dynamically during publishing as `optionalDependencies`. The `README.md` and `package.json` files for those dependencies can be found in the [`npm`](npm) folder. The corresponding binaries are built and published from [GitHub Actions](.github/workflows/build-and-tests.yml) whenever a new release version tag is pushed. The actual loading of the native code is handled by [`native.js`](native.js) which is copied into the output folder during build. So to add a new platform-architecture combination, you need to
- For every supported platform-architecture combination, there is a separate package containing the native code. These are not listed in the committed `package.json` file but are added dynamically during publishing as `optionalDependencies`. The `README.md` and `package.json` files for those dependencies can be found in the [`npm`](npm) folder. The corresponding binaries are built and published from [GitHub Actions](.github/workflows/build-and-tests.yml) whenever a new release version tag is pushed. The actual loading of the native code is handled by [`native.js`](native.js) which is copied into the output folder during build. So to add a new platform-architecture combination, you need to
- add a new package in the `npm` folder
- update the `native.js` file
- add the corresponding triple to the [`package.json`](package.json) file as napi-rs depends on this
Expand All @@ -24,7 +24,7 @@
- The entry point for the Node.js build is [`node-entry.ts`](src/node-entry.ts) while the browser build uses [`browser-entry.ts`](src/browser-entry.ts). Those are mostly identical except that the browser build does not expose the watch mode interface.
- The CLI is a wrapper around the JavaScript interface.
- It resides in the [`cli` folder](cli) with the entry point [cli.ts](cli/cli.ts).
- The logic to read configuration files resides in [locaConfigFile.ts](cli/run/loadConfigFile.ts) and is exposed as a separate export via `import { loadConfigFile } from "rollup/loadConfigFile"`.
- The logic to read configuration files resides in [loadConfigFile.ts](cli/run/loadConfigFile.ts) and is exposed as a separate export via `import { loadConfigFile } from "rollup/loadConfigFile"`.
- Only the CLI is able to handle arrays of configurations. Those are handled sequentially in [`run/index.ts`](cli/run/index.ts).
- The CLI handles several CLI-only options that are specific to the Node.js environment like setting environment variables or handling std-in, see [Command line flags](docs/command-line-interface/index.md#command-line-flags).

Expand All @@ -42,7 +42,7 @@ The Rust entrypoints are [`bindings_napi/src/lib.rs`](rust/bindings_napi/src/lib

Building an output has two phases

- The "build" phase builds a module graph form the input files and decides, which code should be included in the output
- The "build" phase builds a module graph from the input files and decides, which code should be included in the output
- It is triggered by calling the `rollup(inputOptions)` function exported by the JavaScript interface
- It returns a "bundle" object that has `generate` and `write` methods
- The "generate" phase generates the output files from the bundle by calling `.generate(outputOptions)` or `.write(outputOptions)`
Expand Down Expand Up @@ -96,14 +96,14 @@ To understand this phase from a plugin perspective, have a look at [Build Hooks]

To understand this phase from a plugin perspective, have a look at [Output Generation Hooks](https://rollupjs.org/plugin-development/#output-generation-hooks), which again contains a graph to show in which order these hooks are executed. In detail `Bundle.generate` performs the following steps

- Assign modules to chunks via [`chunkAssigment.ts`](src/utils/chunkAssignment.ts)
- Assign modules to chunks via [`chunkAssignment.ts`](src/utils/chunkAssignment.ts)
- Determine the exports for each chunk by tracing the included inter-module dependencies
- Render the chunks, which is orchestrated by the [`renderChunks`](src/utils/renderChunks.ts) helper
- Render the chunks with placeholders for chunk hashes by calling `Chunk.render()`
- Determine how dynamic imports and `import.meta` references should be resolved and store this on the corresponding AST nodes.
- Determine the final deconflicted variable names and store those on the AST nodes as well in [`deconflictChunk.ts`](src/utils/deconflictChunk.ts)
- Render each module by calling the `.render` methods of their AST nodes. This is also where tree-shaken nodes are removed from the output.
- Render the format specific wrapper with imports and exports for this chunk by calling the corresponding [finalizer](src/finalisers).
- Render the format specific wrapper with imports and exports for this chunk by calling the corresponding [finaliser](src/finalisers).
- Transform the rendered chunks via the [`renderChunk`](https://rollupjs.org/plugin-development/#renderchunk) plugin hook
- Determine the final chunk hashes based on the actual rendered content and the chunk dependency graph and replace the placeholders

Expand Down
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# rollup changelog

## 4.18.0

_2024-05-22_

### Features

- Resolve import.meta.filename and .dirname in transpiled plugins (#5520)

### Pull Requests

- [#5504](https://github.com/rollup/rollup/pull/5504): Auto generate node index (@lukastaegert)
- [#5507](https://github.com/rollup/rollup/pull/5507): chore(deps): lock file maintenance minor/patch updates (@renovate[bot])
- [#5508](https://github.com/rollup/rollup/pull/5508): chore(deps): lock file maintenance (@renovate[bot])
- [#5510](https://github.com/rollup/rollup/pull/5510): Split up converter.rs into AST nodes (@lukastaegert)
- [#5512](https://github.com/rollup/rollup/pull/5512): chore(deps): update dependency builtin-modules to v4 (@renovate[bot], @lukastaegert)
- [#5514](https://github.com/rollup/rollup/pull/5514): chore(deps): lock file maintenance minor/patch updates (@renovate[bot])
- [#5518](https://github.com/rollup/rollup/pull/5518): chore(deps): update dependency eslint-plugin-unicorn to v53 (@renovate[bot], @lukastaegert)
- [#5519](https://github.com/rollup/rollup/pull/5519): chore(deps): lock file maintenance minor/patch updates (@renovate[bot], @lukastaegert)
- [#5520](https://github.com/rollup/rollup/pull/5520): Resolve import.meta.{filename,dirname} in files imported from config (@BPScott)
- [#5521](https://github.com/rollup/rollup/pull/5521): docs: correct base32 to base36 in documentation (@highcastlee)

## 4.17.2

_2024-04-30_
Expand Down
12 changes: 8 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ 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.
Rollup now includes some Rust code. To compile it, you need to set up the Rust toolchain. If you haven't installed it yet, please see https://www.rust-lang.org/tools/install to learn how to download Rustup and install Rust.

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:
Make sure you use the same toolchain 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
rustup toolchain install stable
rustup default stable
```

You should also install the `wasm32-unknown-unknown` target:
Expand Down Expand Up @@ -61,6 +61,10 @@ After applying this setting, you may need to reset your local branch to ensure t
git reset --hard
```

### Installing dependencies

Running `npm install` will install the necessary dependencies. If it fails, it might be because the Rust toolchain is not yet set up for WebAssembly, see above.

### How to run one test on your local machine

With `npm run test` you can run all tests together.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Repository: micromatch/braces

> The MIT License (MIT)
>
> Copyright (c) 2014-2018, Jon Schlinkert.
> Copyright (c) 2014-present, Jon Schlinkert.
>
> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
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.17.2",
"version": "4.18.0",
"description": "Next-generation ES module bundler browser build",
"main": "dist/rollup.browser.js",
"module": "dist/es/rollup.browser.js",
Expand Down
8 changes: 7 additions & 1 deletion cli/run/loadConfigFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,14 @@ async function loadTranspiledConfigFile(
if (property === 'url') {
return `'${pathToFileURL(moduleId).href}'`;
}
if (property == 'filename') {
return `'${moduleId}'`;
}
if (property == 'dirname') {
return `'${path.dirname(moduleId)}'`;
}
if (property == null) {
return `{url:'${pathToFileURL(moduleId).href}'}`;
return `{url:'${pathToFileURL(moduleId).href}', filename: '${moduleId}', dirname: '${path.dirname(moduleId)}'}`;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration-options/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ exports.foo = foo;

| | |
| -----: | :------------------------------ |
| 类型: | `"base64" \| "base32" \| "hex"` |
| 类型: | `"base64" \| "base36" \| "hex"` |
| CLI: | `--hashCharacters <name>` |
| 默认: | `"base64"` |

Expand Down
Loading

0 comments on commit 14d8db0

Please sign in to comment.