@rollup/plugin-babel 5.2.0 → 5.3.0
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 +40 -0
- package/README.md +35 -6
- package/dist/index.es.js +44 -7
- package/dist/index.js +68 -9
- package/package.json +8 -7
- package/types/index.d.ts +42 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
# @rollup/plugin-babel ChangeLog
|
|
2
2
|
|
|
3
|
+
## v5.3.0
|
|
4
|
+
|
|
5
|
+
_2021-02-14_
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- feat: add custom filter option (#767)
|
|
10
|
+
- feat: pass rollup context as this context into override config function (#784)
|
|
11
|
+
|
|
12
|
+
### Updates
|
|
13
|
+
|
|
14
|
+
- docs: typo in README.md (#800)
|
|
15
|
+
- chore: commit updated readme format (bfda6d8)
|
|
16
|
+
|
|
17
|
+
## v5.2.3
|
|
18
|
+
|
|
19
|
+
_2021-01-29_
|
|
20
|
+
|
|
21
|
+
### Updates
|
|
22
|
+
|
|
23
|
+
- docs: add usage with commonjs. fixes #622 (6b4b7b6)
|
|
24
|
+
- docs: update export in README (#690)
|
|
25
|
+
|
|
26
|
+
## v5.2.2
|
|
27
|
+
|
|
28
|
+
_2020-11-30_
|
|
29
|
+
|
|
30
|
+
### Bugfixes
|
|
31
|
+
|
|
32
|
+
- fix: clone cached helper identifier before returning it (#584)
|
|
33
|
+
- fix: strip hash and query param in extension filter (#533)
|
|
34
|
+
|
|
35
|
+
## v5.2.1
|
|
36
|
+
|
|
37
|
+
_2020-09-09_
|
|
38
|
+
|
|
39
|
+
### Updates
|
|
40
|
+
|
|
41
|
+
- chore: add deprecation/migration warnings for the runtime (#534)
|
|
42
|
+
|
|
3
43
|
## v5.2.0
|
|
4
44
|
|
|
5
45
|
_2020-08-13_
|
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>
|
|
@@ -314,10 +346,7 @@ export default createBabelInputPluginFactory(babelCore => {
|
|
|
314
346
|
};
|
|
315
347
|
},
|
|
316
348
|
|
|
317
|
-
config(
|
|
318
|
-
cfg /* Passed Babel's 'PartialConfig' object. */,
|
|
319
|
-
{ code, customOptions }
|
|
320
|
-
) {
|
|
349
|
+
config(cfg /* Passed Babel's 'PartialConfig' object. */, { code, customOptions }) {
|
|
321
350
|
if (cfg.hasFilesystemConfig()) {
|
|
322
351
|
// Use the normal config
|
|
323
352
|
return cfg.options;
|
package/dist/index.es.js
CHANGED
|
@@ -96,7 +96,9 @@ const EXTERNAL = 'external'; // NOTE: DO NOT REMOVE the null character `\0` as i
|
|
|
96
96
|
|
|
97
97
|
const HELPERS = '\0rollupPluginBabelHelpers.js';
|
|
98
98
|
|
|
99
|
-
function importHelperPlugin(
|
|
99
|
+
function importHelperPlugin({
|
|
100
|
+
types: t
|
|
101
|
+
}) {
|
|
100
102
|
return {
|
|
101
103
|
pre(file) {
|
|
102
104
|
const cachedHelpers = {};
|
|
@@ -106,7 +108,7 @@ function importHelperPlugin() {
|
|
|
106
108
|
}
|
|
107
109
|
|
|
108
110
|
if (cachedHelpers[name]) {
|
|
109
|
-
return cachedHelpers[name];
|
|
111
|
+
return t.cloneNode(cachedHelpers[name]);
|
|
110
112
|
}
|
|
111
113
|
|
|
112
114
|
return cachedHelpers[name] = addNamed(file.path, name, HELPERS);
|
|
@@ -129,6 +131,16 @@ function warnOnce(ctx, msg) {
|
|
|
129
131
|
}
|
|
130
132
|
const regExpCharactersRegExp = /[\\^$.*+?()[\]{}|]/g;
|
|
131
133
|
const escapeRegExpCharacters = str => str.replace(regExpCharactersRegExp, '\\$&');
|
|
134
|
+
function stripQuery(id) {
|
|
135
|
+
// strip query params from import
|
|
136
|
+
const [bareId, query] = id.split('?');
|
|
137
|
+
const suffix = `${query ? `?${query}` : ''}`;
|
|
138
|
+
return {
|
|
139
|
+
bareId,
|
|
140
|
+
query,
|
|
141
|
+
suffix
|
|
142
|
+
};
|
|
143
|
+
}
|
|
132
144
|
|
|
133
145
|
const MODULE_ERROR = 'Rollup requires that your Babel configuration keeps ES6 module syntax intact. ' + 'Unfortunately it looks like your configuration specifies a module transformer ' + 'to replace ES6 modules with another module format. To continue you have to disable it.' + '\n\n' + "Most commonly it's a CommonJS transform added by @babel/preset-env - " + 'in such case you should disable it by adding `modules: false` option to that preset ' + '(described in more detail here - https://github.com/rollup/plugins/tree/master/packages/babel#modules ).';
|
|
134
146
|
const UNEXPECTED_ERROR = 'An unexpected situation arose. Please raise an issue at ' + 'https://github.com/rollup/plugins/issues. Thanks!';
|
|
@@ -199,7 +211,7 @@ async function transformCode(inputCode, babelOptions, overrides, customOptions,
|
|
|
199
211
|
return null;
|
|
200
212
|
}
|
|
201
213
|
|
|
202
|
-
let transformOptions = !overrides.config ? config.options : await overrides.config.call(
|
|
214
|
+
let transformOptions = !overrides.config ? config.options : await overrides.config.call(ctx, config, {
|
|
203
215
|
code: inputCode,
|
|
204
216
|
customOptions
|
|
205
217
|
});
|
|
@@ -258,13 +270,31 @@ const unpackOptions = (_ref = {}) => {
|
|
|
258
270
|
});
|
|
259
271
|
};
|
|
260
272
|
|
|
273
|
+
const warnAboutDeprecatedHelpersOption = ({
|
|
274
|
+
deprecatedOption,
|
|
275
|
+
suggestion
|
|
276
|
+
}) => {
|
|
277
|
+
// eslint-disable-next-line no-console
|
|
278
|
+
console.warn(`\`${deprecatedOption}\` has been removed in favor a \`babelHelpers\` option. Try changing your configuration to \`${suggestion}\`. ` + `Refer to the documentation to learn more: https://github.com/rollup/plugins/tree/master/packages/babel#babelhelpers`);
|
|
279
|
+
};
|
|
280
|
+
|
|
261
281
|
const unpackInputPluginOptions = (_ref2, rollupVersion) => {
|
|
262
282
|
let {
|
|
263
283
|
skipPreflightCheck = false
|
|
264
284
|
} = _ref2,
|
|
265
285
|
rest = _objectWithoutProperties(_ref2, ["skipPreflightCheck"]);
|
|
266
286
|
|
|
267
|
-
if (
|
|
287
|
+
if ('runtimeHelpers' in rest) {
|
|
288
|
+
warnAboutDeprecatedHelpersOption({
|
|
289
|
+
deprecatedOption: 'runtimeHelpers',
|
|
290
|
+
suggestion: `babelHelpers: 'runtime'`
|
|
291
|
+
});
|
|
292
|
+
} else if ('externalHelpers' in rest) {
|
|
293
|
+
warnAboutDeprecatedHelpersOption({
|
|
294
|
+
deprecatedOption: 'externalHelpers',
|
|
295
|
+
suggestion: `babelHelpers: 'external'`
|
|
296
|
+
});
|
|
297
|
+
} else if (!rest.babelHelpers) {
|
|
268
298
|
// eslint-disable-next-line no-console
|
|
269
299
|
console.warn("babelHelpers: 'bundled' option was used by default. It is recommended to configure this option explicitly, read more here: " + 'https://github.com/rollup/plugins/tree/master/packages/babel#babelhelpers');
|
|
270
300
|
}
|
|
@@ -333,6 +363,7 @@ function createBabelInputPluginFactory(customCallback = returnObject) {
|
|
|
333
363
|
let exclude;
|
|
334
364
|
let include;
|
|
335
365
|
let extensions;
|
|
366
|
+
let customFilter;
|
|
336
367
|
|
|
337
368
|
var _unpackInputPluginOpt = unpackInputPluginOptions(pluginOptionsWithOverrides, this.meta.rollupVersion);
|
|
338
369
|
|
|
@@ -341,13 +372,19 @@ function createBabelInputPluginFactory(customCallback = returnObject) {
|
|
|
341
372
|
extensions,
|
|
342
373
|
babelHelpers,
|
|
343
374
|
include,
|
|
375
|
+
filter: customFilter,
|
|
344
376
|
skipPreflightCheck
|
|
345
377
|
} = _unpackInputPluginOpt);
|
|
346
|
-
babelOptions = _objectWithoutProperties(_unpackInputPluginOpt, ["exclude", "extensions", "babelHelpers", "include", "skipPreflightCheck"]);
|
|
378
|
+
babelOptions = _objectWithoutProperties(_unpackInputPluginOpt, ["exclude", "extensions", "babelHelpers", "include", "filter", "skipPreflightCheck"]);
|
|
347
379
|
const extensionRegExp = new RegExp(`(${extensions.map(escapeRegExpCharacters).join('|')})$`);
|
|
348
|
-
const includeExcludeFilter = createFilter(include, exclude);
|
|
349
380
|
|
|
350
|
-
|
|
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);
|
|
351
388
|
|
|
352
389
|
return null;
|
|
353
390
|
},
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,28 @@ var babel = require('@babel/core');
|
|
|
6
6
|
var pluginutils = require('@rollup/pluginutils');
|
|
7
7
|
var helperModuleImports = require('@babel/helper-module-imports');
|
|
8
8
|
|
|
9
|
+
function _interopNamespace(e) {
|
|
10
|
+
if (e && e.__esModule) return e;
|
|
11
|
+
var n = Object.create(null);
|
|
12
|
+
if (e) {
|
|
13
|
+
Object.keys(e).forEach(function (k) {
|
|
14
|
+
if (k !== 'default') {
|
|
15
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () {
|
|
19
|
+
return e[k];
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
n['default'] = e;
|
|
26
|
+
return Object.freeze(n);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
var babel__namespace = /*#__PURE__*/_interopNamespace(babel);
|
|
30
|
+
|
|
9
31
|
function _defineProperty(obj, key, value) {
|
|
10
32
|
if (key in obj) {
|
|
11
33
|
Object.defineProperty(obj, key, {
|
|
@@ -99,7 +121,9 @@ const EXTERNAL = 'external'; // NOTE: DO NOT REMOVE the null character `\0` as i
|
|
|
99
121
|
|
|
100
122
|
const HELPERS = '\0rollupPluginBabelHelpers.js';
|
|
101
123
|
|
|
102
|
-
function importHelperPlugin(
|
|
124
|
+
function importHelperPlugin({
|
|
125
|
+
types: t
|
|
126
|
+
}) {
|
|
103
127
|
return {
|
|
104
128
|
pre(file) {
|
|
105
129
|
const cachedHelpers = {};
|
|
@@ -109,7 +133,7 @@ function importHelperPlugin() {
|
|
|
109
133
|
}
|
|
110
134
|
|
|
111
135
|
if (cachedHelpers[name]) {
|
|
112
|
-
return cachedHelpers[name];
|
|
136
|
+
return t.cloneNode(cachedHelpers[name]);
|
|
113
137
|
}
|
|
114
138
|
|
|
115
139
|
return cachedHelpers[name] = helperModuleImports.addNamed(file.path, name, HELPERS);
|
|
@@ -132,6 +156,16 @@ function warnOnce(ctx, msg) {
|
|
|
132
156
|
}
|
|
133
157
|
const regExpCharactersRegExp = /[\\^$.*+?()[\]{}|]/g;
|
|
134
158
|
const escapeRegExpCharacters = str => str.replace(regExpCharactersRegExp, '\\$&');
|
|
159
|
+
function stripQuery(id) {
|
|
160
|
+
// strip query params from import
|
|
161
|
+
const [bareId, query] = id.split('?');
|
|
162
|
+
const suffix = `${query ? `?${query}` : ''}`;
|
|
163
|
+
return {
|
|
164
|
+
bareId,
|
|
165
|
+
query,
|
|
166
|
+
suffix
|
|
167
|
+
};
|
|
168
|
+
}
|
|
135
169
|
|
|
136
170
|
const MODULE_ERROR = 'Rollup requires that your Babel configuration keeps ES6 module syntax intact. ' + 'Unfortunately it looks like your configuration specifies a module transformer ' + 'to replace ES6 modules with another module format. To continue you have to disable it.' + '\n\n' + "Most commonly it's a CommonJS transform added by @babel/preset-env - " + 'in such case you should disable it by adding `modules: false` option to that preset ' + '(described in more detail here - https://github.com/rollup/plugins/tree/master/packages/babel#modules ).';
|
|
137
171
|
const UNEXPECTED_ERROR = 'An unexpected situation arose. Please raise an issue at ' + 'https://github.com/rollup/plugins/issues. Thanks!';
|
|
@@ -202,7 +236,7 @@ async function transformCode(inputCode, babelOptions, overrides, customOptions,
|
|
|
202
236
|
return null;
|
|
203
237
|
}
|
|
204
238
|
|
|
205
|
-
let transformOptions = !overrides.config ? config.options : await overrides.config.call(
|
|
239
|
+
let transformOptions = !overrides.config ? config.options : await overrides.config.call(ctx, config, {
|
|
206
240
|
code: inputCode,
|
|
207
241
|
customOptions
|
|
208
242
|
});
|
|
@@ -261,13 +295,31 @@ const unpackOptions = (_ref = {}) => {
|
|
|
261
295
|
});
|
|
262
296
|
};
|
|
263
297
|
|
|
298
|
+
const warnAboutDeprecatedHelpersOption = ({
|
|
299
|
+
deprecatedOption,
|
|
300
|
+
suggestion
|
|
301
|
+
}) => {
|
|
302
|
+
// eslint-disable-next-line no-console
|
|
303
|
+
console.warn(`\`${deprecatedOption}\` has been removed in favor a \`babelHelpers\` option. Try changing your configuration to \`${suggestion}\`. ` + `Refer to the documentation to learn more: https://github.com/rollup/plugins/tree/master/packages/babel#babelhelpers`);
|
|
304
|
+
};
|
|
305
|
+
|
|
264
306
|
const unpackInputPluginOptions = (_ref2, rollupVersion) => {
|
|
265
307
|
let {
|
|
266
308
|
skipPreflightCheck = false
|
|
267
309
|
} = _ref2,
|
|
268
310
|
rest = _objectWithoutProperties(_ref2, ["skipPreflightCheck"]);
|
|
269
311
|
|
|
270
|
-
if (
|
|
312
|
+
if ('runtimeHelpers' in rest) {
|
|
313
|
+
warnAboutDeprecatedHelpersOption({
|
|
314
|
+
deprecatedOption: 'runtimeHelpers',
|
|
315
|
+
suggestion: `babelHelpers: 'runtime'`
|
|
316
|
+
});
|
|
317
|
+
} else if ('externalHelpers' in rest) {
|
|
318
|
+
warnAboutDeprecatedHelpersOption({
|
|
319
|
+
deprecatedOption: 'externalHelpers',
|
|
320
|
+
suggestion: `babelHelpers: 'external'`
|
|
321
|
+
});
|
|
322
|
+
} else if (!rest.babelHelpers) {
|
|
271
323
|
// eslint-disable-next-line no-console
|
|
272
324
|
console.warn("babelHelpers: 'bundled' option was used by default. It is recommended to configure this option explicitly, read more here: " + 'https://github.com/rollup/plugins/tree/master/packages/babel#babelhelpers');
|
|
273
325
|
}
|
|
@@ -318,7 +370,7 @@ const returnObject = () => {
|
|
|
318
370
|
};
|
|
319
371
|
|
|
320
372
|
function createBabelInputPluginFactory(customCallback = returnObject) {
|
|
321
|
-
const overrides = customCallback(
|
|
373
|
+
const overrides = customCallback(babel__namespace);
|
|
322
374
|
return pluginOptions => {
|
|
323
375
|
const {
|
|
324
376
|
customOptions,
|
|
@@ -336,6 +388,7 @@ function createBabelInputPluginFactory(customCallback = returnObject) {
|
|
|
336
388
|
let exclude;
|
|
337
389
|
let include;
|
|
338
390
|
let extensions;
|
|
391
|
+
let customFilter;
|
|
339
392
|
|
|
340
393
|
var _unpackInputPluginOpt = unpackInputPluginOptions(pluginOptionsWithOverrides, this.meta.rollupVersion);
|
|
341
394
|
|
|
@@ -344,13 +397,19 @@ function createBabelInputPluginFactory(customCallback = returnObject) {
|
|
|
344
397
|
extensions,
|
|
345
398
|
babelHelpers,
|
|
346
399
|
include,
|
|
400
|
+
filter: customFilter,
|
|
347
401
|
skipPreflightCheck
|
|
348
402
|
} = _unpackInputPluginOpt);
|
|
349
|
-
babelOptions = _objectWithoutProperties(_unpackInputPluginOpt, ["exclude", "extensions", "babelHelpers", "include", "skipPreflightCheck"]);
|
|
403
|
+
babelOptions = _objectWithoutProperties(_unpackInputPluginOpt, ["exclude", "extensions", "babelHelpers", "include", "filter", "skipPreflightCheck"]);
|
|
350
404
|
const extensionRegExp = new RegExp(`(${extensions.map(escapeRegExpCharacters).join('|')})$`);
|
|
351
|
-
const includeExcludeFilter = pluginutils.createFilter(include, exclude);
|
|
352
405
|
|
|
353
|
-
|
|
406
|
+
if (customFilter && (include || exclude)) {
|
|
407
|
+
throw new Error('Could not handle include or exclude with custom filter together');
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
const userDefinedFilter = typeof customFilter === 'function' ? customFilter : pluginutils.createFilter(include, exclude);
|
|
411
|
+
|
|
412
|
+
filter = id => extensionRegExp.test(stripQuery(id).bareId) && userDefinedFilter(id);
|
|
354
413
|
|
|
355
414
|
return null;
|
|
356
415
|
},
|
|
@@ -407,7 +466,7 @@ function getRecommendedFormat(rollupFormat) {
|
|
|
407
466
|
}
|
|
408
467
|
|
|
409
468
|
function createBabelOutputPluginFactory(customCallback = returnObject) {
|
|
410
|
-
const overrides = customCallback(
|
|
469
|
+
const overrides = customCallback(babel__namespace);
|
|
411
470
|
return pluginOptions => {
|
|
412
471
|
const {
|
|
413
472
|
customOptions,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rollup/plugin-babel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -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"
|
|
@@ -62,6 +67,7 @@
|
|
|
62
67
|
"@babel/plugin-transform-runtime": "^7.10.5",
|
|
63
68
|
"@babel/preset-env": "^7.10.4",
|
|
64
69
|
"@rollup/plugin-json": "^4.1.0",
|
|
70
|
+
"@rollup/plugin-node-resolve": "^10.0.0",
|
|
65
71
|
"@types/babel__core": "^7.1.9",
|
|
66
72
|
"rollup": "^2.23.0",
|
|
67
73
|
"source-map": "^0.7.3"
|
|
@@ -81,10 +87,5 @@
|
|
|
81
87
|
"contributors": [
|
|
82
88
|
"Bogdan Chadkin <trysound@yandex.ru>",
|
|
83
89
|
"Mateusz Burzyński <mateuszburzynski@gmail.com> (https://github.com/Andarist)"
|
|
84
|
-
]
|
|
85
|
-
"peerDependenciesMeta": {
|
|
86
|
-
"@types/babel__core": {
|
|
87
|
-
"optional": true
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
+
]
|
|
90
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
|