@rollup/plugin-babel 5.2.2 → 5.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/README.md +35 -3
- package/dist/index.es.js +21 -15
- package/dist/index.js +23 -17
- package/package.json +18 -18
- package/types/index.d.ts +42 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# @rollup/plugin-babel ChangeLog
|
|
2
2
|
|
|
3
|
+
## v5.3.1
|
|
4
|
+
|
|
5
|
+
_2022-02-22_
|
|
6
|
+
|
|
7
|
+
### Bugfixes
|
|
8
|
+
|
|
9
|
+
- fix: consider path delimeter on windows (#1090)
|
|
10
|
+
|
|
11
|
+
## v5.3.0
|
|
12
|
+
|
|
13
|
+
_2021-02-14_
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
- feat: add custom filter option (#767)
|
|
18
|
+
- feat: pass rollup context as this context into override config function (#784)
|
|
19
|
+
|
|
20
|
+
### Updates
|
|
21
|
+
|
|
22
|
+
- docs: typo in README.md (#800)
|
|
23
|
+
- chore: commit updated readme format (bfda6d8)
|
|
24
|
+
|
|
25
|
+
## v5.2.3
|
|
26
|
+
|
|
27
|
+
_2021-01-29_
|
|
28
|
+
|
|
29
|
+
### Updates
|
|
30
|
+
|
|
31
|
+
- docs: add usage with commonjs. fixes #622 (6b4b7b6)
|
|
32
|
+
- docs: update export in README (#690)
|
|
33
|
+
|
|
3
34
|
## v5.2.2
|
|
4
35
|
|
|
5
36
|
_2020-11-30_
|
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@ npm install @rollup/plugin-babel --save-dev
|
|
|
39
39
|
Create a `rollup.config.js` [configuration file](https://www.rollupjs.org/guide/en/#configuration-files) and import the plugin:
|
|
40
40
|
|
|
41
41
|
```js
|
|
42
|
-
import babel from '@rollup/plugin-babel';
|
|
42
|
+
import { babel } from '@rollup/plugin-babel';
|
|
43
43
|
|
|
44
44
|
const config = {
|
|
45
45
|
input: 'src/index.js',
|
|
@@ -55,6 +55,23 @@ export default config;
|
|
|
55
55
|
|
|
56
56
|
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).
|
|
57
57
|
|
|
58
|
+
### Using With `@rollup/plugin-commonjs`
|
|
59
|
+
|
|
60
|
+
When using `@rollup/plugin-babel` with `@rollup/plugin-commonjs` in the same Rollup configuration, it's important to note that `@rollup/plugin-commonjs` _must_ be placed before this plugin in the `plugins` array for the two to work together properly. e.g.
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
import { babel } from '@rollup/plugin-babel';
|
|
64
|
+
import commonjs from '@rollup/plugin-commonjs';
|
|
65
|
+
|
|
66
|
+
const config = {
|
|
67
|
+
...
|
|
68
|
+
plugins: [
|
|
69
|
+
commonjs(),
|
|
70
|
+
babel({ babelHelpers: 'bundled' })
|
|
71
|
+
],
|
|
72
|
+
};
|
|
73
|
+
```
|
|
74
|
+
|
|
58
75
|
## Options
|
|
59
76
|
|
|
60
77
|
This plugin respects Babel [configuration files](https://babeljs.io/docs/en/configuration) by default and they are generally the best place to put your configuration.
|
|
@@ -67,7 +84,7 @@ All options are as per the [Babel documentation](https://babeljs.io/docs/en/opti
|
|
|
67
84
|
|
|
68
85
|
Type: `String | RegExp | Array[...String|RegExp]`<br>
|
|
69
86
|
|
|
70
|
-
A [minimatch pattern](https://github.com/isaacs/minimatch), or array of patterns, which specifies the files in the build the plugin should _ignore_. When
|
|
87
|
+
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.
|
|
71
88
|
|
|
72
89
|
### `include`
|
|
73
90
|
|
|
@@ -75,6 +92,21 @@ Type: `String | RegExp | Array[...String|RegExp]`<br>
|
|
|
75
92
|
|
|
76
93
|
A [minimatch pattern](https://github.com/isaacs/minimatch), or array of patterns, which specifies the files in the build the plugin should operate on. When relying on Babel configuration files you cannot include files already excluded there.
|
|
77
94
|
|
|
95
|
+
### `filter`
|
|
96
|
+
|
|
97
|
+
Type: (id: string) => boolean<br>
|
|
98
|
+
|
|
99
|
+
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.
|
|
100
|
+
|
|
101
|
+
Usage:
|
|
102
|
+
|
|
103
|
+
```js
|
|
104
|
+
import { createFilter } from '@rollup/pluginutils';
|
|
105
|
+
const include = 'include/**.js';
|
|
106
|
+
const exclude = 'exclude/**.js';
|
|
107
|
+
const filter = createFilter(include, exclude, {});
|
|
108
|
+
```
|
|
109
|
+
|
|
78
110
|
### `extensions`
|
|
79
111
|
|
|
80
112
|
Type: `Array[...String]`<br>
|
|
@@ -295,7 +327,7 @@ It's main purpose is to allow other tools for configuration of transpilation wit
|
|
|
295
327
|
```js
|
|
296
328
|
import { createBabelInputPluginFactory } from '@rollup/plugin-babel';
|
|
297
329
|
|
|
298
|
-
export default createBabelInputPluginFactory(babelCore => {
|
|
330
|
+
export default createBabelInputPluginFactory((babelCore) => {
|
|
299
331
|
function myPlugin() {
|
|
300
332
|
return {
|
|
301
333
|
visitor: {}
|
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as babel from '@babel/core';
|
|
2
|
-
import { transformAsync, loadPartialConfigAsync, loadPartialConfig, buildExternalHelpers, DEFAULT_EXTENSIONS } from '@babel/core';
|
|
3
2
|
import { createFilter } from '@rollup/pluginutils';
|
|
4
3
|
import { addNamed } from '@babel/helper-module-imports';
|
|
5
4
|
|
|
@@ -160,12 +159,13 @@ function helpersTestTransform() {
|
|
|
160
159
|
};
|
|
161
160
|
}
|
|
162
161
|
|
|
163
|
-
const mismatchError = (actual, expected, filename) => `You have declared using "${expected}" babelHelpers, but transforming ${filename} resulted in "${actual}". Please check your configuration.`;
|
|
162
|
+
const mismatchError = (actual, expected, filename) => `You have declared using "${expected}" babelHelpers, but transforming ${filename} resulted in "${actual}". Please check your configuration.`; // Revert to /\/helpers\/(esm\/)?inherits/ when Babel 8 gets released, this was fixed in https://github.com/babel/babel/issues/14185
|
|
164
163
|
|
|
165
|
-
|
|
164
|
+
|
|
165
|
+
const inheritsHelperRe = /[\\/]+helpers[\\/]+(esm[\\/]+)?inherits/;
|
|
166
166
|
async function preflightCheck(ctx, babelHelpers, transformOptions) {
|
|
167
167
|
const finalOptions = addBabelPlugin(transformOptions, helpersTestTransform);
|
|
168
|
-
const check = (await transformAsync(PREFLIGHT_INPUT, finalOptions)).code; // Babel sometimes splits ExportDefaultDeclaration into 2 statements, so we also check for ExportNamedDeclaration
|
|
168
|
+
const check = (await babel.transformAsync(PREFLIGHT_INPUT, finalOptions)).code; // Babel sometimes splits ExportDefaultDeclaration into 2 statements, so we also check for ExportNamedDeclaration
|
|
169
169
|
|
|
170
170
|
if (!/export (d|{)/.test(check)) {
|
|
171
171
|
ctx.error(MODULE_ERROR);
|
|
@@ -205,13 +205,13 @@ async function preflightCheck(ctx, babelHelpers, transformOptions) {
|
|
|
205
205
|
|
|
206
206
|
async function transformCode(inputCode, babelOptions, overrides, customOptions, ctx, finalizeOptions) {
|
|
207
207
|
// loadPartialConfigAsync has become available in @babel/core@7.8.0
|
|
208
|
-
const config = await (loadPartialConfigAsync || loadPartialConfig)(babelOptions); // file is ignored by babel
|
|
208
|
+
const config = await (babel.loadPartialConfigAsync || babel.loadPartialConfig)(babelOptions); // file is ignored by babel
|
|
209
209
|
|
|
210
210
|
if (!config) {
|
|
211
211
|
return null;
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
-
let transformOptions = !overrides.config ? config.options : await overrides.config.call(
|
|
214
|
+
let transformOptions = !overrides.config ? config.options : await overrides.config.call(ctx, config, {
|
|
215
215
|
code: inputCode,
|
|
216
216
|
customOptions
|
|
217
217
|
});
|
|
@@ -224,14 +224,14 @@ async function transformCode(inputCode, babelOptions, overrides, customOptions,
|
|
|
224
224
|
const {
|
|
225
225
|
code,
|
|
226
226
|
map
|
|
227
|
-
} = await transformAsync(inputCode, transformOptions);
|
|
227
|
+
} = await babel.transformAsync(inputCode, transformOptions);
|
|
228
228
|
return {
|
|
229
229
|
code,
|
|
230
230
|
map
|
|
231
231
|
};
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
-
const result = await transformAsync(inputCode, transformOptions);
|
|
234
|
+
const result = await babel.transformAsync(inputCode, transformOptions);
|
|
235
235
|
const {
|
|
236
236
|
code,
|
|
237
237
|
map
|
|
@@ -249,7 +249,7 @@ async function transformCode(inputCode, babelOptions, overrides, customOptions,
|
|
|
249
249
|
|
|
250
250
|
const unpackOptions = (_ref = {}) => {
|
|
251
251
|
let {
|
|
252
|
-
extensions = DEFAULT_EXTENSIONS,
|
|
252
|
+
extensions = babel.DEFAULT_EXTENSIONS,
|
|
253
253
|
// rollup uses sourcemap, babel uses sourceMaps
|
|
254
254
|
// just normalize them here so people don't have to worry about it
|
|
255
255
|
sourcemap = true,
|
|
@@ -363,6 +363,7 @@ function createBabelInputPluginFactory(customCallback = returnObject) {
|
|
|
363
363
|
let exclude;
|
|
364
364
|
let include;
|
|
365
365
|
let extensions;
|
|
366
|
+
let customFilter;
|
|
366
367
|
|
|
367
368
|
var _unpackInputPluginOpt = unpackInputPluginOptions(pluginOptionsWithOverrides, this.meta.rollupVersion);
|
|
368
369
|
|
|
@@ -371,13 +372,19 @@ function createBabelInputPluginFactory(customCallback = returnObject) {
|
|
|
371
372
|
extensions,
|
|
372
373
|
babelHelpers,
|
|
373
374
|
include,
|
|
375
|
+
filter: customFilter,
|
|
374
376
|
skipPreflightCheck
|
|
375
377
|
} = _unpackInputPluginOpt);
|
|
376
|
-
babelOptions = _objectWithoutProperties(_unpackInputPluginOpt, ["exclude", "extensions", "babelHelpers", "include", "skipPreflightCheck"]);
|
|
378
|
+
babelOptions = _objectWithoutProperties(_unpackInputPluginOpt, ["exclude", "extensions", "babelHelpers", "include", "filter", "skipPreflightCheck"]);
|
|
377
379
|
const extensionRegExp = new RegExp(`(${extensions.map(escapeRegExpCharacters).join('|')})$`);
|
|
378
|
-
const includeExcludeFilter = createFilter(include, exclude);
|
|
379
380
|
|
|
380
|
-
|
|
381
|
+
if (customFilter && (include || exclude)) {
|
|
382
|
+
throw new Error('Could not handle include or exclude with custom filter together');
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
const userDefinedFilter = typeof customFilter === 'function' ? customFilter : createFilter(include, exclude);
|
|
386
|
+
|
|
387
|
+
filter = id => extensionRegExp.test(stripQuery(id).bareId) && userDefinedFilter(id);
|
|
381
388
|
|
|
382
389
|
return null;
|
|
383
390
|
},
|
|
@@ -395,7 +402,7 @@ function createBabelInputPluginFactory(customCallback = returnObject) {
|
|
|
395
402
|
return null;
|
|
396
403
|
}
|
|
397
404
|
|
|
398
|
-
return buildExternalHelpers(null, 'module');
|
|
405
|
+
return babel.buildExternalHelpers(null, 'module');
|
|
399
406
|
},
|
|
400
407
|
|
|
401
408
|
transform(code, filename) {
|
|
@@ -478,5 +485,4 @@ function createBabelOutputPluginFactory(customCallback = returnObject) {
|
|
|
478
485
|
const getBabelInputPlugin = createBabelInputPluginFactory();
|
|
479
486
|
const getBabelOutputPlugin = createBabelOutputPluginFactory();
|
|
480
487
|
|
|
481
|
-
export default getBabelInputPlugin;
|
|
482
|
-
export { getBabelInputPlugin as babel, createBabelInputPluginFactory, createBabelOutputPluginFactory, getBabelInputPlugin, getBabelOutputPlugin };
|
|
488
|
+
export { getBabelInputPlugin as babel, createBabelInputPluginFactory, createBabelOutputPluginFactory, getBabelInputPlugin as default, getBabelInputPlugin, getBabelOutputPlugin };
|
package/dist/index.js
CHANGED
|
@@ -15,14 +15,12 @@ function _interopNamespace(e) {
|
|
|
15
15
|
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
16
|
Object.defineProperty(n, k, d.get ? d : {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () {
|
|
19
|
-
return e[k];
|
|
20
|
-
}
|
|
18
|
+
get: function () { return e[k]; }
|
|
21
19
|
});
|
|
22
20
|
}
|
|
23
21
|
});
|
|
24
22
|
}
|
|
25
|
-
n[
|
|
23
|
+
n["default"] = e;
|
|
26
24
|
return Object.freeze(n);
|
|
27
25
|
}
|
|
28
26
|
|
|
@@ -185,12 +183,13 @@ function helpersTestTransform() {
|
|
|
185
183
|
};
|
|
186
184
|
}
|
|
187
185
|
|
|
188
|
-
const mismatchError = (actual, expected, filename) => `You have declared using "${expected}" babelHelpers, but transforming ${filename} resulted in "${actual}". Please check your configuration.`;
|
|
186
|
+
const mismatchError = (actual, expected, filename) => `You have declared using "${expected}" babelHelpers, but transforming ${filename} resulted in "${actual}". Please check your configuration.`; // Revert to /\/helpers\/(esm\/)?inherits/ when Babel 8 gets released, this was fixed in https://github.com/babel/babel/issues/14185
|
|
187
|
+
|
|
189
188
|
|
|
190
|
-
const inheritsHelperRe =
|
|
189
|
+
const inheritsHelperRe = /[\\/]+helpers[\\/]+(esm[\\/]+)?inherits/;
|
|
191
190
|
async function preflightCheck(ctx, babelHelpers, transformOptions) {
|
|
192
191
|
const finalOptions = addBabelPlugin(transformOptions, helpersTestTransform);
|
|
193
|
-
const check = (await
|
|
192
|
+
const check = (await babel__namespace.transformAsync(PREFLIGHT_INPUT, finalOptions)).code; // Babel sometimes splits ExportDefaultDeclaration into 2 statements, so we also check for ExportNamedDeclaration
|
|
194
193
|
|
|
195
194
|
if (!/export (d|{)/.test(check)) {
|
|
196
195
|
ctx.error(MODULE_ERROR);
|
|
@@ -230,13 +229,13 @@ async function preflightCheck(ctx, babelHelpers, transformOptions) {
|
|
|
230
229
|
|
|
231
230
|
async function transformCode(inputCode, babelOptions, overrides, customOptions, ctx, finalizeOptions) {
|
|
232
231
|
// loadPartialConfigAsync has become available in @babel/core@7.8.0
|
|
233
|
-
const config = await (
|
|
232
|
+
const config = await (babel__namespace.loadPartialConfigAsync || babel__namespace.loadPartialConfig)(babelOptions); // file is ignored by babel
|
|
234
233
|
|
|
235
234
|
if (!config) {
|
|
236
235
|
return null;
|
|
237
236
|
}
|
|
238
237
|
|
|
239
|
-
let transformOptions = !overrides.config ? config.options : await overrides.config.call(
|
|
238
|
+
let transformOptions = !overrides.config ? config.options : await overrides.config.call(ctx, config, {
|
|
240
239
|
code: inputCode,
|
|
241
240
|
customOptions
|
|
242
241
|
});
|
|
@@ -249,14 +248,14 @@ async function transformCode(inputCode, babelOptions, overrides, customOptions,
|
|
|
249
248
|
const {
|
|
250
249
|
code,
|
|
251
250
|
map
|
|
252
|
-
} = await
|
|
251
|
+
} = await babel__namespace.transformAsync(inputCode, transformOptions);
|
|
253
252
|
return {
|
|
254
253
|
code,
|
|
255
254
|
map
|
|
256
255
|
};
|
|
257
256
|
}
|
|
258
257
|
|
|
259
|
-
const result = await
|
|
258
|
+
const result = await babel__namespace.transformAsync(inputCode, transformOptions);
|
|
260
259
|
const {
|
|
261
260
|
code,
|
|
262
261
|
map
|
|
@@ -274,7 +273,7 @@ async function transformCode(inputCode, babelOptions, overrides, customOptions,
|
|
|
274
273
|
|
|
275
274
|
const unpackOptions = (_ref = {}) => {
|
|
276
275
|
let {
|
|
277
|
-
extensions =
|
|
276
|
+
extensions = babel__namespace.DEFAULT_EXTENSIONS,
|
|
278
277
|
// rollup uses sourcemap, babel uses sourceMaps
|
|
279
278
|
// just normalize them here so people don't have to worry about it
|
|
280
279
|
sourcemap = true,
|
|
@@ -388,6 +387,7 @@ function createBabelInputPluginFactory(customCallback = returnObject) {
|
|
|
388
387
|
let exclude;
|
|
389
388
|
let include;
|
|
390
389
|
let extensions;
|
|
390
|
+
let customFilter;
|
|
391
391
|
|
|
392
392
|
var _unpackInputPluginOpt = unpackInputPluginOptions(pluginOptionsWithOverrides, this.meta.rollupVersion);
|
|
393
393
|
|
|
@@ -396,13 +396,19 @@ function createBabelInputPluginFactory(customCallback = returnObject) {
|
|
|
396
396
|
extensions,
|
|
397
397
|
babelHelpers,
|
|
398
398
|
include,
|
|
399
|
+
filter: customFilter,
|
|
399
400
|
skipPreflightCheck
|
|
400
401
|
} = _unpackInputPluginOpt);
|
|
401
|
-
babelOptions = _objectWithoutProperties(_unpackInputPluginOpt, ["exclude", "extensions", "babelHelpers", "include", "skipPreflightCheck"]);
|
|
402
|
+
babelOptions = _objectWithoutProperties(_unpackInputPluginOpt, ["exclude", "extensions", "babelHelpers", "include", "filter", "skipPreflightCheck"]);
|
|
402
403
|
const extensionRegExp = new RegExp(`(${extensions.map(escapeRegExpCharacters).join('|')})$`);
|
|
403
|
-
const includeExcludeFilter = pluginutils.createFilter(include, exclude);
|
|
404
404
|
|
|
405
|
-
|
|
405
|
+
if (customFilter && (include || exclude)) {
|
|
406
|
+
throw new Error('Could not handle include or exclude with custom filter together');
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
const userDefinedFilter = typeof customFilter === 'function' ? customFilter : pluginutils.createFilter(include, exclude);
|
|
410
|
+
|
|
411
|
+
filter = id => extensionRegExp.test(stripQuery(id).bareId) && userDefinedFilter(id);
|
|
406
412
|
|
|
407
413
|
return null;
|
|
408
414
|
},
|
|
@@ -420,7 +426,7 @@ function createBabelInputPluginFactory(customCallback = returnObject) {
|
|
|
420
426
|
return null;
|
|
421
427
|
}
|
|
422
428
|
|
|
423
|
-
return
|
|
429
|
+
return babel__namespace.buildExternalHelpers(null, 'module');
|
|
424
430
|
},
|
|
425
431
|
|
|
426
432
|
transform(code, filename) {
|
|
@@ -506,6 +512,6 @@ const getBabelOutputPlugin = createBabelOutputPluginFactory();
|
|
|
506
512
|
exports.babel = getBabelInputPlugin;
|
|
507
513
|
exports.createBabelInputPluginFactory = createBabelInputPluginFactory;
|
|
508
514
|
exports.createBabelOutputPluginFactory = createBabelOutputPluginFactory;
|
|
509
|
-
exports
|
|
515
|
+
exports["default"] = getBabelInputPlugin;
|
|
510
516
|
exports.getBabelInputPlugin = getBabelInputPlugin;
|
|
511
517
|
exports.getBabelOutputPlugin = getBabelOutputPlugin;
|
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rollup/plugin-babel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
7
|
"description": "Seamless integration between Rollup and Babel.",
|
|
8
8
|
"license": "MIT",
|
|
9
|
-
"repository":
|
|
9
|
+
"repository": {
|
|
10
|
+
"url": "rollup/plugins",
|
|
11
|
+
"directory": "packages/babel"
|
|
12
|
+
},
|
|
10
13
|
"author": "Rich Harris",
|
|
11
14
|
"homepage": "https://github.com/rollup/plugins/tree/master/packages/babel#readme",
|
|
12
15
|
"bugs": "https://github.com/rollup/plugins/issues",
|
|
@@ -17,17 +20,14 @@
|
|
|
17
20
|
},
|
|
18
21
|
"scripts": {
|
|
19
22
|
"build": "rollup -c",
|
|
20
|
-
"ci:coverage": "nyc pnpm
|
|
21
|
-
"ci:lint": "pnpm
|
|
23
|
+
"ci:coverage": "nyc pnpm test && nyc report --reporter=text-lcov > coverage.lcov",
|
|
24
|
+
"ci:lint": "pnpm build && pnpm lint",
|
|
22
25
|
"ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}",
|
|
23
|
-
"ci:test": "pnpm
|
|
24
|
-
"lint": "pnpm run lint:js && pnpm run lint:docs && pnpm run lint:package",
|
|
25
|
-
"lint:docs": "prettier --single-quote --arrow-parens avoid --trailing-comma none --write README.md",
|
|
26
|
-
"lint:js": "eslint --fix --cache src test",
|
|
27
|
-
"lint:package": "prettier --write package.json --plugin=prettier-plugin-package",
|
|
26
|
+
"ci:test": "pnpm test -- --verbose",
|
|
28
27
|
"prebuild": "del-cli dist",
|
|
29
|
-
"
|
|
30
|
-
"pretest": "pnpm
|
|
28
|
+
"prerelease": "pnpm build",
|
|
29
|
+
"pretest": "pnpm build",
|
|
30
|
+
"release": "pnpm plugin:release --workspace-root -- --pkg $npm_package_name",
|
|
31
31
|
"test": "ava",
|
|
32
32
|
"test:ts": "tsc types/index.d.ts test/types.ts --noEmit"
|
|
33
33
|
},
|
|
@@ -50,6 +50,11 @@
|
|
|
50
50
|
"@types/babel__core": "^7.1.9",
|
|
51
51
|
"rollup": "^1.20.0||^2.0.0"
|
|
52
52
|
},
|
|
53
|
+
"peerDependenciesMeta": {
|
|
54
|
+
"@types/babel__core": {
|
|
55
|
+
"optional": true
|
|
56
|
+
}
|
|
57
|
+
},
|
|
53
58
|
"dependencies": {
|
|
54
59
|
"@babel/helper-module-imports": "^7.10.4",
|
|
55
60
|
"@rollup/pluginutils": "^3.1.0"
|
|
@@ -64,7 +69,7 @@
|
|
|
64
69
|
"@rollup/plugin-json": "^4.1.0",
|
|
65
70
|
"@rollup/plugin-node-resolve": "^10.0.0",
|
|
66
71
|
"@types/babel__core": "^7.1.9",
|
|
67
|
-
"rollup": "^2.
|
|
72
|
+
"rollup": "^2.67.3",
|
|
68
73
|
"source-map": "^0.7.3"
|
|
69
74
|
},
|
|
70
75
|
"types": "types/index.d.ts",
|
|
@@ -82,10 +87,5 @@
|
|
|
82
87
|
"contributors": [
|
|
83
88
|
"Bogdan Chadkin <trysound@yandex.ru>",
|
|
84
89
|
"Mateusz Burzyński <mateuszburzynski@gmail.com> (https://github.com/Andarist)"
|
|
85
|
-
]
|
|
86
|
-
"peerDependenciesMeta": {
|
|
87
|
-
"@types/babel__core": {
|
|
88
|
-
"optional": true
|
|
89
|
-
}
|
|
90
|
-
}
|
|
90
|
+
]
|
|
91
91
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Plugin } from 'rollup';
|
|
2
|
-
import { FilterPattern } from '@rollup/pluginutils';
|
|
1
|
+
import { Plugin, PluginContext, TransformPluginContext } from 'rollup';
|
|
2
|
+
import { FilterPattern, CreateFilter } from '@rollup/pluginutils';
|
|
3
3
|
import * as babelCore from '@babel/core';
|
|
4
4
|
|
|
5
5
|
export interface RollupBabelInputPluginOptions
|
|
@@ -14,6 +14,16 @@ export interface RollupBabelInputPluginOptions
|
|
|
14
14
|
* @default undefined;
|
|
15
15
|
*/
|
|
16
16
|
exclude?: FilterPattern;
|
|
17
|
+
/**
|
|
18
|
+
* Custom filter function can be used to determine whether or not certain modules should be operated upon.
|
|
19
|
+
* Example:
|
|
20
|
+
* import { createFilter } from '@rollup/pluginutils';
|
|
21
|
+
* const include = 'include/**.js';
|
|
22
|
+
* const exclude = 'exclude/**.js';
|
|
23
|
+
* const filter = createFilter(include, exclude, {});
|
|
24
|
+
* @default undefined;
|
|
25
|
+
*/
|
|
26
|
+
filter?: ReturnType<CreateFilter>;
|
|
17
27
|
/**
|
|
18
28
|
* 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.
|
|
19
29
|
* @default ['.js', '.jsx', '.es6', '.es', '.mjs']
|
|
@@ -52,28 +62,45 @@ export type RollupBabelCustomOutputPluginOptions = (
|
|
|
52
62
|
customOptions: Record<string, any>;
|
|
53
63
|
pluginOptions: RollupBabelOutputPluginOptions;
|
|
54
64
|
};
|
|
55
|
-
export
|
|
65
|
+
export interface RollupBabelCustomPluginConfigOptions {
|
|
66
|
+
code: string;
|
|
67
|
+
customOptions: Record<string, any>;
|
|
68
|
+
}
|
|
69
|
+
export interface RollupBabelCustomPluginResultOptions {
|
|
70
|
+
code: string;
|
|
71
|
+
customOptions: Record<string, any>;
|
|
72
|
+
config: babelCore.PartialConfig;
|
|
73
|
+
transformOptions: babelCore.TransformOptions;
|
|
74
|
+
}
|
|
75
|
+
export type RollupBabelCustomInputPluginConfig = (
|
|
76
|
+
this: TransformPluginContext,
|
|
77
|
+
cfg: babelCore.PartialConfig,
|
|
78
|
+
options: RollupBabelCustomPluginConfigOptions
|
|
79
|
+
) => babelCore.TransformOptions;
|
|
80
|
+
export type RollupBabelCustomInputPluginResult = (
|
|
81
|
+
this: TransformPluginContext,
|
|
82
|
+
result: babelCore.BabelFileResult,
|
|
83
|
+
options: RollupBabelCustomPluginResultOptions
|
|
84
|
+
) => babelCore.BabelFileResult;
|
|
85
|
+
export type RollupBabelCustomOutputPluginConfig = (
|
|
86
|
+
this: PluginContext,
|
|
56
87
|
cfg: babelCore.PartialConfig,
|
|
57
|
-
options:
|
|
88
|
+
options: RollupBabelCustomPluginConfigOptions
|
|
58
89
|
) => babelCore.TransformOptions;
|
|
59
|
-
export type
|
|
90
|
+
export type RollupBabelCustomOutputPluginResult = (
|
|
91
|
+
this: PluginContext,
|
|
60
92
|
result: babelCore.BabelFileResult,
|
|
61
|
-
options:
|
|
62
|
-
code: string;
|
|
63
|
-
customOptions: Record<string, any>;
|
|
64
|
-
config: babelCore.PartialConfig;
|
|
65
|
-
transformOptions: babelCore.TransformOptions;
|
|
66
|
-
}
|
|
93
|
+
options: RollupBabelCustomPluginResultOptions
|
|
67
94
|
) => babelCore.BabelFileResult;
|
|
68
95
|
export interface RollupBabelCustomInputPlugin {
|
|
69
96
|
options?: RollupBabelCustomInputPluginOptions;
|
|
70
|
-
config?:
|
|
71
|
-
result?:
|
|
97
|
+
config?: RollupBabelCustomInputPluginConfig;
|
|
98
|
+
result?: RollupBabelCustomInputPluginResult;
|
|
72
99
|
}
|
|
73
100
|
export interface RollupBabelCustomOutputPlugin {
|
|
74
101
|
options?: RollupBabelCustomOutputPluginOptions;
|
|
75
|
-
config?:
|
|
76
|
-
result?:
|
|
102
|
+
config?: RollupBabelCustomOutputPluginConfig;
|
|
103
|
+
result?: RollupBabelCustomOutputPluginResult;
|
|
77
104
|
}
|
|
78
105
|
export type RollupBabelCustomInputPluginBuilder = (
|
|
79
106
|
babel: typeof babelCore
|