@rollup/plugin-babel 5.3.0 → 6.0.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/README.md +12 -12
- package/dist/{index.js → cjs/index.js} +67 -149
- package/dist/{index.es.js → es/index.js} +63 -145
- package/dist/es/package.json +1 -0
- package/package.json +35 -29
- package/types/index.d.ts +2 -2
- package/CHANGELOG.md +0 -284
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ Using Rollup with `@rollup/plugin-babel` makes the process far easier.
|
|
|
26
26
|
|
|
27
27
|
## Requirements
|
|
28
28
|
|
|
29
|
-
This plugin requires an [LTS](https://github.com/nodejs/Release) Node version (
|
|
29
|
+
This plugin requires an [LTS](https://github.com/nodejs/Release) Node version (v14.0.0+) and Rollup v1.20.0+.
|
|
30
30
|
|
|
31
31
|
## Install
|
|
32
32
|
|
|
@@ -45,7 +45,7 @@ const config = {
|
|
|
45
45
|
input: 'src/index.js',
|
|
46
46
|
output: {
|
|
47
47
|
dir: 'output',
|
|
48
|
-
format: '
|
|
48
|
+
format: 'es'
|
|
49
49
|
},
|
|
50
50
|
plugins: [babel({ babelHelpers: 'bundled' })]
|
|
51
51
|
};
|
|
@@ -84,13 +84,13 @@ All options are as per the [Babel documentation](https://babeljs.io/docs/en/opti
|
|
|
84
84
|
|
|
85
85
|
Type: `String | RegExp | Array[...String|RegExp]`<br>
|
|
86
86
|
|
|
87
|
-
A [
|
|
87
|
+
A [picomatch pattern](https://github.com/micromatch/picomatch), 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.
|
|
88
88
|
|
|
89
89
|
### `include`
|
|
90
90
|
|
|
91
91
|
Type: `String | RegExp | Array[...String|RegExp]`<br>
|
|
92
92
|
|
|
93
|
-
A [
|
|
93
|
+
A [picomatch pattern](https://github.com/micromatch/picomatch), 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.
|
|
94
94
|
|
|
95
95
|
### `filter`
|
|
96
96
|
|
|
@@ -174,7 +174,7 @@ export default {
|
|
|
174
174
|
],
|
|
175
175
|
output: [
|
|
176
176
|
{ file: 'bundle.cjs.js', format: 'cjs' },
|
|
177
|
-
{ file: 'bundle.
|
|
177
|
+
{ file: 'bundle.es.js', format: 'es' }
|
|
178
178
|
]
|
|
179
179
|
};
|
|
180
180
|
```
|
|
@@ -188,10 +188,10 @@ import { getBabelOutputPlugin } from '@rollup/plugin-babel';
|
|
|
188
188
|
export default {
|
|
189
189
|
input: 'main.js',
|
|
190
190
|
output: [
|
|
191
|
-
{ file: 'bundle.js', format: '
|
|
191
|
+
{ file: 'bundle.js', format: 'es' },
|
|
192
192
|
{
|
|
193
193
|
file: 'bundle.es5.js',
|
|
194
|
-
format: '
|
|
194
|
+
format: 'es',
|
|
195
195
|
plugins: [getBabelOutputPlugin({ presets: ['@babel/preset-env'] })]
|
|
196
196
|
}
|
|
197
197
|
]
|
|
@@ -212,7 +212,7 @@ export default {
|
|
|
212
212
|
output: [
|
|
213
213
|
{
|
|
214
214
|
file: 'bundle.js',
|
|
215
|
-
format: '
|
|
215
|
+
format: 'es',
|
|
216
216
|
plugins: [getBabelOutputPlugin({ presets: ['@babel/preset-env'] })]
|
|
217
217
|
}
|
|
218
218
|
]
|
|
@@ -231,7 +231,7 @@ getBabelOutputPlugin({
|
|
|
231
231
|
|
|
232
232
|
### Using formats other than ES modules or CommonJS
|
|
233
233
|
|
|
234
|
-
As `getBabelOutputPlugin(...)` will run _after_ Rollup has done all its transformations, it needs to make sure it preserves the semantics of Rollup's output format. This is especially important for Babel plugins that add, modify or remove imports or exports, but also for other transformations that add new variables as they can accidentally become global variables depending on the format. Therefore it is recommended that for formats other than `
|
|
234
|
+
As `getBabelOutputPlugin(...)` will run _after_ Rollup has done all its transformations, it needs to make sure it preserves the semantics of Rollup's output format. This is especially important for Babel plugins that add, modify or remove imports or exports, but also for other transformations that add new variables as they can accidentally become global variables depending on the format. Therefore it is recommended that for formats other than `es` or `cjs`, you set Rollup to use the `es` output format and let Babel handle the transformation to another format, e.g. via
|
|
235
235
|
|
|
236
236
|
```
|
|
237
237
|
presets: [['@babel/preset-env', { modules: 'umd' }], ...]
|
|
@@ -256,12 +256,12 @@ By default, helpers e.g. when transpiling classes will be inserted at the top of
|
|
|
256
256
|
|
|
257
257
|
Alternatively, you can use imported runtime helpers by adding the `@babel/transform-runtime` plugin. This will make `@babel/runtime` an external dependency of your project, see [@babel/plugin-transform-runtime](https://babeljs.io/docs/en/babel-plugin-transform-runtime) for details.
|
|
258
258
|
|
|
259
|
-
Note that this will only work for `
|
|
259
|
+
Note that this will only work for `es` and `cjs` formats, and you need to make sure to set the `useESModules` option of `@babel/plugin-transform-runtime` to `true` if you create ES output:
|
|
260
260
|
|
|
261
261
|
```js
|
|
262
262
|
rollup.rollup({...})
|
|
263
263
|
.then(bundle => bundle.generate({
|
|
264
|
-
format: '
|
|
264
|
+
format: 'es',
|
|
265
265
|
plugins: [getBabelOutputPlugin({
|
|
266
266
|
presets: ['@babel/preset-env'],
|
|
267
267
|
plugins: [['@babel/plugin-transform-runtime', { useESModules: true }]]
|
|
@@ -327,7 +327,7 @@ It's main purpose is to allow other tools for configuration of transpilation wit
|
|
|
327
327
|
```js
|
|
328
328
|
import { createBabelInputPluginFactory } from '@rollup/plugin-babel';
|
|
329
329
|
|
|
330
|
-
export default createBabelInputPluginFactory(babelCore => {
|
|
330
|
+
export default createBabelInputPluginFactory((babelCore) => {
|
|
331
331
|
function myPlugin() {
|
|
332
332
|
return {
|
|
333
333
|
visitor: {}
|
|
@@ -6,8 +6,7 @@ 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
|
|
10
|
-
if (e && e.__esModule) return e;
|
|
9
|
+
function _interopNamespaceDefault(e) {
|
|
11
10
|
var n = Object.create(null);
|
|
12
11
|
if (e) {
|
|
13
12
|
Object.keys(e).forEach(function (k) {
|
|
@@ -15,103 +14,16 @@ function _interopNamespace(e) {
|
|
|
15
14
|
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
15
|
Object.defineProperty(n, k, d.get ? d : {
|
|
17
16
|
enumerable: true,
|
|
18
|
-
get: function () {
|
|
19
|
-
return e[k];
|
|
20
|
-
}
|
|
17
|
+
get: function () { return e[k]; }
|
|
21
18
|
});
|
|
22
19
|
}
|
|
23
20
|
});
|
|
24
21
|
}
|
|
25
|
-
n
|
|
22
|
+
n.default = e;
|
|
26
23
|
return Object.freeze(n);
|
|
27
24
|
}
|
|
28
25
|
|
|
29
|
-
var babel__namespace = /*#__PURE__*/
|
|
30
|
-
|
|
31
|
-
function _defineProperty(obj, key, value) {
|
|
32
|
-
if (key in obj) {
|
|
33
|
-
Object.defineProperty(obj, key, {
|
|
34
|
-
value: value,
|
|
35
|
-
enumerable: true,
|
|
36
|
-
configurable: true,
|
|
37
|
-
writable: true
|
|
38
|
-
});
|
|
39
|
-
} else {
|
|
40
|
-
obj[key] = value;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return obj;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function ownKeys(object, enumerableOnly) {
|
|
47
|
-
var keys = Object.keys(object);
|
|
48
|
-
|
|
49
|
-
if (Object.getOwnPropertySymbols) {
|
|
50
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
51
|
-
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
|
52
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
53
|
-
});
|
|
54
|
-
keys.push.apply(keys, symbols);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return keys;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function _objectSpread2(target) {
|
|
61
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
62
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
63
|
-
|
|
64
|
-
if (i % 2) {
|
|
65
|
-
ownKeys(Object(source), true).forEach(function (key) {
|
|
66
|
-
_defineProperty(target, key, source[key]);
|
|
67
|
-
});
|
|
68
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
69
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
70
|
-
} else {
|
|
71
|
-
ownKeys(Object(source)).forEach(function (key) {
|
|
72
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return target;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
81
|
-
if (source == null) return {};
|
|
82
|
-
var target = {};
|
|
83
|
-
var sourceKeys = Object.keys(source);
|
|
84
|
-
var key, i;
|
|
85
|
-
|
|
86
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
87
|
-
key = sourceKeys[i];
|
|
88
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
89
|
-
target[key] = source[key];
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return target;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function _objectWithoutProperties(source, excluded) {
|
|
96
|
-
if (source == null) return {};
|
|
97
|
-
|
|
98
|
-
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
99
|
-
|
|
100
|
-
var key, i;
|
|
101
|
-
|
|
102
|
-
if (Object.getOwnPropertySymbols) {
|
|
103
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
104
|
-
|
|
105
|
-
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
106
|
-
key = sourceSymbolKeys[i];
|
|
107
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
108
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
109
|
-
target[key] = source[key];
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return target;
|
|
114
|
-
}
|
|
26
|
+
var babel__namespace = /*#__PURE__*/_interopNamespaceDefault(babel);
|
|
115
27
|
|
|
116
28
|
const BUNDLED = 'bundled';
|
|
117
29
|
const INLINE = 'inline';
|
|
@@ -144,9 +56,9 @@ function importHelperPlugin({
|
|
|
144
56
|
}
|
|
145
57
|
|
|
146
58
|
const addBabelPlugin = (options, plugin) => {
|
|
147
|
-
return
|
|
59
|
+
return { ...options,
|
|
148
60
|
plugins: options.plugins.concat(plugin)
|
|
149
|
-
}
|
|
61
|
+
};
|
|
150
62
|
};
|
|
151
63
|
const warned = {};
|
|
152
64
|
function warnOnce(ctx, msg) {
|
|
@@ -185,12 +97,13 @@ function helpersTestTransform() {
|
|
|
185
97
|
};
|
|
186
98
|
}
|
|
187
99
|
|
|
188
|
-
const mismatchError = (actual, expected, filename) => `You have declared using "${expected}" babelHelpers, but transforming ${filename} resulted in "${actual}". Please check your configuration.`;
|
|
100
|
+
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
|
|
189
101
|
|
|
190
|
-
|
|
102
|
+
|
|
103
|
+
const inheritsHelperRe = /[\\/]+helpers[\\/]+(esm[\\/]+)?inherits/;
|
|
191
104
|
async function preflightCheck(ctx, babelHelpers, transformOptions) {
|
|
192
105
|
const finalOptions = addBabelPlugin(transformOptions, helpersTestTransform);
|
|
193
|
-
const check = (await
|
|
106
|
+
const check = (await babel__namespace.transformAsync(PREFLIGHT_INPUT, finalOptions)).code; // Babel sometimes splits ExportDefaultDeclaration into 2 statements, so we also check for ExportNamedDeclaration
|
|
194
107
|
|
|
195
108
|
if (!/export (d|{)/.test(check)) {
|
|
196
109
|
ctx.error(MODULE_ERROR);
|
|
@@ -230,7 +143,7 @@ async function preflightCheck(ctx, babelHelpers, transformOptions) {
|
|
|
230
143
|
|
|
231
144
|
async function transformCode(inputCode, babelOptions, overrides, customOptions, ctx, finalizeOptions) {
|
|
232
145
|
// loadPartialConfigAsync has become available in @babel/core@7.8.0
|
|
233
|
-
const config = await (
|
|
146
|
+
const config = await (babel__namespace.loadPartialConfigAsync || babel__namespace.loadPartialConfig)(babelOptions); // file is ignored by babel
|
|
234
147
|
|
|
235
148
|
if (!config) {
|
|
236
149
|
return null;
|
|
@@ -249,14 +162,14 @@ async function transformCode(inputCode, babelOptions, overrides, customOptions,
|
|
|
249
162
|
const {
|
|
250
163
|
code,
|
|
251
164
|
map
|
|
252
|
-
} = await
|
|
165
|
+
} = await babel__namespace.transformAsync(inputCode, transformOptions);
|
|
253
166
|
return {
|
|
254
167
|
code,
|
|
255
168
|
map
|
|
256
169
|
};
|
|
257
170
|
}
|
|
258
171
|
|
|
259
|
-
const result = await
|
|
172
|
+
const result = await babel__namespace.transformAsync(inputCode, transformOptions);
|
|
260
173
|
const {
|
|
261
174
|
code,
|
|
262
175
|
map
|
|
@@ -272,27 +185,26 @@ async function transformCode(inputCode, babelOptions, overrides, customOptions,
|
|
|
272
185
|
};
|
|
273
186
|
}
|
|
274
187
|
|
|
275
|
-
const unpackOptions = (
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
return _objectSpread2(_objectSpread2({
|
|
188
|
+
const unpackOptions = ({
|
|
189
|
+
extensions = babel__namespace.DEFAULT_EXTENSIONS,
|
|
190
|
+
// rollup uses sourcemap, babel uses sourceMaps
|
|
191
|
+
// just normalize them here so people don't have to worry about it
|
|
192
|
+
sourcemap = true,
|
|
193
|
+
sourcemaps = true,
|
|
194
|
+
sourceMap = true,
|
|
195
|
+
sourceMaps = true,
|
|
196
|
+
...rest
|
|
197
|
+
} = {}) => {
|
|
198
|
+
return {
|
|
288
199
|
extensions,
|
|
289
200
|
plugins: [],
|
|
290
|
-
sourceMaps: sourcemap && sourcemaps && sourceMap && sourceMaps
|
|
291
|
-
|
|
292
|
-
caller:
|
|
293
|
-
name: '@rollup/plugin-babel'
|
|
294
|
-
|
|
295
|
-
|
|
201
|
+
sourceMaps: sourcemap && sourcemaps && sourceMap && sourceMaps,
|
|
202
|
+
...rest,
|
|
203
|
+
caller: {
|
|
204
|
+
name: '@rollup/plugin-babel',
|
|
205
|
+
...rest.caller
|
|
206
|
+
}
|
|
207
|
+
};
|
|
296
208
|
};
|
|
297
209
|
|
|
298
210
|
const warnAboutDeprecatedHelpersOption = ({
|
|
@@ -303,12 +215,10 @@ const warnAboutDeprecatedHelpersOption = ({
|
|
|
303
215
|
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
216
|
};
|
|
305
217
|
|
|
306
|
-
const unpackInputPluginOptions = (
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
rest = _objectWithoutProperties(_ref2, ["skipPreflightCheck"]);
|
|
311
|
-
|
|
218
|
+
const unpackInputPluginOptions = ({
|
|
219
|
+
skipPreflightCheck = false,
|
|
220
|
+
...rest
|
|
221
|
+
}, rollupVersion) => {
|
|
312
222
|
if ('runtimeHelpers' in rest) {
|
|
313
223
|
warnAboutDeprecatedHelpersOption({
|
|
314
224
|
deprecatedOption: 'runtimeHelpers',
|
|
@@ -324,29 +234,31 @@ const unpackInputPluginOptions = (_ref2, rollupVersion) => {
|
|
|
324
234
|
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');
|
|
325
235
|
}
|
|
326
236
|
|
|
327
|
-
return unpackOptions(
|
|
237
|
+
return unpackOptions({ ...rest,
|
|
328
238
|
skipPreflightCheck,
|
|
329
239
|
babelHelpers: rest.babelHelpers || BUNDLED,
|
|
330
|
-
caller:
|
|
240
|
+
caller: {
|
|
331
241
|
supportsStaticESM: true,
|
|
332
242
|
supportsDynamicImport: true,
|
|
333
243
|
supportsTopLevelAwait: true,
|
|
334
244
|
// todo: remove version checks for 1.20 - 1.25 when we bump peer deps
|
|
335
|
-
supportsExportNamespaceFrom: !rollupVersion.match(/^1\.2[0-5]\./)
|
|
336
|
-
|
|
337
|
-
|
|
245
|
+
supportsExportNamespaceFrom: !rollupVersion.match(/^1\.2[0-5]\./),
|
|
246
|
+
...rest.caller
|
|
247
|
+
}
|
|
248
|
+
});
|
|
338
249
|
};
|
|
339
250
|
|
|
340
251
|
const unpackOutputPluginOptions = (options, {
|
|
341
252
|
format
|
|
342
|
-
}) => unpackOptions(
|
|
253
|
+
}) => unpackOptions({
|
|
343
254
|
configFile: false,
|
|
344
|
-
sourceType: format === 'es' ? 'module' : 'script'
|
|
345
|
-
|
|
346
|
-
caller:
|
|
347
|
-
supportsStaticESM: format === 'es'
|
|
348
|
-
|
|
349
|
-
}
|
|
255
|
+
sourceType: format === 'es' ? 'module' : 'script',
|
|
256
|
+
...options,
|
|
257
|
+
caller: {
|
|
258
|
+
supportsStaticESM: format === 'es',
|
|
259
|
+
...options.caller
|
|
260
|
+
}
|
|
261
|
+
});
|
|
350
262
|
|
|
351
263
|
function getOptionsWithOverrides(pluginOptions = {}, overrides = {}) {
|
|
352
264
|
if (!overrides.options) return {
|
|
@@ -389,18 +301,15 @@ function createBabelInputPluginFactory(customCallback = returnObject) {
|
|
|
389
301
|
let include;
|
|
390
302
|
let extensions;
|
|
391
303
|
let customFilter;
|
|
392
|
-
|
|
393
|
-
var _unpackInputPluginOpt = unpackInputPluginOptions(pluginOptionsWithOverrides, this.meta.rollupVersion);
|
|
394
|
-
|
|
395
304
|
({
|
|
396
305
|
exclude,
|
|
397
306
|
extensions,
|
|
398
307
|
babelHelpers,
|
|
399
308
|
include,
|
|
400
309
|
filter: customFilter,
|
|
401
|
-
skipPreflightCheck
|
|
402
|
-
|
|
403
|
-
|
|
310
|
+
skipPreflightCheck,
|
|
311
|
+
...babelOptions
|
|
312
|
+
} = unpackInputPluginOptions(pluginOptionsWithOverrides, this.meta.rollupVersion));
|
|
404
313
|
const extensionRegExp = new RegExp(`(${extensions.map(escapeRegExpCharacters).join('|')})$`);
|
|
405
314
|
|
|
406
315
|
if (customFilter && (include || exclude)) {
|
|
@@ -427,15 +336,15 @@ function createBabelInputPluginFactory(customCallback = returnObject) {
|
|
|
427
336
|
return null;
|
|
428
337
|
}
|
|
429
338
|
|
|
430
|
-
return
|
|
339
|
+
return babel__namespace.buildExternalHelpers(null, 'module');
|
|
431
340
|
},
|
|
432
341
|
|
|
433
342
|
transform(code, filename) {
|
|
434
343
|
if (!filter(filename)) return null;
|
|
435
344
|
if (filename === HELPERS) return null;
|
|
436
|
-
return transformCode(code,
|
|
345
|
+
return transformCode(code, { ...babelOptions,
|
|
437
346
|
filename
|
|
438
|
-
}
|
|
347
|
+
}, overrides, customOptions, this, async transformOptions => {
|
|
439
348
|
if (!skipPreflightCheck) {
|
|
440
349
|
await preflightCheck(this, babelHelpers, transformOptions);
|
|
441
350
|
}
|
|
@@ -494,11 +403,18 @@ function createBabelOutputPluginFactory(customCallback = returnObject) {
|
|
|
494
403
|
|
|
495
404
|
renderChunk(code, chunk, outputOptions) {
|
|
496
405
|
/* eslint-disable no-unused-vars */
|
|
497
|
-
const
|
|
498
|
-
|
|
406
|
+
const {
|
|
407
|
+
allowAllFormats,
|
|
408
|
+
exclude,
|
|
409
|
+
extensions,
|
|
410
|
+
externalHelpers,
|
|
411
|
+
externalHelpersWhitelist,
|
|
412
|
+
include,
|
|
413
|
+
runtimeHelpers,
|
|
414
|
+
...babelOptions
|
|
415
|
+
} = unpackOutputPluginOptions(pluginOptionsWithOverrides, outputOptions);
|
|
499
416
|
/* eslint-enable no-unused-vars */
|
|
500
417
|
|
|
501
|
-
|
|
502
418
|
return transformCode(code, babelOptions, overrides, customOptions, this);
|
|
503
419
|
}
|
|
504
420
|
|
|
@@ -516,3 +432,5 @@ exports.createBabelOutputPluginFactory = createBabelOutputPluginFactory;
|
|
|
516
432
|
exports.default = getBabelInputPlugin;
|
|
517
433
|
exports.getBabelInputPlugin = getBabelInputPlugin;
|
|
518
434
|
exports.getBabelOutputPlugin = getBabelOutputPlugin;
|
|
435
|
+
module.exports = Object.assign(exports.default, exports);
|
|
436
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,93 +1,7 @@
|
|
|
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
|
|
|
6
|
-
function _defineProperty(obj, key, value) {
|
|
7
|
-
if (key in obj) {
|
|
8
|
-
Object.defineProperty(obj, key, {
|
|
9
|
-
value: value,
|
|
10
|
-
enumerable: true,
|
|
11
|
-
configurable: true,
|
|
12
|
-
writable: true
|
|
13
|
-
});
|
|
14
|
-
} else {
|
|
15
|
-
obj[key] = value;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return obj;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function ownKeys(object, enumerableOnly) {
|
|
22
|
-
var keys = Object.keys(object);
|
|
23
|
-
|
|
24
|
-
if (Object.getOwnPropertySymbols) {
|
|
25
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
26
|
-
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
|
27
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
28
|
-
});
|
|
29
|
-
keys.push.apply(keys, symbols);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return keys;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function _objectSpread2(target) {
|
|
36
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
37
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
38
|
-
|
|
39
|
-
if (i % 2) {
|
|
40
|
-
ownKeys(Object(source), true).forEach(function (key) {
|
|
41
|
-
_defineProperty(target, key, source[key]);
|
|
42
|
-
});
|
|
43
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
44
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
45
|
-
} else {
|
|
46
|
-
ownKeys(Object(source)).forEach(function (key) {
|
|
47
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return target;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
56
|
-
if (source == null) return {};
|
|
57
|
-
var target = {};
|
|
58
|
-
var sourceKeys = Object.keys(source);
|
|
59
|
-
var key, i;
|
|
60
|
-
|
|
61
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
62
|
-
key = sourceKeys[i];
|
|
63
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
64
|
-
target[key] = source[key];
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return target;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function _objectWithoutProperties(source, excluded) {
|
|
71
|
-
if (source == null) return {};
|
|
72
|
-
|
|
73
|
-
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
74
|
-
|
|
75
|
-
var key, i;
|
|
76
|
-
|
|
77
|
-
if (Object.getOwnPropertySymbols) {
|
|
78
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
79
|
-
|
|
80
|
-
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
81
|
-
key = sourceSymbolKeys[i];
|
|
82
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
83
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
84
|
-
target[key] = source[key];
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return target;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
5
|
const BUNDLED = 'bundled';
|
|
92
6
|
const INLINE = 'inline';
|
|
93
7
|
const RUNTIME = 'runtime';
|
|
@@ -119,9 +33,9 @@ function importHelperPlugin({
|
|
|
119
33
|
}
|
|
120
34
|
|
|
121
35
|
const addBabelPlugin = (options, plugin) => {
|
|
122
|
-
return
|
|
36
|
+
return { ...options,
|
|
123
37
|
plugins: options.plugins.concat(plugin)
|
|
124
|
-
}
|
|
38
|
+
};
|
|
125
39
|
};
|
|
126
40
|
const warned = {};
|
|
127
41
|
function warnOnce(ctx, msg) {
|
|
@@ -160,12 +74,13 @@ function helpersTestTransform() {
|
|
|
160
74
|
};
|
|
161
75
|
}
|
|
162
76
|
|
|
163
|
-
const mismatchError = (actual, expected, filename) => `You have declared using "${expected}" babelHelpers, but transforming ${filename} resulted in "${actual}". Please check your configuration.`;
|
|
77
|
+
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
|
|
78
|
+
|
|
164
79
|
|
|
165
|
-
const inheritsHelperRe =
|
|
80
|
+
const inheritsHelperRe = /[\\/]+helpers[\\/]+(esm[\\/]+)?inherits/;
|
|
166
81
|
async function preflightCheck(ctx, babelHelpers, transformOptions) {
|
|
167
82
|
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
|
|
83
|
+
const check = (await babel.transformAsync(PREFLIGHT_INPUT, finalOptions)).code; // Babel sometimes splits ExportDefaultDeclaration into 2 statements, so we also check for ExportNamedDeclaration
|
|
169
84
|
|
|
170
85
|
if (!/export (d|{)/.test(check)) {
|
|
171
86
|
ctx.error(MODULE_ERROR);
|
|
@@ -205,7 +120,7 @@ async function preflightCheck(ctx, babelHelpers, transformOptions) {
|
|
|
205
120
|
|
|
206
121
|
async function transformCode(inputCode, babelOptions, overrides, customOptions, ctx, finalizeOptions) {
|
|
207
122
|
// loadPartialConfigAsync has become available in @babel/core@7.8.0
|
|
208
|
-
const config = await (loadPartialConfigAsync || loadPartialConfig)(babelOptions); // file is ignored by babel
|
|
123
|
+
const config = await (babel.loadPartialConfigAsync || babel.loadPartialConfig)(babelOptions); // file is ignored by babel
|
|
209
124
|
|
|
210
125
|
if (!config) {
|
|
211
126
|
return null;
|
|
@@ -224,14 +139,14 @@ async function transformCode(inputCode, babelOptions, overrides, customOptions,
|
|
|
224
139
|
const {
|
|
225
140
|
code,
|
|
226
141
|
map
|
|
227
|
-
} = await transformAsync(inputCode, transformOptions);
|
|
142
|
+
} = await babel.transformAsync(inputCode, transformOptions);
|
|
228
143
|
return {
|
|
229
144
|
code,
|
|
230
145
|
map
|
|
231
146
|
};
|
|
232
147
|
}
|
|
233
148
|
|
|
234
|
-
const result = await transformAsync(inputCode, transformOptions);
|
|
149
|
+
const result = await babel.transformAsync(inputCode, transformOptions);
|
|
235
150
|
const {
|
|
236
151
|
code,
|
|
237
152
|
map
|
|
@@ -247,27 +162,26 @@ async function transformCode(inputCode, babelOptions, overrides, customOptions,
|
|
|
247
162
|
};
|
|
248
163
|
}
|
|
249
164
|
|
|
250
|
-
const unpackOptions = (
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
return _objectSpread2(_objectSpread2({
|
|
165
|
+
const unpackOptions = ({
|
|
166
|
+
extensions = babel.DEFAULT_EXTENSIONS,
|
|
167
|
+
// rollup uses sourcemap, babel uses sourceMaps
|
|
168
|
+
// just normalize them here so people don't have to worry about it
|
|
169
|
+
sourcemap = true,
|
|
170
|
+
sourcemaps = true,
|
|
171
|
+
sourceMap = true,
|
|
172
|
+
sourceMaps = true,
|
|
173
|
+
...rest
|
|
174
|
+
} = {}) => {
|
|
175
|
+
return {
|
|
263
176
|
extensions,
|
|
264
177
|
plugins: [],
|
|
265
|
-
sourceMaps: sourcemap && sourcemaps && sourceMap && sourceMaps
|
|
266
|
-
|
|
267
|
-
caller:
|
|
268
|
-
name: '@rollup/plugin-babel'
|
|
269
|
-
|
|
270
|
-
|
|
178
|
+
sourceMaps: sourcemap && sourcemaps && sourceMap && sourceMaps,
|
|
179
|
+
...rest,
|
|
180
|
+
caller: {
|
|
181
|
+
name: '@rollup/plugin-babel',
|
|
182
|
+
...rest.caller
|
|
183
|
+
}
|
|
184
|
+
};
|
|
271
185
|
};
|
|
272
186
|
|
|
273
187
|
const warnAboutDeprecatedHelpersOption = ({
|
|
@@ -278,12 +192,10 @@ const warnAboutDeprecatedHelpersOption = ({
|
|
|
278
192
|
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
193
|
};
|
|
280
194
|
|
|
281
|
-
const unpackInputPluginOptions = (
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
rest = _objectWithoutProperties(_ref2, ["skipPreflightCheck"]);
|
|
286
|
-
|
|
195
|
+
const unpackInputPluginOptions = ({
|
|
196
|
+
skipPreflightCheck = false,
|
|
197
|
+
...rest
|
|
198
|
+
}, rollupVersion) => {
|
|
287
199
|
if ('runtimeHelpers' in rest) {
|
|
288
200
|
warnAboutDeprecatedHelpersOption({
|
|
289
201
|
deprecatedOption: 'runtimeHelpers',
|
|
@@ -299,29 +211,31 @@ const unpackInputPluginOptions = (_ref2, rollupVersion) => {
|
|
|
299
211
|
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');
|
|
300
212
|
}
|
|
301
213
|
|
|
302
|
-
return unpackOptions(
|
|
214
|
+
return unpackOptions({ ...rest,
|
|
303
215
|
skipPreflightCheck,
|
|
304
216
|
babelHelpers: rest.babelHelpers || BUNDLED,
|
|
305
|
-
caller:
|
|
217
|
+
caller: {
|
|
306
218
|
supportsStaticESM: true,
|
|
307
219
|
supportsDynamicImport: true,
|
|
308
220
|
supportsTopLevelAwait: true,
|
|
309
221
|
// todo: remove version checks for 1.20 - 1.25 when we bump peer deps
|
|
310
|
-
supportsExportNamespaceFrom: !rollupVersion.match(/^1\.2[0-5]\./)
|
|
311
|
-
|
|
312
|
-
|
|
222
|
+
supportsExportNamespaceFrom: !rollupVersion.match(/^1\.2[0-5]\./),
|
|
223
|
+
...rest.caller
|
|
224
|
+
}
|
|
225
|
+
});
|
|
313
226
|
};
|
|
314
227
|
|
|
315
228
|
const unpackOutputPluginOptions = (options, {
|
|
316
229
|
format
|
|
317
|
-
}) => unpackOptions(
|
|
230
|
+
}) => unpackOptions({
|
|
318
231
|
configFile: false,
|
|
319
|
-
sourceType: format === 'es' ? 'module' : 'script'
|
|
320
|
-
|
|
321
|
-
caller:
|
|
322
|
-
supportsStaticESM: format === 'es'
|
|
323
|
-
|
|
324
|
-
}
|
|
232
|
+
sourceType: format === 'es' ? 'module' : 'script',
|
|
233
|
+
...options,
|
|
234
|
+
caller: {
|
|
235
|
+
supportsStaticESM: format === 'es',
|
|
236
|
+
...options.caller
|
|
237
|
+
}
|
|
238
|
+
});
|
|
325
239
|
|
|
326
240
|
function getOptionsWithOverrides(pluginOptions = {}, overrides = {}) {
|
|
327
241
|
if (!overrides.options) return {
|
|
@@ -364,18 +278,15 @@ function createBabelInputPluginFactory(customCallback = returnObject) {
|
|
|
364
278
|
let include;
|
|
365
279
|
let extensions;
|
|
366
280
|
let customFilter;
|
|
367
|
-
|
|
368
|
-
var _unpackInputPluginOpt = unpackInputPluginOptions(pluginOptionsWithOverrides, this.meta.rollupVersion);
|
|
369
|
-
|
|
370
281
|
({
|
|
371
282
|
exclude,
|
|
372
283
|
extensions,
|
|
373
284
|
babelHelpers,
|
|
374
285
|
include,
|
|
375
286
|
filter: customFilter,
|
|
376
|
-
skipPreflightCheck
|
|
377
|
-
|
|
378
|
-
|
|
287
|
+
skipPreflightCheck,
|
|
288
|
+
...babelOptions
|
|
289
|
+
} = unpackInputPluginOptions(pluginOptionsWithOverrides, this.meta.rollupVersion));
|
|
379
290
|
const extensionRegExp = new RegExp(`(${extensions.map(escapeRegExpCharacters).join('|')})$`);
|
|
380
291
|
|
|
381
292
|
if (customFilter && (include || exclude)) {
|
|
@@ -402,15 +313,15 @@ function createBabelInputPluginFactory(customCallback = returnObject) {
|
|
|
402
313
|
return null;
|
|
403
314
|
}
|
|
404
315
|
|
|
405
|
-
return buildExternalHelpers(null, 'module');
|
|
316
|
+
return babel.buildExternalHelpers(null, 'module');
|
|
406
317
|
},
|
|
407
318
|
|
|
408
319
|
transform(code, filename) {
|
|
409
320
|
if (!filter(filename)) return null;
|
|
410
321
|
if (filename === HELPERS) return null;
|
|
411
|
-
return transformCode(code,
|
|
322
|
+
return transformCode(code, { ...babelOptions,
|
|
412
323
|
filename
|
|
413
|
-
}
|
|
324
|
+
}, overrides, customOptions, this, async transformOptions => {
|
|
414
325
|
if (!skipPreflightCheck) {
|
|
415
326
|
await preflightCheck(this, babelHelpers, transformOptions);
|
|
416
327
|
}
|
|
@@ -469,11 +380,18 @@ function createBabelOutputPluginFactory(customCallback = returnObject) {
|
|
|
469
380
|
|
|
470
381
|
renderChunk(code, chunk, outputOptions) {
|
|
471
382
|
/* eslint-disable no-unused-vars */
|
|
472
|
-
const
|
|
473
|
-
|
|
383
|
+
const {
|
|
384
|
+
allowAllFormats,
|
|
385
|
+
exclude,
|
|
386
|
+
extensions,
|
|
387
|
+
externalHelpers,
|
|
388
|
+
externalHelpersWhitelist,
|
|
389
|
+
include,
|
|
390
|
+
runtimeHelpers,
|
|
391
|
+
...babelOptions
|
|
392
|
+
} = unpackOutputPluginOptions(pluginOptionsWithOverrides, outputOptions);
|
|
474
393
|
/* eslint-enable no-unused-vars */
|
|
475
394
|
|
|
476
|
-
|
|
477
395
|
return transformCode(code, babelOptions, overrides, customOptions, this);
|
|
478
396
|
}
|
|
479
397
|
|
|
@@ -485,5 +403,5 @@ function createBabelOutputPluginFactory(customCallback = returnObject) {
|
|
|
485
403
|
const getBabelInputPlugin = createBabelInputPluginFactory();
|
|
486
404
|
const getBabelOutputPlugin = createBabelOutputPluginFactory();
|
|
487
405
|
|
|
488
|
-
export default getBabelInputPlugin;
|
|
489
|
-
|
|
406
|
+
export { getBabelInputPlugin as babel, createBabelInputPluginFactory, createBabelOutputPluginFactory, getBabelInputPlugin as default, getBabelInputPlugin, getBabelOutputPlugin };
|
|
407
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
package/package.json
CHANGED
|
@@ -1,38 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rollup/plugin-babel",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
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",
|
|
13
|
-
"main": "dist/index.js",
|
|
14
|
-
"module": "dist/index.
|
|
16
|
+
"main": "./dist/cjs/index.js",
|
|
17
|
+
"module": "./dist/es/index.js",
|
|
18
|
+
"exports": {
|
|
19
|
+
"types": "./types/index.d.ts",
|
|
20
|
+
"import": "./dist/es/index.js",
|
|
21
|
+
"default": "./dist/cjs/index.js"
|
|
22
|
+
},
|
|
15
23
|
"engines": {
|
|
16
|
-
"node": ">=
|
|
24
|
+
"node": ">=14.0.0"
|
|
17
25
|
},
|
|
18
26
|
"scripts": {
|
|
19
27
|
"build": "rollup -c",
|
|
20
|
-
"ci:coverage": "nyc pnpm
|
|
21
|
-
"ci:lint": "pnpm
|
|
28
|
+
"ci:coverage": "nyc pnpm test && nyc report --reporter=text-lcov > coverage.lcov",
|
|
29
|
+
"ci:lint": "pnpm build && pnpm lint",
|
|
22
30
|
"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",
|
|
31
|
+
"ci:test": "pnpm test -- --verbose",
|
|
28
32
|
"prebuild": "del-cli dist",
|
|
29
|
-
"
|
|
30
|
-
"pretest": "pnpm
|
|
33
|
+
"prerelease": "pnpm build",
|
|
34
|
+
"pretest": "pnpm build",
|
|
35
|
+
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
|
|
31
36
|
"test": "ava",
|
|
32
37
|
"test:ts": "tsc types/index.d.ts test/types.ts --noEmit"
|
|
33
38
|
},
|
|
34
39
|
"files": [
|
|
35
40
|
"dist",
|
|
41
|
+
"!dist/**/*.map",
|
|
36
42
|
"types",
|
|
37
43
|
"README.md",
|
|
38
44
|
"LICENSE"
|
|
@@ -48,35 +54,35 @@
|
|
|
48
54
|
"peerDependencies": {
|
|
49
55
|
"@babel/core": "^7.0.0",
|
|
50
56
|
"@types/babel__core": "^7.1.9",
|
|
51
|
-
"rollup": "^1.20.0||^2.0.0"
|
|
57
|
+
"rollup": "^1.20.0||^2.0.0||^3.0.0"
|
|
52
58
|
},
|
|
53
59
|
"peerDependenciesMeta": {
|
|
60
|
+
"rollup": {
|
|
61
|
+
"optional": true
|
|
62
|
+
},
|
|
54
63
|
"@types/babel__core": {
|
|
55
64
|
"optional": true
|
|
56
65
|
}
|
|
57
66
|
},
|
|
58
67
|
"dependencies": {
|
|
59
|
-
"@babel/helper-module-imports": "^7.
|
|
60
|
-
"@rollup/pluginutils": "^
|
|
68
|
+
"@babel/helper-module-imports": "^7.18.6",
|
|
69
|
+
"@rollup/pluginutils": "^4.2.1"
|
|
61
70
|
},
|
|
62
71
|
"devDependencies": {
|
|
63
|
-
"@babel/core": "^7.
|
|
64
|
-
"@babel/plugin-external-helpers": "^7.
|
|
65
|
-
"@babel/plugin-proposal-decorators": "^7.
|
|
72
|
+
"@babel/core": "^7.19.1",
|
|
73
|
+
"@babel/plugin-external-helpers": "^7.18.6",
|
|
74
|
+
"@babel/plugin-proposal-decorators": "^7.19.1",
|
|
66
75
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
67
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
68
|
-
"@babel/preset-env": "^7.
|
|
76
|
+
"@babel/plugin-transform-runtime": "^7.19.1",
|
|
77
|
+
"@babel/preset-env": "^7.19.1",
|
|
69
78
|
"@rollup/plugin-json": "^4.1.0",
|
|
70
|
-
"@rollup/plugin-node-resolve": "^
|
|
79
|
+
"@rollup/plugin-node-resolve": "^14.1.0",
|
|
71
80
|
"@types/babel__core": "^7.1.9",
|
|
72
|
-
"rollup": "^
|
|
73
|
-
"source-map": "^0.7.
|
|
81
|
+
"rollup": "^3.0.0-7",
|
|
82
|
+
"source-map": "^0.7.4"
|
|
74
83
|
},
|
|
75
|
-
"types": "types/index.d.ts",
|
|
84
|
+
"types": "./types/index.d.ts",
|
|
76
85
|
"ava": {
|
|
77
|
-
"babel": {
|
|
78
|
-
"compileEnhancements": false
|
|
79
|
-
},
|
|
80
86
|
"files": [
|
|
81
87
|
"!**/fixtures/**",
|
|
82
88
|
"!**/helpers/**",
|
package/types/index.d.ts
CHANGED
|
@@ -5,12 +5,12 @@ import * as babelCore from '@babel/core';
|
|
|
5
5
|
export interface RollupBabelInputPluginOptions
|
|
6
6
|
extends Omit<babelCore.TransformOptions, 'include' | 'exclude'> {
|
|
7
7
|
/**
|
|
8
|
-
* A
|
|
8
|
+
* A picomatch pattern, 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.
|
|
9
9
|
* @default undefined;
|
|
10
10
|
*/
|
|
11
11
|
include?: FilterPattern;
|
|
12
12
|
/**
|
|
13
|
-
* A
|
|
13
|
+
* A picomatch pattern, 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.
|
|
14
14
|
* @default undefined;
|
|
15
15
|
*/
|
|
16
16
|
exclude?: FilterPattern;
|
package/CHANGELOG.md
DELETED
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
# @rollup/plugin-babel ChangeLog
|
|
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
|
-
|
|
43
|
-
## v5.2.0
|
|
44
|
-
|
|
45
|
-
_2020-08-13_
|
|
46
|
-
|
|
47
|
-
### Features
|
|
48
|
-
|
|
49
|
-
- feat: `export * as ns` support (#511)
|
|
50
|
-
|
|
51
|
-
### Updates
|
|
52
|
-
|
|
53
|
-
- chore: update dependencies (13526d6)
|
|
54
|
-
|
|
55
|
-
## v5.1.0
|
|
56
|
-
|
|
57
|
-
_2020-07-12_
|
|
58
|
-
|
|
59
|
-
### Features
|
|
60
|
-
|
|
61
|
-
- feat: add typings (#462)
|
|
62
|
-
|
|
63
|
-
### Updates
|
|
64
|
-
|
|
65
|
-
- docs: add note about excluding @babel/runtime helpers via regex (#483)
|
|
66
|
-
|
|
67
|
-
## v5.0.4
|
|
68
|
-
|
|
69
|
-
_2020-06-22_
|
|
70
|
-
|
|
71
|
-
### Updates
|
|
72
|
-
|
|
73
|
-
- docs: remove unused import in "Usage" example (#460)
|
|
74
|
-
- docs: update node requirement in readme (#443)
|
|
75
|
-
- docs: fix typo in readme (#447)
|
|
76
|
-
|
|
77
|
-
## v5.0.3
|
|
78
|
-
|
|
79
|
-
_2020-06-05_
|
|
80
|
-
|
|
81
|
-
### Updates
|
|
82
|
-
|
|
83
|
-
- docs: update `babelHelpers` description (#397)
|
|
84
|
-
|
|
85
|
-
## v5.0.2
|
|
86
|
-
|
|
87
|
-
_2020-05-20_
|
|
88
|
-
|
|
89
|
-
### Bugfixes
|
|
90
|
-
|
|
91
|
-
- fix: use loadPartialConfigAsync when it is available (#359)
|
|
92
|
-
|
|
93
|
-
### Updates
|
|
94
|
-
|
|
95
|
-
- docs: Cleanup misleading leftovers in the README (#377)
|
|
96
|
-
- docs: correct breaking change note in v5 CHANGELOG (#368)
|
|
97
|
-
|
|
98
|
-
## v5.0.1
|
|
99
|
-
|
|
100
|
-
_2020-05-20_
|
|
101
|
-
|
|
102
|
-
### Bugfixes
|
|
103
|
-
|
|
104
|
-
- fix: use loadPartialConfigAsync when it is available (#359)
|
|
105
|
-
|
|
106
|
-
### Updates
|
|
107
|
-
|
|
108
|
-
- docs: Cleanup misleading leftovers in the README (#377)
|
|
109
|
-
- docs: correct breaking change note in v5 CHANGELOG (#368)
|
|
110
|
-
|
|
111
|
-
# @rollup/plugin-babel changelog
|
|
112
|
-
|
|
113
|
-
## 5.0.0
|
|
114
|
-
|
|
115
|
-
_2020-04-27_
|
|
116
|
-
|
|
117
|
-
### Features
|
|
118
|
-
|
|
119
|
-
- Added `getBabelOutputPlugin` and `createBabelOutputPluginFactory` exports which can be used to transform generated code
|
|
120
|
-
- Added `skipPreflightCheck` option. The plugin performs some extra checks to see if the passed configuration is correct and matching its expectations. This comes with some runtime overhead and can slow down builds. If you know what you are doing and you are confident that you have configured things correctly you can disable those checks with this option.
|
|
121
|
-
- Published as `@rollup/plugin-babel`
|
|
122
|
-
|
|
123
|
-
### Updates
|
|
124
|
-
|
|
125
|
-
- Default export exported as `getBabelInputPlugin` for symmetry with `getBabelOutputPlugin`
|
|
126
|
-
|
|
127
|
-
### Breaking Changes
|
|
128
|
-
|
|
129
|
-
- Minimum compatible Rollup version is 1.2.0
|
|
130
|
-
- Minimum supported Node version is 10.0.0
|
|
131
|
-
- `.custom` factory is now available as separate `createBabelInputPluginFactory` export
|
|
132
|
-
- Removed `externalHelpers` & `runtimeHelpers` options. There is now a single `babelHelpers` option which can take one of `'bundled'`, `'inline'`, `'runtime'` and `'external'` as a value. The default is `'bundled'` which matches 4.x behavior, but it is recommended to configure this option explicitly.
|
|
133
|
-
|
|
134
|
-
## 4.3.2
|
|
135
|
-
|
|
136
|
-
- Fixed usage with `externalHelpers: true` option
|
|
137
|
-
|
|
138
|
-
## 4.3.1
|
|
139
|
-
|
|
140
|
-
- Add `.js` extension to the virtual babel helpers file (only matters when using `preserveModules` option in rollup)
|
|
141
|
-
|
|
142
|
-
## 4.3.0
|
|
143
|
-
|
|
144
|
-
- Added `.custom` builder.
|
|
145
|
-
- Fail build when a plugin tries to add non existent babel helper
|
|
146
|
-
|
|
147
|
-
## 4.2.0
|
|
148
|
-
|
|
149
|
-
Allow `rollup@1` as peer dependency.
|
|
150
|
-
|
|
151
|
-
## 4.1.0
|
|
152
|
-
|
|
153
|
-
- Fixed "preflight check" for ignored files.
|
|
154
|
-
- Return `null` when no transformation has been done (fixing source maps for this case)
|
|
155
|
-
|
|
156
|
-
## 4.0.3
|
|
157
|
-
|
|
158
|
-
Fixed fallback class transform in "preflight check".
|
|
159
|
-
|
|
160
|
-
## 4.0.2
|
|
161
|
-
|
|
162
|
-
Fixed `rollup` peer dependency.
|
|
163
|
-
|
|
164
|
-
## 4.0.0
|
|
165
|
-
|
|
166
|
-
Babel 7 compatible! (dropped Babel 6 compatibility though).
|
|
167
|
-
|
|
168
|
-
Additionally:
|
|
169
|
-
|
|
170
|
-
- Internal preflight checks are created now per plugin instance, so using 2 instances of rollup-plugin-babel (i.e. targeting 2 different set of files with include/exclude options) shouldn't conflict with each other
|
|
171
|
-
- Transpiling by default only what Babel transpiles - files with those extensions: .js, .jsx, .es6, .es, .mjs. You can customize this with new `extensions` option. This also fixes long standing issue with rollup-plugin-babel trying to transform JSON files.
|
|
172
|
-
|
|
173
|
-
## 3.0.3
|
|
174
|
-
|
|
175
|
-
- Drop babel7 support. Use 4.0.0-beta if you use babel 7
|
|
176
|
-
- Use "module" in addition to "jsnext:main" ([#150](https://github.com/rollup/rollup-plugin-babel/issues/150))
|
|
177
|
-
- Remove unused babel helpers namespace declaration & expression ([#164](https://github.com/rollup/rollup-plugin-babel/issues/164))
|
|
178
|
-
|
|
179
|
-
## 3.0.2
|
|
180
|
-
|
|
181
|
-
- Fix regression with Babel 6 ([#158](https://github.com/rollup/rollup-plugin-babel/issues/158))
|
|
182
|
-
|
|
183
|
-
## 3.0.1
|
|
184
|
-
|
|
185
|
-
- Wasn't working, fix bug with transform (not using es2015-classes for preflight check)
|
|
186
|
-
|
|
187
|
-
## 3.0.0
|
|
188
|
-
|
|
189
|
-
- Drop Node 0.10/0.12 (Use native `Object.assign`)
|
|
190
|
-
- Change `babel-core` to be a peerDependency
|
|
191
|
-
- Support `babel-core` v7 as well as a peerDep (no changes necessary)
|
|
192
|
-
|
|
193
|
-
## 2.7.1
|
|
194
|
-
|
|
195
|
-
- Prevent erroneous warnings about duplicated runtime helpers ([#105](https://github.com/rollup/rollup-plugin-babel/issues/105))
|
|
196
|
-
- Ignore `ignore` option in preflight check ([#102](https://github.com/rollup/rollup-plugin-babel/issues/102))
|
|
197
|
-
- Allow custom `moduleName` with `runtime-helpers` ([#95](https://github.com/rollup/rollup-plugin-babel/issues/95))
|
|
198
|
-
|
|
199
|
-
## 2.7.0
|
|
200
|
-
|
|
201
|
-
- Add `externalHelpersWhitelist` option ([#92](https://github.com/rollup/rollup-plugin-babel/pull/92))
|
|
202
|
-
- Ignore `only` option during preflight checks ([#98](https://github.com/rollup/rollup-plugin-babel/issues/98))
|
|
203
|
-
- Use `options.onwarn` if available ([#84](https://github.com/rollup/rollup-plugin-babel/issues/84))
|
|
204
|
-
- Update documentation and dependencies
|
|
205
|
-
|
|
206
|
-
## 2.6.1
|
|
207
|
-
|
|
208
|
-
- Return a `name`
|
|
209
|
-
|
|
210
|
-
## 2.6.0
|
|
211
|
-
|
|
212
|
-
- Use `\0` convention for helper module ID ([#64](https://github.com/rollup/rollup-plugin-babel/issues/64))
|
|
213
|
-
|
|
214
|
-
## 2.5.1
|
|
215
|
-
|
|
216
|
-
- Don't mutate `options.plugins` ([#47](https://github.com/rollup/rollup-plugin-babel/issues/47))
|
|
217
|
-
|
|
218
|
-
## 2.5.0
|
|
219
|
-
|
|
220
|
-
- Import `babelHelpers` rather than injecting them – allows `transform` function to be pure ([#rollup/658](https://github.com/rollup/rollup/pull/658#issuecomment-223876824))
|
|
221
|
-
|
|
222
|
-
## 2.4.0
|
|
223
|
-
|
|
224
|
-
- Add `externalHelpers` option ([#41](https://github.com/rollup/rollup-plugin-babel/pull/41))
|
|
225
|
-
|
|
226
|
-
## 2.3.9
|
|
227
|
-
|
|
228
|
-
- Do not rename Babel helpers ([#34](https://github.com/rollup/rollup-plugin-babel/pull/34))
|
|
229
|
-
|
|
230
|
-
## 2.3.8
|
|
231
|
-
|
|
232
|
-
- Create new version to (hopefully) solve bizarre CI issue
|
|
233
|
-
|
|
234
|
-
## 2.3.7
|
|
235
|
-
|
|
236
|
-
- Be less clever about renaming Babel helpers ([#19](https://github.com/rollup/rollup-plugin-babel/issues/19))
|
|
237
|
-
|
|
238
|
-
## 2.3.6
|
|
239
|
-
|
|
240
|
-
- Fix cache misses in preflight check ([#29](https://github.com/rollup/rollup-plugin-babel/pull/29))
|
|
241
|
-
|
|
242
|
-
## 2.3.5
|
|
243
|
-
|
|
244
|
-
- Use class transformer local to plugin, not project being built
|
|
245
|
-
|
|
246
|
-
## 2.3.4
|
|
247
|
-
|
|
248
|
-
- Ensure class transformer is present for preflight check, and only run check once per directory ([#23](https://github.com/rollup/rollup-plugin-babel/issues/23))
|
|
249
|
-
|
|
250
|
-
## 2.3.3
|
|
251
|
-
|
|
252
|
-
- Fix helper renaming ([#22](https://github.com/rollup/rollup-plugin-babel/issues/22))
|
|
253
|
-
|
|
254
|
-
## 2.3.1-2
|
|
255
|
-
|
|
256
|
-
- Include correct files in npm package
|
|
257
|
-
|
|
258
|
-
## 2.3.0
|
|
259
|
-
|
|
260
|
-
- Allow `transform-runtime` Babel plugin, if combined with `runtimeHelpers: true` option ([#17](https://github.com/rollup/rollup-plugin-babel/issues/17))
|
|
261
|
-
- More permissive handling of helpers – only warn if inline helpers are duplicated
|
|
262
|
-
- Handle plugins that change export patterns ([#18](https://github.com/rollup/rollup-plugin-babel/issues/18))
|
|
263
|
-
|
|
264
|
-
## 2.2.0
|
|
265
|
-
|
|
266
|
-
- Preflight checks are run per-file, to avoid configuration snafus ([#16](https://github.com/rollup/rollup-plugin-babel/issues/16))
|
|
267
|
-
|
|
268
|
-
## 2.1.0
|
|
269
|
-
|
|
270
|
-
- Generate sourcemaps by default
|
|
271
|
-
|
|
272
|
-
## 2.0.1
|
|
273
|
-
|
|
274
|
-
- Use object-assign ponyfill
|
|
275
|
-
- Add travis support
|
|
276
|
-
- Fix test
|
|
277
|
-
|
|
278
|
-
## 2.0.0
|
|
279
|
-
|
|
280
|
-
- Babel 6 compatible
|
|
281
|
-
|
|
282
|
-
## 1.0.0
|
|
283
|
-
|
|
284
|
-
- First release
|