Skip to content
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

docs(en): merge rollup/master into rollup-docs-cn/master @ 0595e433 #162

Merged
merged 6 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/build-and-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
- name: Cache Node Modules
id: cache-node-modules
uses: actions/cache@v4
Expand Down Expand Up @@ -207,7 +207,7 @@ jobs:
uses: actions/setup-node@v4
if: ${{ !matrix.settings.docker }}
with:
node-version: 20
node-version: 22
- name: Install Toolchain
uses: dtolnay/rust-toolchain@stable
if: ${{ !matrix.settings.docker }}
Expand Down Expand Up @@ -415,12 +415,12 @@ jobs:
target: aarch64-apple-darwin
node:
- '18.0.0'
- '20'
- '22'
include:
- settings:
host: ubuntu-latest
target: x86_64-unknown-linux-gnu
node: '20'
node: '22'
command: 'ci:coverage'
additionalName: ' with Coverage'
coverage: true
Expand Down Expand Up @@ -463,7 +463,7 @@ jobs:
env:
CI: true
- name: Upload coverage
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
if: matrix.coverage
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# rollup changelog

## 4.28.0

_2024-11-30_

### Features

- Allow to specify how to handle import attributes when transpiling Rollup config files (#5743)

### Pull Requests

- [#5743](https://github.com/rollup/rollup/pull/5743): fix: supports modify the import attributes key in the config file (@TrickyPi, @lukastaegert)
- [#5747](https://github.com/rollup/rollup/pull/5747): chore(deps): update codecov/codecov-action action to v5 (@renovate[bot])
- [#5748](https://github.com/rollup/rollup/pull/5748): chore(deps): lock file maintenance minor/patch updates (@renovate[bot])

## 4.27.4

_2024-11-23_
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.27.4",
"version": "4.28.0",
"description": "Next-generation ES module bundler browser build",
"main": "dist/rollup.browser.js",
"module": "dist/es/rollup.browser.js",
Expand Down
10 changes: 8 additions & 2 deletions cli/run/loadConfigFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from 'node:path';
import process from 'node:process';
import { pathToFileURL } from 'node:url';
import * as rollup from '../../src/node-entry';
import type { MergedRollupOptions } from '../../src/rollup/types';
import type { ImportAttributesKey, MergedRollupOptions } from '../../src/rollup/types';
import { bold } from '../../src/utils/colors';
import {
error,
Expand Down Expand Up @@ -90,11 +90,16 @@ function getDefaultFromCjs(namespace: GenericConfigObject): unknown {
return namespace.default || namespace;
}

function getConfigImportAttributesKey(input: unknown): ImportAttributesKey | undefined {
if (input === 'assert' || input === 'with') return input;
return;
}

async function loadTranspiledConfigFile(
fileName: string,
commandOptions: Record<string, unknown>
): Promise<unknown> {
const { bundleConfigAsCjs, configPlugin, silent } = commandOptions;
const { bundleConfigAsCjs, configPlugin, configImportAttributesKey, silent } = commandOptions;
const warnings = batchWarnings(commandOptions);
const inputOptions = {
external: (id: string) => (id[0] !== '.' && !path.isAbsolute(id)) || id.slice(-5) === '.json',
Expand All @@ -110,6 +115,7 @@ async function loadTranspiledConfigFile(
} = await bundle.generate({
exports: 'named',
format: bundleConfigAsCjs ? 'cjs' : 'es',
importAttributesKey: getConfigImportAttributesKey(configImportAttributesKey),
plugins: [
{
name: 'transpile-import-meta',
Expand Down
12 changes: 11 additions & 1 deletion docs/command-line-interface/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,17 @@ export default {

这允许你在配置中使用 CommonJS 常用的变量/方法,例如 `__dirname` 或 `require.resolve`,即使配置本身是作为 ES 模块编写的。

### `--configPlugin <plugin>` {#configplugin-plugin}
### `--configImportAttributesKey <with | assert>`

控制 Rollup 在配置文件中用于导入属性的关键字。

```shell
rollup --config rollup.config.ts --configPlugin typescript --configImportAttributesKey with
```

此选项仅在使用 [`--configPlugin`](#configplugin-plugin) 或 [`--bundleConfigAsCjs`](#bundleconfigascjs) 选项时可用。

### `--configPlugin <plugin>`

允许指定 Rollup 插件来转译或控制解析配置文件。主要好处是可以使用非 JavaScript 的配置文件。例如,如果你安装了 `@rollup/plugin-typescript`,则以下内容将允许你使用 TypeScript 编写配置文件:

Expand Down
Loading