From e0fc7d0d07575d53694725729aa0c362927bd9cd Mon Sep 17 00:00:00 2001 From: Bertrand Guay-Paquet Date: Sat, 23 Jul 2022 18:31:50 +0200 Subject: [PATCH 1/2] Documentation clarity and syntax improvements --- docs/01-command-line-reference.md | 18 ++++++++++-------- docs/999-big-list-of-options.md | 8 ++++---- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/docs/01-command-line-reference.md b/docs/01-command-line-reference.md index 601389c26d7..f92d0741a16 100755 --- a/docs/01-command-line-reference.md +++ b/docs/01-command-line-reference.md @@ -220,10 +220,7 @@ Since Rollup ships with TypeScript typings, you can leverage your IDE's Intellis /** * @type {import('rollup').RollupOptions} */ -const config = { - // ... -}; - +const config = { /* your config */ }; export default config; ``` @@ -233,9 +230,7 @@ Alternatively you can use the `defineConfig` helper, which should provide Intell // rollup.config.js import { defineConfig } from 'rollup'; -export default defineConfig({ - // ... -}); +export default defineConfig({ /* your config */ }; ``` Besides `RollupOptions` and the `defineConfig` helper that encapsulates this type, the following types can prove useful as well: @@ -244,7 +239,14 @@ Besides `RollupOptions` and the `defineConfig` helper that encapsulates this typ - `Plugin`: A plugin object that provides a `name` and some hooks. All hooks are fully typed to aid in plugin development. - `PluginImpl`: A function that maps an options object to a plugin object. Most public Rollup plugins follow this pattern. -You can also directly write your config in TypeScript via the [`--configPlugin`](guide/en/#--configplugin-plugin) option. +You can also directly write your config in TypeScript via the [`--configPlugin`](guide/en/#--configplugin-plugin) option. With TypeScript you can import the `RollupOptions` type directly: + +```typescript +import type { RollupOptions } from 'rollup'; + +const config: RollupOptions = { /* your config */ }; +export default config; +``` ### Differences to the JavaScript API diff --git a/docs/999-big-list-of-options.md b/docs/999-big-list-of-options.md index e09c71af6f8..a251653576b 100755 --- a/docs/999-big-list-of-options.md +++ b/docs/999-big-list-of-options.md @@ -919,11 +919,11 @@ import './lib.js'; // lib.js import('./dynamic.js'); -export const value = 42; +export const importantValue = 42; // dynamic.js -import { value } from './lib.js'; -console.log(value); +import { importantValue } from './lib.js'; +console.log(importantValue); ``` Output with `output.minifyInternalExports: true`: @@ -1075,7 +1075,7 @@ Type: `boolean | 'inline' | 'hidden'`
CLI: `-m`/`--sourcemap`/`--no-sourcema If `true`, a separate sourcemap file will be created. If `"inline"`, the sourcemap will be appended to the resulting `output` file as a data URI. `"hidden"` works like `true` except that the corresponding sourcemap comments in the bundled files are suppressed. -### output.sourcemapBaseUrl +#### output.sourcemapBaseUrl Type: `string`
CLI: `--sourcemapBaseUrl ` From 2aab1f17f012f83b9138a1fcdef2bd4e737ee97f Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Tue, 26 Jul 2022 09:19:01 +0200 Subject: [PATCH 2/2] Fix linting --- docs/01-command-line-reference.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/01-command-line-reference.md b/docs/01-command-line-reference.md index f92d0741a16..5ebd91ce780 100755 --- a/docs/01-command-line-reference.md +++ b/docs/01-command-line-reference.md @@ -220,7 +220,9 @@ Since Rollup ships with TypeScript typings, you can leverage your IDE's Intellis /** * @type {import('rollup').RollupOptions} */ -const config = { /* your config */ }; +const config = { + /* your config */ +}; export default config; ``` @@ -244,7 +246,9 @@ You can also directly write your config in TypeScript via the [`--configPlugin`] ```typescript import type { RollupOptions } from 'rollup'; -const config: RollupOptions = { /* your config */ }; +const config: RollupOptions = { + /* your config */ +}; export default config; ```