@rollup/plugin-babel
Advanced tools
Comparing version 5.2.3 to 5.3.0
# @rollup/plugin-babel ChangeLog | ||
## v5.3.0 | ||
_2021-02-14_ | ||
### Features | ||
- feat: add custom filter option (#767) | ||
- feat: pass rollup context as this context into override config function (#784) | ||
### Updates | ||
- docs: typo in README.md (#800) | ||
- chore: commit updated readme format (bfda6d8) | ||
## v5.2.3 | ||
@@ -4,0 +18,0 @@ |
@@ -214,3 +214,3 @@ import * as babel from '@babel/core'; | ||
let transformOptions = !overrides.config ? config.options : await overrides.config.call(this, config, { | ||
let transformOptions = !overrides.config ? config.options : await overrides.config.call(ctx, config, { | ||
code: inputCode, | ||
@@ -367,2 +367,3 @@ customOptions | ||
let extensions; | ||
let customFilter; | ||
@@ -376,10 +377,16 @@ var _unpackInputPluginOpt = unpackInputPluginOptions(pluginOptionsWithOverrides, this.meta.rollupVersion); | ||
include, | ||
filter: customFilter, | ||
skipPreflightCheck | ||
} = _unpackInputPluginOpt); | ||
babelOptions = _objectWithoutProperties(_unpackInputPluginOpt, ["exclude", "extensions", "babelHelpers", "include", "skipPreflightCheck"]); | ||
babelOptions = _objectWithoutProperties(_unpackInputPluginOpt, ["exclude", "extensions", "babelHelpers", "include", "filter", "skipPreflightCheck"]); | ||
const extensionRegExp = new RegExp(`(${extensions.map(escapeRegExpCharacters).join('|')})$`); | ||
const includeExcludeFilter = createFilter(include, exclude); | ||
filter = id => extensionRegExp.test(stripQuery(id).bareId) && includeExcludeFilter(id); | ||
if (customFilter && (include || exclude)) { | ||
throw new Error('Could not handle include or exclude with custom filter together'); | ||
} | ||
const userDefinedFilter = typeof customFilter === 'function' ? customFilter : createFilter(include, exclude); | ||
filter = id => extensionRegExp.test(stripQuery(id).bareId) && userDefinedFilter(id); | ||
return null; | ||
@@ -386,0 +393,0 @@ }, |
@@ -239,3 +239,3 @@ 'use strict'; | ||
let transformOptions = !overrides.config ? config.options : await overrides.config.call(this, config, { | ||
let transformOptions = !overrides.config ? config.options : await overrides.config.call(ctx, config, { | ||
code: inputCode, | ||
@@ -392,2 +392,3 @@ customOptions | ||
let extensions; | ||
let customFilter; | ||
@@ -401,10 +402,16 @@ var _unpackInputPluginOpt = unpackInputPluginOptions(pluginOptionsWithOverrides, this.meta.rollupVersion); | ||
include, | ||
filter: customFilter, | ||
skipPreflightCheck | ||
} = _unpackInputPluginOpt); | ||
babelOptions = _objectWithoutProperties(_unpackInputPluginOpt, ["exclude", "extensions", "babelHelpers", "include", "skipPreflightCheck"]); | ||
babelOptions = _objectWithoutProperties(_unpackInputPluginOpt, ["exclude", "extensions", "babelHelpers", "include", "filter", "skipPreflightCheck"]); | ||
const extensionRegExp = new RegExp(`(${extensions.map(escapeRegExpCharacters).join('|')})$`); | ||
const includeExcludeFilter = pluginutils.createFilter(include, exclude); | ||
filter = id => extensionRegExp.test(stripQuery(id).bareId) && includeExcludeFilter(id); | ||
if (customFilter && (include || exclude)) { | ||
throw new Error('Could not handle include or exclude with custom filter together'); | ||
} | ||
const userDefinedFilter = typeof customFilter === 'function' ? customFilter : pluginutils.createFilter(include, exclude); | ||
filter = id => extensionRegExp.test(stripQuery(id).bareId) && userDefinedFilter(id); | ||
return null; | ||
@@ -411,0 +418,0 @@ }, |
{ | ||
"name": "@rollup/plugin-babel", | ||
"version": "5.2.3", | ||
"version": "5.3.0", | ||
"publishConfig": { | ||
@@ -5,0 +5,0 @@ "access": "public" |
@@ -87,3 +87,3 @@ [npm]: https://img.shields.io/npm/v/@rollup/plugin-babel | ||
A [minimatch pattern](https://github.com/isaacs/minimatch), or array of patterns, which specifies the files in the build the plugin should _ignore_. When relaying on Babel configuration files you can only exclude additional files with this option, you cannot override what you have configured for Babel itself. | ||
A [minimatch pattern](https://github.com/isaacs/minimatch), or array of patterns, which specifies the files in the build the plugin should _ignore_. When relying on Babel configuration files you can only exclude additional files with this option, you cannot override what you have configured for Babel itself. | ||
@@ -96,2 +96,17 @@ ### `include` | ||
### `filter` | ||
Type: (id: string) => boolean<br> | ||
Custom [filter function](https://github.com/rollup/plugins/tree/master/packages/pluginutils#createfilter) can be used to determine whether or not certain modules should be operated upon. | ||
Usage: | ||
```js | ||
import { createFilter } from '@rollup/pluginutils'; | ||
const include = 'include/**.js'; | ||
const exclude = 'exclude/**.js'; | ||
const filter = createFilter(include, exclude, {}); | ||
``` | ||
### `extensions` | ||
@@ -98,0 +113,0 @@ |
@@ -1,3 +0,3 @@ | ||
import { Plugin } from 'rollup'; | ||
import { FilterPattern } from '@rollup/pluginutils'; | ||
import { Plugin, PluginContext, TransformPluginContext } from 'rollup'; | ||
import { FilterPattern, CreateFilter } from '@rollup/pluginutils'; | ||
import * as babelCore from '@babel/core'; | ||
@@ -18,2 +18,12 @@ | ||
/** | ||
* Custom filter function can be used to determine whether or not certain modules should be operated upon. | ||
* Example: | ||
* import { createFilter } from '@rollup/pluginutils'; | ||
* const include = 'include/**.js'; | ||
* const exclude = 'exclude/**.js'; | ||
* const filter = createFilter(include, exclude, {}); | ||
* @default undefined; | ||
*/ | ||
filter?: ReturnType<CreateFilter>; | ||
/** | ||
* An array of file extensions that Babel should transpile. If you want to transpile TypeScript files with this plugin it's essential to include .ts and .tsx in this option. | ||
@@ -56,24 +66,41 @@ * @default ['.js', '.jsx', '.es6', '.es', '.mjs'] | ||
}; | ||
export type RollupBabelCustomPluginConfig = ( | ||
export interface RollupBabelCustomPluginConfigOptions { | ||
code: string; | ||
customOptions: Record<string, any>; | ||
} | ||
export interface RollupBabelCustomPluginResultOptions { | ||
code: string; | ||
customOptions: Record<string, any>; | ||
config: babelCore.PartialConfig; | ||
transformOptions: babelCore.TransformOptions; | ||
} | ||
export type RollupBabelCustomInputPluginConfig = ( | ||
this: TransformPluginContext, | ||
cfg: babelCore.PartialConfig, | ||
options: { code: string; customOptions: Record<string, any> } | ||
options: RollupBabelCustomPluginConfigOptions | ||
) => babelCore.TransformOptions; | ||
export type RollupBabelCustomPluginResult = ( | ||
export type RollupBabelCustomInputPluginResult = ( | ||
this: TransformPluginContext, | ||
result: babelCore.BabelFileResult, | ||
options: { | ||
code: string; | ||
customOptions: Record<string, any>; | ||
config: babelCore.PartialConfig; | ||
transformOptions: babelCore.TransformOptions; | ||
} | ||
options: RollupBabelCustomPluginResultOptions | ||
) => babelCore.BabelFileResult; | ||
export type RollupBabelCustomOutputPluginConfig = ( | ||
this: PluginContext, | ||
cfg: babelCore.PartialConfig, | ||
options: RollupBabelCustomPluginConfigOptions | ||
) => babelCore.TransformOptions; | ||
export type RollupBabelCustomOutputPluginResult = ( | ||
this: PluginContext, | ||
result: babelCore.BabelFileResult, | ||
options: RollupBabelCustomPluginResultOptions | ||
) => babelCore.BabelFileResult; | ||
export interface RollupBabelCustomInputPlugin { | ||
options?: RollupBabelCustomInputPluginOptions; | ||
config?: RollupBabelCustomPluginConfig; | ||
result?: RollupBabelCustomPluginResult; | ||
config?: RollupBabelCustomInputPluginConfig; | ||
result?: RollupBabelCustomInputPluginResult; | ||
} | ||
export interface RollupBabelCustomOutputPlugin { | ||
options?: RollupBabelCustomOutputPluginOptions; | ||
config?: RollupBabelCustomPluginConfig; | ||
result?: RollupBabelCustomPluginResult; | ||
config?: RollupBabelCustomOutputPluginConfig; | ||
result?: RollupBabelCustomOutputPluginResult; | ||
} | ||
@@ -80,0 +107,0 @@ export type RollupBabelCustomInputPluginBuilder = ( |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64757
963
381