From 219cacb56f9e482ad6c31eda1f802abea41a8993 Mon Sep 17 00:00:00 2001 From: Stephan Schreiber Date: Thu, 4 Sep 2025 07:23:06 +0200 Subject: [PATCH] fix(*): add named export to all plugins --- packages/alias/README.md | 7 +++++++ packages/alias/src/index.ts | 3 ++- packages/alias/types/index.d.ts | 3 ++- packages/auto-install/README.md | 14 +++++++++++--- packages/auto-install/src/index.ts | 3 ++- packages/auto-install/types/index.d.ts | 3 ++- packages/babel/types/index.d.ts | 4 ++-- packages/beep/README.md | 11 +++++++++-- packages/beep/lib/index.js | 1 + packages/beep/types/index.d.ts | 3 ++- packages/buble/README.md | 7 +++++++ packages/buble/src/index.ts | 3 ++- packages/buble/types/index.d.ts | 3 ++- packages/commonjs/README.md | 7 +++++++ packages/commonjs/src/index.js | 3 ++- packages/commonjs/types/index.d.ts | 3 ++- packages/data-uri/README.md | 9 ++++++++- packages/data-uri/src/index.ts | 3 ++- packages/data-uri/types/index.d.ts | 3 ++- packages/dsv/README.md | 7 +++++++ packages/dsv/src/index.js | 3 ++- packages/dsv/types/index.d.ts | 3 ++- packages/dynamic-import-vars/README.md | 7 +++++++ packages/dynamic-import-vars/src/index.js | 2 +- packages/dynamic-import-vars/types/index.d.ts | 5 ++--- packages/eslint/README.md | 7 +++++++ packages/eslint/src/index.ts | 3 ++- packages/eslint/types/index.d.ts | 3 ++- packages/esm-shim/README.md | 7 +++++++ packages/esm-shim/src/module.ts | 1 + packages/esm-shim/types/index.d.ts | 6 ++++-- packages/graphql/README.md | 7 +++++++ packages/graphql/src/index.js | 3 ++- packages/graphql/types/index.d.ts | 3 ++- packages/html/README.md | 11 +++++++++-- packages/html/src/index.ts | 3 ++- packages/html/types/index.d.ts | 3 ++- packages/image/README.md | 7 +++++++ packages/image/src/index.js | 3 ++- packages/image/types/index.d.ts | 3 ++- packages/inject/README.md | 7 +++++++ packages/inject/src/index.js | 3 ++- packages/inject/types/index.d.ts | 3 ++- packages/json/README.md | 7 +++++++ packages/json/src/index.js | 3 ++- packages/json/types/index.d.ts | 3 ++- packages/legacy/README.md | 7 +++++++ packages/legacy/src/index.js | 3 ++- packages/legacy/types/index.d.ts | 3 ++- packages/multi-entry/README.md | 11 +++++++++-- packages/multi-entry/src/index.js | 3 ++- packages/multi-entry/types/index.d.ts | 3 ++- packages/replace/README.md | 7 +++++++ packages/replace/src/index.js | 3 ++- packages/replace/types/index.d.ts | 3 ++- packages/run/README.md | 7 +++++++ packages/run/src/index.ts | 3 ++- packages/run/types/index.d.ts | 3 ++- packages/strip/README.md | 7 +++++++ packages/strip/src/index.js | 3 ++- packages/strip/types/index.d.ts | 3 ++- packages/sucrase/README.md | 7 +++++++ packages/sucrase/src/index.js | 3 ++- packages/sucrase/types/index.d.ts | 3 ++- packages/swc/README.md | 7 +++++++ packages/swc/types/index.d.ts | 3 ++- packages/terser/README.md | 7 +++++++ packages/terser/src/index.ts | 2 +- packages/terser/types/index.d.ts | 3 ++- packages/typescript/README.md | 7 +++++++ packages/typescript/src/index.ts | 3 ++- packages/typescript/types/index.d.ts | 5 +++-- packages/url/README.md | 6 ++++++ packages/url/src/index.js | 3 ++- packages/url/types/index.d.ts | 3 ++- packages/virtual/README.md | 6 ++++++ packages/virtual/src/index.ts | 3 ++- packages/virtual/types/index.d.ts | 3 ++- packages/yaml/README.md | 7 +++++++ packages/yaml/src/index.js | 3 ++- packages/yaml/types/index.d.ts | 3 ++- 81 files changed, 305 insertions(+), 67 deletions(-) diff --git a/packages/alias/README.md b/packages/alias/README.md index 7bb0e2246..fb612f39a 100644 --- a/packages/alias/README.md +++ b/packages/alias/README.md @@ -67,6 +67,13 @@ export default { }; ``` +> [!NOTE] +> If your editor complains that _"alias is not a function"_, then use the named export instead: +> +> ```js +> import { alias } from '@rollup/plugin-alias'; +> ``` + Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api). If the build produces any errors, the plugin will write a 'alias' character to stderr, which should be audible on most systems. ## Options diff --git a/packages/alias/src/index.ts b/packages/alias/src/index.ts index 51503848c..baf3c354b 100755 --- a/packages/alias/src/index.ts +++ b/packages/alias/src/index.ts @@ -62,7 +62,7 @@ function resolveCustomResolver( return null; } -export default function alias(options: RollupAliasOptions = {}): Plugin { +function alias(options: RollupAliasOptions = {}): Plugin { const entries = getEntries(options); if (entries.length === 0) { @@ -114,3 +114,4 @@ export default function alias(options: RollupAliasOptions = {}): Plugin { } }; } +export { alias, alias as default }; diff --git a/packages/alias/types/index.d.ts b/packages/alias/types/index.d.ts index 52cc2a471..3dca8568c 100644 --- a/packages/alias/types/index.d.ts +++ b/packages/alias/types/index.d.ts @@ -41,4 +41,5 @@ export interface RollupAliasOptions { /** * 🍣 A Rollup plugin for defining aliases when bundling packages. */ -export default function alias(options?: RollupAliasOptions): Plugin; +declare function alias(options?: RollupAliasOptions): Plugin; +export { alias, alias as default }; diff --git a/packages/auto-install/README.md b/packages/auto-install/README.md index 9052da468..1f6132980 100755 --- a/packages/auto-install/README.md +++ b/packages/auto-install/README.md @@ -28,7 +28,7 @@ npm install @rollup/plugin-auto-install --save-dev Create a `rollup.config.js` [configuration file](https://www.rollupjs.org/guide/en/#configuration-files) and import the plugin: ```js -import auto from '@rollup/plugin-auto-install'; +import autoInstall from '@rollup/plugin-auto-install'; import resolve from '@rollup/plugin-node-resolve'; export default { @@ -37,11 +37,19 @@ export default { dir: 'output', format: 'cjs' }, - plugins: [auto(), resolve()] + plugins: [autoInstall(), resolve()] }; ``` -_Note: ensure that this plugin is added to the `plugins` array *before* [@rollup/plugin-node-resolve](https://github.com/rollup/plugins/tree/master/packages/node-resolve)._ +> [!NOTE] +> If your editor complains that _"autoInstall is not a function"_, then use the named export instead: +> +> ```js +> import { autoInstall } from '@rollup/plugin-auto-install'; +> ``` + +> [!IMPORTANT] +> Ensure that this plugin is added to the `plugins` array _before_ [@rollup/plugin-node-resolve](https://github.com/rollup/plugins/tree/master/packages/node-resolve). Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api). diff --git a/packages/auto-install/src/index.ts b/packages/auto-install/src/index.ts index 13dbd7b07..cfac14ea4 100644 --- a/packages/auto-install/src/index.ts +++ b/packages/auto-install/src/index.ts @@ -10,7 +10,7 @@ import type { RollupAutoInstallOptions } from '../types'; const execAsync = promisify(exec); -export default function autoInstall(opts: RollupAutoInstallOptions = {}): Plugin { +function autoInstall(opts: RollupAutoInstallOptions = {}): Plugin { const defaults = { // intentionally undocumented options. used for tests commands: { @@ -73,3 +73,4 @@ export default function autoInstall(opts: RollupAutoInstallOptions = {}): Plugin } }; } +export { autoInstall, autoInstall as default }; diff --git a/packages/auto-install/types/index.d.ts b/packages/auto-install/types/index.d.ts index d9e564445..a225ceff0 100644 --- a/packages/auto-install/types/index.d.ts +++ b/packages/auto-install/types/index.d.ts @@ -19,4 +19,5 @@ export interface RollupAutoInstallOptions { /** * 🍣 A Rollup plugin which automatically installs dependencies that are imported by a bundle, even if not yet in `package.json`. */ -export default function auto(options?: RollupAutoInstallOptions): Plugin; +declare function autoInstall(options?: RollupAutoInstallOptions): Plugin; +export { autoInstall, autoInstall as default }; diff --git a/packages/babel/types/index.d.ts b/packages/babel/types/index.d.ts index 1a82da7ba..947ea836c 100644 --- a/packages/babel/types/index.d.ts +++ b/packages/babel/types/index.d.ts @@ -129,5 +129,5 @@ export function createBabelOutputPluginFactory( * @param options - Plugin options. * @returns Plugin instance. */ -export function babel(options?: RollupBabelInputPluginOptions): Plugin; -export default babel; +declare function babel(options?: RollupBabelInputPluginOptions): Plugin; +export { babel, babel as default }; diff --git a/packages/beep/README.md b/packages/beep/README.md index 0430a519f..c79d30e43 100644 --- a/packages/beep/README.md +++ b/packages/beep/README.md @@ -28,9 +28,9 @@ npm install @rollup/plugin-beep --save-dev Create a `rollup.config.js` [configuration file](https://www.rollupjs.org/guide/en/#configuration-files) and import the plugin: ```js -const beep = require('@rollup/plugin-beep'); +import beep from '@rollup/plugin-beep'; -module.exports = { +export default { input: 'src/index.js', output: { dir: 'output', @@ -40,6 +40,13 @@ module.exports = { }; ``` +> [!NOTE] +> If your editor complains that _"beep is not a function"_, then use the named export instead: +> +> ```javascript +> import { alias } from '@rollup/plugin-alias'; +> ``` + Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api). If the build produces any errors, the plugin will write a "beep" character to stderr, which should be audible on most systems. ## Options diff --git a/packages/beep/lib/index.js b/packages/beep/lib/index.js index 3f3e50512..36030f047 100644 --- a/packages/beep/lib/index.js +++ b/packages/beep/lib/index.js @@ -15,3 +15,4 @@ const beep = (opts) => { }; module.exports = beep; +module.exports.beep = beep; diff --git a/packages/beep/types/index.d.ts b/packages/beep/types/index.d.ts index 9b6abcc0d..0babbd85e 100644 --- a/packages/beep/types/index.d.ts +++ b/packages/beep/types/index.d.ts @@ -3,4 +3,5 @@ import type { Plugin } from 'rollup'; /** * 🍣 A Rollup plugin that beeps when a build ends with errors. */ -export default function beep(): Plugin; +declare function beep(): Plugin; +export { beep, beep as default }; diff --git a/packages/buble/README.md b/packages/buble/README.md index f82cbe2f2..a26a9bd54 100644 --- a/packages/buble/README.md +++ b/packages/buble/README.md @@ -40,6 +40,13 @@ export default { }; ``` +> [!NOTE] +> If your editor complains that _"buble is not a function"_, then use the named export instead: +> +> ```js +> import { buble } from '@rollup/plugin-buble'; +> ``` + Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api). ## Options diff --git a/packages/buble/src/index.ts b/packages/buble/src/index.ts index 7e69f8eb2..c5d5a81ee 100644 --- a/packages/buble/src/index.ts +++ b/packages/buble/src/index.ts @@ -4,7 +4,7 @@ import { createFilter } from '@rollup/pluginutils'; import type { RollupBubleOptions } from '../types'; -export default function buble(options: RollupBubleOptions = {}): Plugin { +export function buble(options: RollupBubleOptions = {}): Plugin { const filter = createFilter(options.include, options.exclude); const transformOptions = { ...options, transforms: { ...options.transforms, modules: false } }; @@ -26,3 +26,4 @@ export default function buble(options: RollupBubleOptions = {}): Plugin { } }; } +export default buble; diff --git a/packages/buble/types/index.d.ts b/packages/buble/types/index.d.ts index 8368f6f20..9f0b2f619 100755 --- a/packages/buble/types/index.d.ts +++ b/packages/buble/types/index.d.ts @@ -17,4 +17,5 @@ export interface RollupBubleOptions extends TransformOptions { /** * Convert ES2015 with buble. */ -export default function buble(options?: RollupBubleOptions): Plugin; +declare function buble(options?: RollupBubleOptions): Plugin; +export { buble, buble as default }; diff --git a/packages/commonjs/README.md b/packages/commonjs/README.md index 7eda39f93..16f77316e 100644 --- a/packages/commonjs/README.md +++ b/packages/commonjs/README.md @@ -40,6 +40,13 @@ export default { }; ``` +> [!NOTE] +> If your editor complains that _"commonjs is not a function"_, then use the named export instead: +> +> ```js +> import { commonjs } from '@rollup/plugin-commonjs'; +> ``` + Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api). When used together with the node-resolve plugin diff --git a/packages/commonjs/src/index.js b/packages/commonjs/src/index.js index ed321dc1b..626befa35 100644 --- a/packages/commonjs/src/index.js +++ b/packages/commonjs/src/index.js @@ -35,7 +35,7 @@ import { getName, getStrictRequiresFilter, normalizePathSlashes } from './utils' const PLUGIN_NAME = 'commonjs'; -export default function commonjs(options = {}) { +export function commonjs(options = {}) { const { ignoreGlobal, ignoreDynamicRequires, @@ -324,3 +324,4 @@ export default function commonjs(options = {}) { } }; } +export default commonjs; diff --git a/packages/commonjs/types/index.d.ts b/packages/commonjs/types/index.d.ts index 37453bd92..eb7037285 100644 --- a/packages/commonjs/types/index.d.ts +++ b/packages/commonjs/types/index.d.ts @@ -230,4 +230,5 @@ interface RollupCommonJSOptions { /** * Convert CommonJS modules to ES6, so they can be included in a Rollup bundle */ -export default function commonjs(options?: RollupCommonJSOptions): Plugin; +declare function commonjs(options?: RollupCommonJSOptions): Plugin; +export { commonjs, commonjs as default }; diff --git a/packages/data-uri/README.md b/packages/data-uri/README.md index 242c93bd2..f1c7c62ef 100644 --- a/packages/data-uri/README.md +++ b/packages/data-uri/README.md @@ -30,7 +30,7 @@ Create a `rollup.config.js` [configuration file](https://www.rollupjs.org/guide/ ```js import dataUri from '@rollup/plugin-data-uri'; -module.exports = { +export default { input: 'src/index.js', output: { dir: 'output', @@ -40,6 +40,13 @@ module.exports = { }; ``` +> [!NOTE] +> If your editor complains that _"dataUri is not a function"_, then use the named export instead: +> +> ```js +> import { dataUri } from '@rollup/plugin-data-uri'; +> ``` + Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api). If the build produces any errors, the plugin will write a "data-uri" character to stderr, which should be audible on most systems. ## Options diff --git a/packages/data-uri/src/index.ts b/packages/data-uri/src/index.ts index d12b197ff..9489b1992 100644 --- a/packages/data-uri/src/index.ts +++ b/packages/data-uri/src/index.ts @@ -10,7 +10,7 @@ const mimeTypes = { json: 'application/json' }; -export default function dataUri(): Plugin { +export function dataUri(): Plugin { const resolved: { [key: string]: { mime: string | null; content: string | null } } = {}; return { @@ -84,3 +84,4 @@ export default function dataUri(): Plugin { } }; } +export default dataUri; diff --git a/packages/data-uri/types/index.d.ts b/packages/data-uri/types/index.d.ts index c00a67485..6c8f8a51c 100644 --- a/packages/data-uri/types/index.d.ts +++ b/packages/data-uri/types/index.d.ts @@ -3,4 +3,5 @@ import type { Plugin } from 'rollup'; /** * A Rollup plugin which imports modules from Data URIs. */ -export default function dataUri(): Plugin; +declare function dataUri(): Plugin; +export { dataUri, dataUri as default }; diff --git a/packages/dsv/README.md b/packages/dsv/README.md index db50c2c9e..3b42ae179 100644 --- a/packages/dsv/README.md +++ b/packages/dsv/README.md @@ -40,6 +40,13 @@ export default { }; ``` +> [!NOTE] +> If your editor complains that _"dsv is not a function"_, then use the named export instead: +> +> ```js +> import { dsv } from '@rollup/plugin-dsv'; +> ``` + Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api). ## Practical Example diff --git a/packages/dsv/src/index.js b/packages/dsv/src/index.js index ec94aa446..062b6a0d1 100755 --- a/packages/dsv/src/index.js +++ b/packages/dsv/src/index.js @@ -7,7 +7,7 @@ import stripBom from 'strip-bom'; const parsers = { '.csv': csvParse, '.tsv': tsvParse }; -export default function dsv(options = {}) { +export function dsv(options = {}) { const filter = createFilter(options.include, options.exclude); return { @@ -32,3 +32,4 @@ export default function dsv(options = {}) { } }; } +export default dsv; diff --git a/packages/dsv/types/index.d.ts b/packages/dsv/types/index.d.ts index e1031295a..31898a1e3 100644 --- a/packages/dsv/types/index.d.ts +++ b/packages/dsv/types/index.d.ts @@ -26,4 +26,5 @@ interface RollupDsvOptions { /** * Convert `.csv` and `.tsv `files into JavaScript modules with `d3-dsv`. */ -export default function dsv(options?: RollupDsvOptions): Plugin; +declare function dsv(options?: RollupDsvOptions): Plugin; +export { dsv, dsv as default }; diff --git a/packages/dynamic-import-vars/README.md b/packages/dynamic-import-vars/README.md index ae663cdf2..0abc0c618 100644 --- a/packages/dynamic-import-vars/README.md +++ b/packages/dynamic-import-vars/README.md @@ -45,6 +45,13 @@ export default { }; ``` +> [!NOTE] +> If your editor complains that _"dynamicImportVars is not a function"_, then use the named export instead: +> +> ```js +> import { dynamicImportVars } from '@rollup/plugin-dynamic-import-vars'; +> ``` + ### Options #### `include` diff --git a/packages/dynamic-import-vars/src/index.js b/packages/dynamic-import-vars/src/index.js index b44770c45..e210fd692 100644 --- a/packages/dynamic-import-vars/src/index.js +++ b/packages/dynamic-import-vars/src/index.js @@ -122,4 +122,4 @@ ${` default: return new Promise(function(resolve, reject) { } export default dynamicImportVariables; -export { dynamicImportToGlob, VariableDynamicImportError }; +export { dynamicImportVariables, dynamicImportToGlob, VariableDynamicImportError }; diff --git a/packages/dynamic-import-vars/types/index.d.ts b/packages/dynamic-import-vars/types/index.d.ts index 353e9f823..1720973e9 100644 --- a/packages/dynamic-import-vars/types/index.d.ts +++ b/packages/dynamic-import-vars/types/index.d.ts @@ -36,6 +36,5 @@ export function dynamicImportToGlob(node: BaseNode, sourceString: string): null /** * Support variables in dynamic imports in Rollup. */ -export default function dynamicImportVariables( - options?: RollupDynamicImportVariablesOptions -): Plugin; +declare function dynamicImportVariables(options?: RollupDynamicImportVariablesOptions): Plugin; +export { dynamicImportVariables, dynamicImportVariables as default }; diff --git a/packages/eslint/README.md b/packages/eslint/README.md index 8f72c0054..ffb131b25 100755 --- a/packages/eslint/README.md +++ b/packages/eslint/README.md @@ -40,6 +40,13 @@ export default { }; ``` +> [!NOTE] +> If your editor complains that _"eslint is not a function"_, then use the named export instead: +> +> ```js +> import { eslint } from '@rollup/plugin-eslint'; +> ``` + ## Options This plugin takes a configuration object intended for the [ESLint constructor](https://eslint.org/docs/developer-guide/nodejs-api#-new-eslintoptions) with the addition of a `throwOnWarning`, `throwOnError`, `formatter`, `include` and `exclude` prop. diff --git a/packages/eslint/src/index.ts b/packages/eslint/src/index.ts index c8b14ebe9..56825fc01 100755 --- a/packages/eslint/src/index.ts +++ b/packages/eslint/src/index.ts @@ -10,7 +10,7 @@ function normalizePath(id: string) { return relative(process.cwd(), id).split(sep).join('/'); } -export default function eslint(options = {} as RollupEslintOptions): Plugin { +export function eslint(options = {} as RollupEslintOptions): Plugin { if (typeof options === 'string') { const configFile = resolve(process.cwd(), options); // eslint-disable-next-line global-require, import/no-dynamic-require, no-param-reassign @@ -81,3 +81,4 @@ export default function eslint(options = {} as RollupEslintOptions): Plugin { } }; } +export default eslint; diff --git a/packages/eslint/types/index.d.ts b/packages/eslint/types/index.d.ts index 1db9bb48f..a12ef2330 100755 --- a/packages/eslint/types/index.d.ts +++ b/packages/eslint/types/index.d.ts @@ -43,4 +43,5 @@ export interface RollupEslintOptions extends ESLint.Options { /** * 🍣 A Rollup plugin for verifing entry points and all imported files with ESLint. */ -export default function eslint(options?: RollupEslintOptions | string): Plugin; +declare function eslint(options?: RollupEslintOptions | string): Plugin; +export { eslint, eslint as default }; diff --git a/packages/esm-shim/README.md b/packages/esm-shim/README.md index dd08a7bb6..0984aabfe 100644 --- a/packages/esm-shim/README.md +++ b/packages/esm-shim/README.md @@ -46,6 +46,13 @@ export default { }; ``` +> [!NOTE] +> If your editor complains that _"esmShim is not a function"_, then use the named export instead: +> +> ```typescript +> import { esmShim } from '@rollup/plugin-esm-shim'; +> ``` + Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api). ## Meta diff --git a/packages/esm-shim/src/module.ts b/packages/esm-shim/src/module.ts index f84ea2aa3..70447b16d 100644 --- a/packages/esm-shim/src/module.ts +++ b/packages/esm-shim/src/module.ts @@ -14,3 +14,4 @@ export function esmShim(): Plugin { } }; } +export default esmShim; diff --git a/packages/esm-shim/types/index.d.ts b/packages/esm-shim/types/index.d.ts index e7a2df455..16d6b86b0 100644 --- a/packages/esm-shim/types/index.d.ts +++ b/packages/esm-shim/types/index.d.ts @@ -5,10 +5,12 @@ interface Output { map?: SourceMapInput; } +export function provideCJSSyntax(code: string): Output | null; + /** * A Rollup plugin to replace cjs syntax for esm output bundles. * * @returns Plugin instance. */ -export default function commonjsShim(): Plugin; -export function provideCJSSyntax(code: string): Output | null; +declare function esShim(): Plugin; +export { esShim, esShim as default }; diff --git a/packages/graphql/README.md b/packages/graphql/README.md index 15e920849..ddadf36b7 100644 --- a/packages/graphql/README.md +++ b/packages/graphql/README.md @@ -40,6 +40,13 @@ export default { }; ``` +> [!NOTE] +> If your editor complains that _"graphql is not a function"_, then use the named export instead: +> +> ```js +> import { graphql } from '@rollup/plugin-graphql'; +> ``` + Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api). With an accompanying file `src/index.js`, you can import GraphQL files or named queries/mutations: diff --git a/packages/graphql/src/index.js b/packages/graphql/src/index.js index 1dd47ee01..8af5cefab 100644 --- a/packages/graphql/src/index.js +++ b/packages/graphql/src/index.js @@ -3,7 +3,7 @@ import loader from 'graphql-tag/loader.js'; import { toESModules } from './toESModules'; -export default function graphql({ include, exclude } = {}) { +export function graphql({ include, exclude } = {}) { // path filter const filter = createFilter(include, exclude); // only .graphql, .graphqls (schema), and .gql files @@ -34,3 +34,4 @@ export default function graphql({ include, exclude } = {}) { } }; } +export default graphql; diff --git a/packages/graphql/types/index.d.ts b/packages/graphql/types/index.d.ts index 1c01e665c..6650b3ad7 100755 --- a/packages/graphql/types/index.d.ts +++ b/packages/graphql/types/index.d.ts @@ -17,4 +17,5 @@ export interface RollupGraphqlOptions { /** * Convert .gql/.graphql files to ES6 modules */ -export default function graphql(options?: RollupGraphqlOptions): Plugin; +declare function graphql(options?: RollupGraphqlOptions): Plugin; +export { graphql, graphql as default }; diff --git a/packages/html/README.md b/packages/html/README.md index 4486b09fa..08284882d 100644 --- a/packages/html/README.md +++ b/packages/html/README.md @@ -30,9 +30,9 @@ npm install @rollup/plugin-html --save-dev Create a `rollup.config.js` [configuration file](https://www.rollupjs.org/guide/en/#configuration-files) and import the plugin: ```js -const html = require('@rollup/plugin-html'); +import html from '@rollup/plugin-html'; -module.exports = { +export default { input: 'src/index.js', output: { dir: 'output', @@ -42,6 +42,13 @@ module.exports = { }; ``` +> [!NOTE] +> If your editor complains that _"html is not a function"_, then use the named export instead: +> +> ```js +> import { html } from '@rollup/plugin-html'; +> ``` + Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api). Once run successfully, an HTML file should be written to the bundle output destination. diff --git a/packages/html/src/index.ts b/packages/html/src/index.ts index ffa046d07..5584509d2 100644 --- a/packages/html/src/index.ts +++ b/packages/html/src/index.ts @@ -92,7 +92,7 @@ const defaults: Required = { addScriptsToHead: false }; -export default function html(opts: RollupHtmlOptions = {}): Plugin { +export function html(opts: RollupHtmlOptions = {}): Plugin { const { addScriptsToHead, attributes, @@ -145,3 +145,4 @@ export default function html(opts: RollupHtmlOptions = {}): Plugin { } }; } +export default html; diff --git a/packages/html/types/index.d.ts b/packages/html/types/index.d.ts index 0bc0cbdf4..3a77dcf4e 100644 --- a/packages/html/types/index.d.ts +++ b/packages/html/types/index.d.ts @@ -27,4 +27,5 @@ export function makeHtmlAttributes(attributes: Record): string; * @param options - Plugin options. * @returns Plugin instance. */ -export default function html(options?: RollupHtmlOptions): Plugin; +declare function html(options?: RollupHtmlOptions): Plugin; +export { html, html as default }; diff --git a/packages/image/README.md b/packages/image/README.md index e7668f533..ac2a3747d 100755 --- a/packages/image/README.md +++ b/packages/image/README.md @@ -50,6 +50,13 @@ export default { }; ``` +> [!NOTE] +> If your editor complains that _"image is not a function"_, then use the named export instead: +> +> ```js +> import { image } from '@rollup/plugin-image'; +> ``` + Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api). Once the bundle is executed, the `console.log` will display the Base64 encoded representation of the image. diff --git a/packages/image/src/index.js b/packages/image/src/index.js index 1aa952f6f..c570e1f9d 100755 --- a/packages/image/src/index.js +++ b/packages/image/src/index.js @@ -33,7 +33,7 @@ const constTemplate = ({ dataUri }) => ` const getDataUri = ({ format, isSvg, mime, source }) => isSvg ? svgToMiniDataURI(source) : `data:${mime};${format},${source}`; -export default function image(opts = {}) { +export function image(opts = {}) { const options = Object.assign({}, defaults, opts); const filter = createFilter(options.include, options.exclude); @@ -62,3 +62,4 @@ export default function image(opts = {}) { } }; } +export default image; diff --git a/packages/image/types/index.d.ts b/packages/image/types/index.d.ts index fd5a9163c..70203bcb2 100644 --- a/packages/image/types/index.d.ts +++ b/packages/image/types/index.d.ts @@ -31,4 +31,5 @@ interface RollupImageOptions { dom?: boolean; } -export default function image(options?: RollupImageOptions): Plugin; +declare function image(options?: RollupImageOptions): Plugin; +export { image, image as default }; diff --git a/packages/inject/README.md b/packages/inject/README.md index 7473b4dd0..0fb942b90 100644 --- a/packages/inject/README.md +++ b/packages/inject/README.md @@ -44,6 +44,13 @@ export default { }; ``` +> [!NOTE] +> If your editor complains that _"inject is not a function"_, then use the named export instead: +> +> ```js +> import { inject } from '@rollup/plugin-inject'; +> ``` + Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api). This configuration above will scan all your files for global Promise usage and plugin will add import to desired module (`import { Promise } from 'es6-promise'` in this case). diff --git a/packages/inject/src/index.js b/packages/inject/src/index.js index 9030c8a1d..f269063d0 100644 --- a/packages/inject/src/index.js +++ b/packages/inject/src/index.js @@ -51,7 +51,7 @@ const flatten = (startNode) => { return { name, keypath: parts.join('.') }; }; -export default function inject(options) { +export function inject(options) { if (!options) throw new Error('Missing options'); const filter = createFilter(options.include, options.exclude); @@ -207,3 +207,4 @@ export default function inject(options) { } }; } +export default inject; diff --git a/packages/inject/types/index.d.ts b/packages/inject/types/index.d.ts index 646522ec2..8331c66e4 100644 --- a/packages/inject/types/index.d.ts +++ b/packages/inject/types/index.d.ts @@ -39,4 +39,5 @@ export interface RollupInjectOptions { /** * inject strings in files while bundling them. */ -export default function inject(options?: RollupInjectOptions): Plugin; +declare function inject(options?: RollupInjectOptions): Plugin; +export { inject, inject as default }; diff --git a/packages/json/README.md b/packages/json/README.md index 1b1c9cd0f..3987c7015 100644 --- a/packages/json/README.md +++ b/packages/json/README.md @@ -40,6 +40,13 @@ export default { }; ``` +> [!NOTE] +> If your editor complains that _"json is not a function"_, then use the named export instead: +> +> ```js +> import { json } from '@rollup/plugin-json'; +> ``` + Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api). With an accompanying file `src/index.js`, the local `package.json` file would now be importable as seen below: diff --git a/packages/json/src/index.js b/packages/json/src/index.js index dcb8f3333..0496c020a 100755 --- a/packages/json/src/index.js +++ b/packages/json/src/index.js @@ -1,6 +1,6 @@ import { createFilter, dataToEsm } from '@rollup/pluginutils'; -export default function json(options = {}) { +export function json(options = {}) { const filter = createFilter(options.include, options.exclude); const indent = 'indent' in options ? options.indent : '\t'; @@ -31,3 +31,4 @@ export default function json(options = {}) { } }; } +export default json; diff --git a/packages/json/types/index.d.ts b/packages/json/types/index.d.ts index 6ef037a23..5616ae8a3 100755 --- a/packages/json/types/index.d.ts +++ b/packages/json/types/index.d.ts @@ -38,4 +38,5 @@ export interface RollupJsonOptions { /** * Convert .json files to ES6 modules */ -export default function json(options?: RollupJsonOptions): Plugin; +declare function json(options?: RollupJsonOptions): Plugin; +export { json, json as default }; diff --git a/packages/legacy/README.md b/packages/legacy/README.md index 83dfa6fc1..64359e002 100644 --- a/packages/legacy/README.md +++ b/packages/legacy/README.md @@ -40,6 +40,13 @@ export default { }; ``` +> [!NOTE] +> If your editor complains that _"legacy is not a function"_, then use the named export instead: +> +> ```js +> import { legacy } from '@rollup/plugin-legacy'; +> ``` + Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api). ## Options diff --git a/packages/legacy/src/index.js b/packages/legacy/src/index.js index b325b7747..f893bf3cf 100644 --- a/packages/legacy/src/index.js +++ b/packages/legacy/src/index.js @@ -4,7 +4,7 @@ import { normalizePath } from '@rollup/pluginutils'; const validName = /^[a-zA-Z_$][a-zA-Z$_0-9]*$/; -export default function legacy(options) { +export function legacy(options) { const exports = {}; Object.keys(options).forEach((file) => { exports[normalizePath(resolve(file))] = options[file]; @@ -50,3 +50,4 @@ export default function legacy(options) { } }; } +export default legacy; diff --git a/packages/legacy/types/index.d.ts b/packages/legacy/types/index.d.ts index f1b4ccdb3..33d33d07c 100644 --- a/packages/legacy/types/index.d.ts +++ b/packages/legacy/types/index.d.ts @@ -7,4 +7,5 @@ interface RollupLegacyOptions { /** * A Rollup plugin which adds `export` declarations to legacy non-module scripts. */ -export default function legacy(options: RollupLegacyOptions): Plugin; +declare function legacy(options: RollupLegacyOptions): Plugin; +export { legacy, legacy as default }; diff --git a/packages/multi-entry/README.md b/packages/multi-entry/README.md index c6bb745b9..a09c8528c 100755 --- a/packages/multi-entry/README.md +++ b/packages/multi-entry/README.md @@ -49,17 +49,24 @@ export const color = 'purple'; Then, create a `rollup.config.js` [configuration file](https://www.rollupjs.org/guide/en/#configuration-files) and import the plugin: ```js -import multi from '@rollup/plugin-multi-entry'; +import multiEntry from '@rollup/plugin-multi-entry'; export default { input: ['batman.js', 'robin.js', 'joker.js'], output: { dir: 'output' }, - plugins: [multi()] + plugins: [multiEntry()] }; ``` +> [!NOTE] +> If your editor complains that _"multiEntry is not a function"_, then use the named export instead: +> +> ```js +> import { multiEntry } from '@rollup/plugin-multi-entry'; +> ``` + Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api). Using all three files above as entry points will yield a bundle with exports for `belt`, `tights`, and `color`. diff --git a/packages/multi-entry/src/index.js b/packages/multi-entry/src/index.js index dec066ac4..ad91309fe 100755 --- a/packages/multi-entry/src/index.js +++ b/packages/multi-entry/src/index.js @@ -7,7 +7,7 @@ const DEFAULT_OUTPUT = 'multi-entry.js'; const AS_IMPORT = 'import'; const AS_EXPORT = 'export * from'; -export default function multiEntry(conf = {}) { +export function multiEntry(conf = {}) { const config = { include: [], exclude: [], @@ -75,3 +75,4 @@ export default function multiEntry(conf = {}) { } }; } +export default multiEntry; diff --git a/packages/multi-entry/types/index.d.ts b/packages/multi-entry/types/index.d.ts index 608ca9dc6..d393b4c87 100644 --- a/packages/multi-entry/types/index.d.ts +++ b/packages/multi-entry/types/index.d.ts @@ -41,4 +41,5 @@ interface RollupMultiEntryOptions { * _Note: `default` exports cannot be combined and exported by this plugin. Only named exports * will be exported._ */ -export default function multiEntry(options?: RollupMultiEntryOptions): Plugin; +declare function multiEntry(options?: RollupMultiEntryOptions): Plugin; +export { multiEntry, multiEntry as default }; diff --git a/packages/replace/README.md b/packages/replace/README.md index 412db4d5d..08ca85707 100644 --- a/packages/replace/README.md +++ b/packages/replace/README.md @@ -46,6 +46,13 @@ export default { }; ``` +> [!NOTE] +> If your editor complains that _"replace is not a function"_, then use the named export instead: +> +> ```js +> import { replace } from '@rollup/plugin-replace'; +> ``` + Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api). The configuration above will replace every instance of `process.env.NODE_ENV` with `"production"` and `__buildDate__` with the result of the given function in any file included in the build. diff --git a/packages/replace/src/index.js b/packages/replace/src/index.js index 5d0427769..c5c966d28 100755 --- a/packages/replace/src/index.js +++ b/packages/replace/src/index.js @@ -52,7 +52,7 @@ function expandTypeofReplacements(replacements) { }); } -export default function replace(options = {}) { +export function replace(options = {}) { const filter = createFilter(options.include, options.exclude); const { delimiters = ['\\b', '\\b(?!\\.)'], preventAssignment, objectGuards } = options; const replacements = getReplacements(options); @@ -125,3 +125,4 @@ export default function replace(options = {}) { return options.sourceMap !== false && options.sourcemap !== false; } } +export default replace; diff --git a/packages/replace/types/index.d.ts b/packages/replace/types/index.d.ts index 68f2e9288..ac6e77ce7 100755 --- a/packages/replace/types/index.d.ts +++ b/packages/replace/types/index.d.ts @@ -54,4 +54,5 @@ export interface RollupReplaceOptions { /** * Replace strings in files while bundling them. */ -export default function replace(options?: RollupReplaceOptions): Plugin; +declare function replace(options?: RollupReplaceOptions): Plugin; +export { replace, replace as default }; diff --git a/packages/run/README.md b/packages/run/README.md index 4eb5bb8d1..974cf8f6a 100644 --- a/packages/run/README.md +++ b/packages/run/README.md @@ -42,6 +42,13 @@ export default { }; ``` +> [!NOTE] +> If your editor complains that _"run is not a function"_, then use the named export instead: +> +> ```js +> import { run } from '@rollup/plugin-run'; +> ``` + Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api). If the build produces any errors, the plugin will write a 'alias' character to stderr, which should be audible on most systems. The plugin `forks` a child process with the generated file, every time the bundle is rebuilt (after first closing the previous process, if it's not the first run). diff --git a/packages/run/src/index.ts b/packages/run/src/index.ts index 63c7dbe7a..bd425c52a 100644 --- a/packages/run/src/index.ts +++ b/packages/run/src/index.ts @@ -6,7 +6,7 @@ import type { Plugin, RenderedChunk } from 'rollup'; import type { RollupRunOptions } from '../types'; -export default function run(opts: RollupRunOptions = {}): Plugin { +export function run(opts: RollupRunOptions = {}): Plugin { let input: string; let proc: ChildProcess; @@ -82,3 +82,4 @@ export default function run(opts: RollupRunOptions = {}): Plugin { } }; } +export default run; diff --git a/packages/run/types/index.d.ts b/packages/run/types/index.d.ts index fe9fbe599..d19a3f8bb 100644 --- a/packages/run/types/index.d.ts +++ b/packages/run/types/index.d.ts @@ -13,4 +13,5 @@ export interface RollupRunOptions extends ForkOptions { * Run your bundles in Node once they're built * @param options These are passed through to `child_process.fork(..)` */ -export default function run(options?: RollupRunOptions): Plugin; +declare function run(options?: RollupRunOptions): Plugin; +export { run, run as default }; diff --git a/packages/strip/README.md b/packages/strip/README.md index d15a84b69..b52205153 100755 --- a/packages/strip/README.md +++ b/packages/strip/README.md @@ -44,6 +44,13 @@ export default { }; ``` +> [!NOTE] +> If your editor complains that _"strip is not a function"_, then use the named export instead: +> +> ```js +> import { strip } from '@rollup/plugin-strip'; +> ``` + Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api). ## Options diff --git a/packages/strip/src/index.js b/packages/strip/src/index.js index 0759a7491..f5153d8a5 100755 --- a/packages/strip/src/index.js +++ b/packages/strip/src/index.js @@ -31,7 +31,7 @@ function flatten(node) { return parts.join('.'); } -export default function strip(options = {}) { +export function strip(options = {}) { const include = options.include || '**/*.js'; const { exclude } = options; const filter = createFilter(include, exclude); @@ -151,3 +151,4 @@ export default function strip(options = {}) { } }; } +export default strip; diff --git a/packages/strip/types/index.d.ts b/packages/strip/types/index.d.ts index 7aa3ae554..6474b0755 100644 --- a/packages/strip/types/index.d.ts +++ b/packages/strip/types/index.d.ts @@ -47,4 +47,5 @@ interface RollupStripOptions { * A Rollup plugin to remove debugger statements and functions like `assert.equal` and * `console.log` from your code. */ -export default function strip(options?: RollupStripOptions): Plugin; +declare function strip(options?: RollupStripOptions): Plugin; +export { strip, strip as default }; diff --git a/packages/sucrase/README.md b/packages/sucrase/README.md index 680e5a7b2..8dc78cf9e 100644 --- a/packages/sucrase/README.md +++ b/packages/sucrase/README.md @@ -49,6 +49,13 @@ export default { }; ``` +> [!NOTE] +> If your editor complains that _"sucrase is not a function"_, then use the named export instead: +> +> ```js +> import { sucrase } from '@rollup/plugin-sucrase'; +> ``` + Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api). ## Options diff --git a/packages/sucrase/src/index.js b/packages/sucrase/src/index.js index dfeb9a765..79b6c4e93 100644 --- a/packages/sucrase/src/index.js +++ b/packages/sucrase/src/index.js @@ -4,7 +4,7 @@ import path from 'path'; import { transform } from 'sucrase'; import { createFilter } from '@rollup/pluginutils'; -export default function sucrase(opts = {}) { +export function sucrase(opts = {}) { const filter = createFilter(opts.include, opts.exclude); return { @@ -60,3 +60,4 @@ export default function sucrase(opts = {}) { } }; } +export default sucrase; diff --git a/packages/sucrase/types/index.d.ts b/packages/sucrase/types/index.d.ts index 3b2147b1a..b91b57b3f 100644 --- a/packages/sucrase/types/index.d.ts +++ b/packages/sucrase/types/index.d.ts @@ -31,4 +31,5 @@ interface RollupSucraseOptions * A Rollup plugin which compiles TypeScript, Flow, JSX, etc with * [Sucrase](https://github.com/alangpierce/sucrase). */ -export default function sucrase(options?: RollupSucraseOptions): Plugin; +declare function sucrase(options?: RollupSucraseOptions): Plugin; +export { sucrase, sucrase as default }; diff --git a/packages/swc/README.md b/packages/swc/README.md index f30bd7900..5e4d40263 100644 --- a/packages/swc/README.md +++ b/packages/swc/README.md @@ -43,6 +43,13 @@ export default { }; ``` +> [!NOTE] +> If your editor complains that _"swc is not a function"_, then use the named export instead: +> +> ```typescript +> import { swc } from '@rollup/plugin-swc'; +> ``` + Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api). ## Options diff --git a/packages/swc/types/index.d.ts b/packages/swc/types/index.d.ts index db426aeb8..7e4173ead 100644 --- a/packages/swc/types/index.d.ts +++ b/packages/swc/types/index.d.ts @@ -8,4 +8,5 @@ import type { Options } from '../src'; * @param options - Plugin options. * @returns Plugin instance. */ -export default function swc(options?: Options): Plugin; +declare function swc(options?: Options): Plugin; +export { swc, swc as default }; diff --git a/packages/terser/README.md b/packages/terser/README.md index bcc387ed8..02e92547b 100644 --- a/packages/terser/README.md +++ b/packages/terser/README.md @@ -40,6 +40,13 @@ export default { }; ``` +> [!NOTE] +> If your editor complains that _"terser is not a function"_, then use the named export instead: +> +> ```typescript +> import { terser } from '@rollup/plugin-terser'; +> ``` + Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api). ## Options diff --git a/packages/terser/src/index.ts b/packages/terser/src/index.ts index 76a880f5a..811bde6f6 100644 --- a/packages/terser/src/index.ts +++ b/packages/terser/src/index.ts @@ -5,4 +5,4 @@ runWorker(); export * from './type'; -export default terser; +export { terser, terser as default }; diff --git a/packages/terser/types/index.d.ts b/packages/terser/types/index.d.ts index 0147eafa0..13b2d0f1c 100644 --- a/packages/terser/types/index.d.ts +++ b/packages/terser/types/index.d.ts @@ -12,4 +12,5 @@ export interface Options extends MinifyOptions { * @param options - Plugin options. * @returns Plugin instance. */ -export default function terser(options?: Options): Plugin; +declare function terser(options?: Options): Plugin; +export { terser, terser as default }; diff --git a/packages/typescript/README.md b/packages/typescript/README.md index 340f5cd3b..fa90241e9 100644 --- a/packages/typescript/README.md +++ b/packages/typescript/README.md @@ -47,6 +47,13 @@ export default { }; ``` +> [!NOTE] +> If your editor complains that _"typescript is not a function"_, then use the named export instead: +> +> ```js +> import { typescript } from '@rollup/plugin-typescript'; +> ``` + Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api). ## Options diff --git a/packages/typescript/src/index.ts b/packages/typescript/src/index.ts index 339a8ba40..b56ae335e 100644 --- a/packages/typescript/src/index.ts +++ b/packages/typescript/src/index.ts @@ -23,7 +23,7 @@ import { preflight } from './preflight'; import createWatchProgram, { WatchProgramHelper } from './watchProgram'; import TSCache from './tscache'; -export default function typescript(options: RollupTypescriptOptions = {}): Plugin { +export function typescript(options: RollupTypescriptOptions = {}): Plugin { const { cacheDir, compilerOptions, @@ -207,3 +207,4 @@ export default function typescript(options: RollupTypescriptOptions = {}): Plugi } }; } +export default typescript; diff --git a/packages/typescript/types/index.d.ts b/packages/typescript/types/index.d.ts index 4db1c5d06..765393d77 100644 --- a/packages/typescript/types/index.d.ts +++ b/packages/typescript/types/index.d.ts @@ -16,7 +16,7 @@ type ElementType | undefined> = T extends (infer U)[] ? U : export type TransformerStage = keyof CustomTransformers; type StagedTransformerFactory = ElementType; -type TransformerFactory = +export type TransformerFactory = | StagedTransformerFactory | ProgramTransformerFactory | TypeCheckerTransformerFactory; @@ -112,4 +112,5 @@ export type RollupTypescriptOptions = RollupTypescriptPluginOptions & PartialCom /** * Seamless integration between Rollup and Typescript. */ -export default function typescript(options?: RollupTypescriptOptions): Plugin; +declare function typescript(options?: RollupTypescriptOptions): Plugin; +export { typescript, typescript as default }; diff --git a/packages/url/README.md b/packages/url/README.md index c2bd5205f..23790e6c5 100644 --- a/packages/url/README.md +++ b/packages/url/README.md @@ -40,6 +40,12 @@ export default { }; ``` +> If your editor complains that _"url is not a function"_, then use the named export instead: +> +> ```js +> import { url } from '@rollup/plugin-url'; +> ``` + Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api). With an accompanying file `src/index.js`, the local `image.svg` file would now be importable as seen below: diff --git a/packages/url/src/index.js b/packages/url/src/index.js index 69c9fab84..b748b1d1e 100644 --- a/packages/url/src/index.js +++ b/packages/url/src/index.js @@ -12,7 +12,7 @@ const fsReadFilePromise = util.promisify(fs.readFile); const { posix, sep } = path; const defaultInclude = ['**/*.svg', '**/*.png', '**/*.jp(e)?g', '**/*.gif', '**/*.webp']; -export default function url(options = {}) { +export function url(options = {}) { const { limit = 14 * 1024, include = defaultInclude, @@ -87,6 +87,7 @@ export default function url(options = {}) { } }; } +export default url; function copy(src, dest) { return new Promise((resolve, reject) => { diff --git a/packages/url/types/index.d.ts b/packages/url/types/index.d.ts index d852ba6e9..f64df9801 100644 --- a/packages/url/types/index.d.ts +++ b/packages/url/types/index.d.ts @@ -63,4 +63,5 @@ interface RollupUrlOptions { /** * A Rollup plugin which imports files as data-URIs or ES Modules. */ -export default function url(options?: RollupUrlOptions): Plugin; +declare function url(options?: RollupUrlOptions): Plugin; +export { url, url as default }; diff --git a/packages/virtual/README.md b/packages/virtual/README.md index 2318a4ff4..7e0d53821 100755 --- a/packages/virtual/README.md +++ b/packages/virtual/README.md @@ -54,6 +54,12 @@ export default { }; ``` +> If your editor complains that _"virtual is not a function"_, then use the named export instead: +> +> ```js +> import { virtual } from '@rollup/plugin-virtual'; +> ``` + Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api). ## Options diff --git a/packages/virtual/src/index.ts b/packages/virtual/src/index.ts index 29049a9c0..7af2591f1 100644 --- a/packages/virtual/src/index.ts +++ b/packages/virtual/src/index.ts @@ -6,7 +6,7 @@ import type { RollupVirtualOptions } from '../types'; const PREFIX = `\0virtual:`; -export default function virtual(modules: RollupVirtualOptions): Plugin { +export function virtual(modules: RollupVirtualOptions): Plugin { const resolvedIds = new Map(); Object.keys(modules).forEach((id) => { @@ -41,3 +41,4 @@ export default function virtual(modules: RollupVirtualOptions): Plugin { } }; } +export default virtual; diff --git a/packages/virtual/types/index.d.ts b/packages/virtual/types/index.d.ts index 34fd38186..2dc3c65a4 100644 --- a/packages/virtual/types/index.d.ts +++ b/packages/virtual/types/index.d.ts @@ -7,4 +7,5 @@ export interface RollupVirtualOptions { /** * A Rollup plugin which loads virtual modules from memory. */ -export default function virtual(modules: RollupVirtualOptions): Plugin; +declare function virtual(modules: RollupVirtualOptions): Plugin; +export { virtual, virtual as default }; diff --git a/packages/yaml/README.md b/packages/yaml/README.md index d02d17b67..2177a8328 100644 --- a/packages/yaml/README.md +++ b/packages/yaml/README.md @@ -40,6 +40,13 @@ export default { }; ``` +> [!NOTE] +> If your editor complains that _"yaml is not a function"_, then use the named export instead: +> +> ```js +> import { yaml } from '@rollup/plugin-yaml'; +> ``` + Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api). With an accompanying file `src/index.js`, the local `heroes.yaml` file would now be importable as seen below: diff --git a/packages/yaml/src/index.js b/packages/yaml/src/index.js index bec744f1a..b45be83b1 100755 --- a/packages/yaml/src/index.js +++ b/packages/yaml/src/index.js @@ -8,7 +8,7 @@ const defaults = { extensions: ['.yaml', '.yml'] }; -export default function yaml(opts = {}) { +export function yaml(opts = {}) { const options = Object.assign({}, defaults, opts); const { documentMode, extensions } = options; const filter = createFilter(options.include, options.exclude); @@ -54,3 +54,4 @@ export default function yaml(opts = {}) { } }; } +export default yaml; diff --git a/packages/yaml/types/index.d.ts b/packages/yaml/types/index.d.ts index d87b8ac4e..bd8cd063f 100644 --- a/packages/yaml/types/index.d.ts +++ b/packages/yaml/types/index.d.ts @@ -49,4 +49,5 @@ interface RollupYamlOptions { /** * A Rollup plugin which Converts YAML files to ES6 modules. */ -export default function yaml(options?: RollupYamlOptions): Plugin; +declare function yaml(options?: RollupYamlOptions): Plugin; +export { yaml, yaml as default };