@rollup/plugin-babel 5.3.1 → 6.0.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/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 (v10.0.0+) and Rollup v1.20.0+.
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: 'esm'
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 [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.
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 [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.
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.esm.js', format: 'esm' }
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: 'esm' },
191
+ { file: 'bundle.js', format: 'es' },
192
192
  {
193
193
  file: 'bundle.es5.js',
194
- format: 'esm',
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: 'esm',
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 `esm` or `cjs`, you set Rollup to use the `esm` output format and let Babel handle the transformation to another format, e.g. via
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 `esm` and `cjs` formats, and you need to make sure to set the `useESModules` option of `@babel/plugin-transform-runtime` to `true` if you create ESM output:
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: 'esm',
264
+ format: 'es',
265
265
  plugins: [getBabelOutputPlugin({
266
266
  presets: ['@babel/preset-env'],
267
267
  plugins: [['@babel/plugin-transform-runtime', { useESModules: true }]]
@@ -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 _interopNamespace(e) {
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) {
@@ -20,103 +19,19 @@ function _interopNamespace(e) {
20
19
  }
21
20
  });
22
21
  }
23
- n["default"] = e;
22
+ n.default = e;
24
23
  return Object.freeze(n);
25
24
  }
26
25
 
27
- var babel__namespace = /*#__PURE__*/_interopNamespace(babel);
28
-
29
- function _defineProperty(obj, key, value) {
30
- if (key in obj) {
31
- Object.defineProperty(obj, key, {
32
- value: value,
33
- enumerable: true,
34
- configurable: true,
35
- writable: true
36
- });
37
- } else {
38
- obj[key] = value;
39
- }
40
-
41
- return obj;
42
- }
43
-
44
- function ownKeys(object, enumerableOnly) {
45
- var keys = Object.keys(object);
46
-
47
- if (Object.getOwnPropertySymbols) {
48
- var symbols = Object.getOwnPropertySymbols(object);
49
- if (enumerableOnly) symbols = symbols.filter(function (sym) {
50
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
51
- });
52
- keys.push.apply(keys, symbols);
53
- }
54
-
55
- return keys;
56
- }
57
-
58
- function _objectSpread2(target) {
59
- for (var i = 1; i < arguments.length; i++) {
60
- var source = arguments[i] != null ? arguments[i] : {};
61
-
62
- if (i % 2) {
63
- ownKeys(Object(source), true).forEach(function (key) {
64
- _defineProperty(target, key, source[key]);
65
- });
66
- } else if (Object.getOwnPropertyDescriptors) {
67
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
68
- } else {
69
- ownKeys(Object(source)).forEach(function (key) {
70
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
71
- });
72
- }
73
- }
74
-
75
- return target;
76
- }
77
-
78
- function _objectWithoutPropertiesLoose(source, excluded) {
79
- if (source == null) return {};
80
- var target = {};
81
- var sourceKeys = Object.keys(source);
82
- var key, i;
83
-
84
- for (i = 0; i < sourceKeys.length; i++) {
85
- key = sourceKeys[i];
86
- if (excluded.indexOf(key) >= 0) continue;
87
- target[key] = source[key];
88
- }
89
-
90
- return target;
91
- }
92
-
93
- function _objectWithoutProperties(source, excluded) {
94
- if (source == null) return {};
95
-
96
- var target = _objectWithoutPropertiesLoose(source, excluded);
97
-
98
- var key, i;
99
-
100
- if (Object.getOwnPropertySymbols) {
101
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
102
-
103
- for (i = 0; i < sourceSymbolKeys.length; i++) {
104
- key = sourceSymbolKeys[i];
105
- if (excluded.indexOf(key) >= 0) continue;
106
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
107
- target[key] = source[key];
108
- }
109
- }
110
-
111
- return target;
112
- }
26
+ var babel__namespace = /*#__PURE__*/_interopNamespaceDefault(babel);
113
27
 
114
28
  const BUNDLED = 'bundled';
115
29
  const INLINE = 'inline';
116
30
  const RUNTIME = 'runtime';
117
- const EXTERNAL = 'external'; // NOTE: DO NOT REMOVE the null character `\0` as it may be used by other plugins
118
- // e.g. https://github.com/rollup/rollup-plugin-node-resolve/blob/313a3e32f432f9eb18cc4c231cc7aac6df317a51/src/index.js#L74
31
+ const EXTERNAL = 'external';
119
32
 
33
+ // NOTE: DO NOT REMOVE the null character `\0` as it may be used by other plugins
34
+ // e.g. https://github.com/rollup/rollup-plugin-node-resolve/blob/313a3e32f432f9eb18cc4c231cc7aac6df317a51/src/index.js#L74
120
35
  const HELPERS = '\0rollupPluginBabelHelpers.js';
121
36
 
122
37
  function importHelperPlugin({
@@ -129,22 +44,20 @@ function importHelperPlugin({
129
44
  if (!file.availableHelper(name)) {
130
45
  return null;
131
46
  }
132
-
133
47
  if (cachedHelpers[name]) {
134
48
  return t.cloneNode(cachedHelpers[name]);
135
49
  }
136
-
137
50
  return cachedHelpers[name] = helperModuleImports.addNamed(file.path, name, HELPERS);
138
51
  });
139
52
  }
140
-
141
53
  };
142
54
  }
143
55
 
144
56
  const addBabelPlugin = (options, plugin) => {
145
- return _objectSpread2(_objectSpread2({}, options), {}, {
57
+ return {
58
+ ...options,
146
59
  plugins: options.plugins.concat(plugin)
147
- });
60
+ };
148
61
  };
149
62
  const warned = {};
150
63
  function warnOnce(ctx, msg) {
@@ -169,7 +82,6 @@ const MODULE_ERROR = 'Rollup requires that your Babel configuration keeps ES6 mo
169
82
  const UNEXPECTED_ERROR = 'An unexpected situation arose. Please raise an issue at ' + 'https://github.com/rollup/plugins/issues. Thanks!';
170
83
  const PREFLIGHT_TEST_STRING = '__ROLLUP__PREFLIGHT_CHECK_DO_NOT_TOUCH__';
171
84
  const PREFLIGHT_INPUT = `export default "${PREFLIGHT_TEST_STRING}";`;
172
-
173
85
  function helpersTestTransform() {
174
86
  return {
175
87
  visitor: {
@@ -178,72 +90,62 @@ function helpersTestTransform() {
178
90
  path.replaceWith(state.file.addHelper('inherits'));
179
91
  }
180
92
  }
181
-
182
93
  }
183
94
  };
184
95
  }
96
+ const mismatchError = (actual, expected, filename) => `You have declared using "${expected}" babelHelpers, but transforming ${filename} resulted in "${actual}". Please check your configuration.`;
185
97
 
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
-
188
-
98
+ // Revert to /\/helpers\/(esm\/)?inherits/ when Babel 8 gets released, this was fixed in https://github.com/babel/babel/issues/14185
189
99
  const inheritsHelperRe = /[\\/]+helpers[\\/]+(esm[\\/]+)?inherits/;
190
100
  async function preflightCheck(ctx, babelHelpers, transformOptions) {
191
101
  const finalOptions = addBabelPlugin(transformOptions, helpersTestTransform);
192
- const check = (await babel__namespace.transformAsync(PREFLIGHT_INPUT, finalOptions)).code; // Babel sometimes splits ExportDefaultDeclaration into 2 statements, so we also check for ExportNamedDeclaration
102
+ const check = (await babel__namespace.transformAsync(PREFLIGHT_INPUT, finalOptions)).code;
193
103
 
104
+ // Babel sometimes splits ExportDefaultDeclaration into 2 statements, so we also check for ExportNamedDeclaration
194
105
  if (!/export (d|{)/.test(check)) {
195
106
  ctx.error(MODULE_ERROR);
196
107
  }
197
-
198
108
  if (inheritsHelperRe.test(check)) {
199
109
  if (babelHelpers === RUNTIME) {
200
110
  return;
201
111
  }
202
-
203
112
  ctx.error(mismatchError(RUNTIME, babelHelpers, transformOptions.filename));
204
113
  }
205
-
206
114
  if (check.includes('babelHelpers.inherits')) {
207
115
  if (babelHelpers === EXTERNAL) {
208
116
  return;
209
117
  }
210
-
211
118
  ctx.error(mismatchError(EXTERNAL, babelHelpers, transformOptions.filename));
212
- } // test unminifiable string content
213
-
119
+ }
214
120
 
121
+ // test unminifiable string content
215
122
  if (check.includes('Super expression must either be null or a function')) {
216
123
  if (babelHelpers === INLINE || babelHelpers === BUNDLED) {
217
124
  return;
218
125
  }
219
-
220
126
  if (babelHelpers === RUNTIME && !transformOptions.plugins.length) {
221
127
  ctx.error(`You must use the \`@babel/plugin-transform-runtime\` plugin when \`babelHelpers\` is "${RUNTIME}".\n`);
222
128
  }
223
-
224
129
  ctx.error(mismatchError(INLINE, babelHelpers, transformOptions.filename));
225
130
  }
226
-
227
131
  ctx.error(UNEXPECTED_ERROR);
228
132
  }
229
133
 
230
134
  async function transformCode(inputCode, babelOptions, overrides, customOptions, ctx, finalizeOptions) {
231
135
  // loadPartialConfigAsync has become available in @babel/core@7.8.0
232
- const config = await (babel__namespace.loadPartialConfigAsync || babel__namespace.loadPartialConfig)(babelOptions); // file is ignored by babel
136
+ const config = await (babel__namespace.loadPartialConfigAsync || babel__namespace.loadPartialConfig)(babelOptions);
233
137
 
138
+ // file is ignored by babel
234
139
  if (!config) {
235
140
  return null;
236
141
  }
237
-
238
142
  let transformOptions = !overrides.config ? config.options : await overrides.config.call(ctx, config, {
239
143
  code: inputCode,
240
144
  customOptions
241
145
  });
242
-
243
146
  if (finalizeOptions) {
244
147
  transformOptions = await finalizeOptions(transformOptions);
245
148
  }
246
-
247
149
  if (!overrides.result) {
248
150
  const {
249
151
  code,
@@ -254,7 +156,6 @@ async function transformCode(inputCode, babelOptions, overrides, customOptions,
254
156
  map
255
157
  };
256
158
  }
257
-
258
159
  const result = await babel__namespace.transformAsync(inputCode, transformOptions);
259
160
  const {
260
161
  code,
@@ -271,29 +172,27 @@ async function transformCode(inputCode, babelOptions, overrides, customOptions,
271
172
  };
272
173
  }
273
174
 
274
- const unpackOptions = (_ref = {}) => {
275
- let {
276
- extensions = babel__namespace.DEFAULT_EXTENSIONS,
277
- // rollup uses sourcemap, babel uses sourceMaps
278
- // just normalize them here so people don't have to worry about it
279
- sourcemap = true,
280
- sourcemaps = true,
281
- sourceMap = true,
282
- sourceMaps = true
283
- } = _ref,
284
- rest = _objectWithoutProperties(_ref, ["extensions", "sourcemap", "sourcemaps", "sourceMap", "sourceMaps"]);
285
-
286
- return _objectSpread2(_objectSpread2({
175
+ const unpackOptions = ({
176
+ extensions = babel__namespace.DEFAULT_EXTENSIONS,
177
+ // rollup uses sourcemap, babel uses sourceMaps
178
+ // just normalize them here so people don't have to worry about it
179
+ sourcemap = true,
180
+ sourcemaps = true,
181
+ sourceMap = true,
182
+ sourceMaps = true,
183
+ ...rest
184
+ } = {}) => {
185
+ return {
287
186
  extensions,
288
187
  plugins: [],
289
- sourceMaps: sourcemap && sourcemaps && sourceMap && sourceMaps
290
- }, rest), {}, {
291
- caller: _objectSpread2({
292
- name: '@rollup/plugin-babel'
293
- }, rest.caller)
294
- });
188
+ sourceMaps: sourcemap && sourcemaps && sourceMap && sourceMaps,
189
+ ...rest,
190
+ caller: {
191
+ name: '@rollup/plugin-babel',
192
+ ...rest.caller
193
+ }
194
+ };
295
195
  };
296
-
297
196
  const warnAboutDeprecatedHelpersOption = ({
298
197
  deprecatedOption,
299
198
  suggestion
@@ -301,13 +200,10 @@ const warnAboutDeprecatedHelpersOption = ({
301
200
  // eslint-disable-next-line no-console
302
201
  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`);
303
202
  };
304
-
305
- const unpackInputPluginOptions = (_ref2, rollupVersion) => {
306
- let {
307
- skipPreflightCheck = false
308
- } = _ref2,
309
- rest = _objectWithoutProperties(_ref2, ["skipPreflightCheck"]);
310
-
203
+ const unpackInputPluginOptions = ({
204
+ skipPreflightCheck = false,
205
+ ...rest
206
+ }, rollupVersion) => {
311
207
  if ('runtimeHelpers' in rest) {
312
208
  warnAboutDeprecatedHelpersOption({
313
209
  deprecatedOption: 'runtimeHelpers',
@@ -322,52 +218,48 @@ const unpackInputPluginOptions = (_ref2, rollupVersion) => {
322
218
  // eslint-disable-next-line no-console
323
219
  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');
324
220
  }
325
-
326
- return unpackOptions(_objectSpread2(_objectSpread2({}, rest), {}, {
221
+ return unpackOptions({
222
+ ...rest,
327
223
  skipPreflightCheck,
328
224
  babelHelpers: rest.babelHelpers || BUNDLED,
329
- caller: _objectSpread2({
225
+ caller: {
330
226
  supportsStaticESM: true,
331
227
  supportsDynamicImport: true,
332
228
  supportsTopLevelAwait: true,
333
229
  // todo: remove version checks for 1.20 - 1.25 when we bump peer deps
334
- supportsExportNamespaceFrom: !rollupVersion.match(/^1\.2[0-5]\./)
335
- }, rest.caller)
336
- }));
230
+ supportsExportNamespaceFrom: !rollupVersion.match(/^1\.2[0-5]\./),
231
+ ...rest.caller
232
+ }
233
+ });
337
234
  };
338
-
339
235
  const unpackOutputPluginOptions = (options, {
340
236
  format
341
- }) => unpackOptions(_objectSpread2(_objectSpread2({
237
+ }) => unpackOptions({
342
238
  configFile: false,
343
- sourceType: format === 'es' ? 'module' : 'script'
344
- }, options), {}, {
345
- caller: _objectSpread2({
346
- supportsStaticESM: format === 'es'
347
- }, options.caller)
348
- }));
349
-
239
+ sourceType: format === 'es' ? 'module' : 'script',
240
+ ...options,
241
+ caller: {
242
+ supportsStaticESM: format === 'es',
243
+ ...options.caller
244
+ }
245
+ });
350
246
  function getOptionsWithOverrides(pluginOptions = {}, overrides = {}) {
351
247
  if (!overrides.options) return {
352
248
  customOptions: null,
353
249
  pluginOptionsWithOverrides: pluginOptions
354
250
  };
355
251
  const overridden = overrides.options(pluginOptions);
356
-
357
252
  if (typeof overridden.then === 'function') {
358
253
  throw new Error(".options hook can't be asynchronous. It should return `{ customOptions, pluginsOptions }` synchronously.");
359
254
  }
360
-
361
255
  return {
362
256
  customOptions: overridden.customOptions || null,
363
257
  pluginOptionsWithOverrides: overridden.pluginOptions || pluginOptions
364
258
  };
365
259
  }
366
-
367
260
  const returnObject = () => {
368
261
  return {};
369
262
  };
370
-
371
263
  function createBabelInputPluginFactory(customCallback = returnObject) {
372
264
  const overrides = customCallback(babel__namespace);
373
265
  return pluginOptions => {
@@ -381,89 +273,70 @@ function createBabelInputPluginFactory(customCallback = returnObject) {
381
273
  let skipPreflightCheck;
382
274
  return {
383
275
  name: 'babel',
384
-
385
276
  options() {
386
277
  // todo: remove options hook and hoist declarations when version checks are removed
387
278
  let exclude;
388
279
  let include;
389
280
  let extensions;
390
281
  let customFilter;
391
-
392
- var _unpackInputPluginOpt = unpackInputPluginOptions(pluginOptionsWithOverrides, this.meta.rollupVersion);
393
-
394
282
  ({
395
283
  exclude,
396
284
  extensions,
397
285
  babelHelpers,
398
286
  include,
399
287
  filter: customFilter,
400
- skipPreflightCheck
401
- } = _unpackInputPluginOpt);
402
- babelOptions = _objectWithoutProperties(_unpackInputPluginOpt, ["exclude", "extensions", "babelHelpers", "include", "filter", "skipPreflightCheck"]);
288
+ skipPreflightCheck,
289
+ ...babelOptions
290
+ } = unpackInputPluginOptions(pluginOptionsWithOverrides, this.meta.rollupVersion));
403
291
  const extensionRegExp = new RegExp(`(${extensions.map(escapeRegExpCharacters).join('|')})$`);
404
-
405
292
  if (customFilter && (include || exclude)) {
406
293
  throw new Error('Could not handle include or exclude with custom filter together');
407
294
  }
408
-
409
295
  const userDefinedFilter = typeof customFilter === 'function' ? customFilter : pluginutils.createFilter(include, exclude);
410
-
411
296
  filter = id => extensionRegExp.test(stripQuery(id).bareId) && userDefinedFilter(id);
412
-
413
297
  return null;
414
298
  },
415
-
416
299
  resolveId(id) {
417
300
  if (id !== HELPERS) {
418
301
  return null;
419
302
  }
420
-
421
303
  return id;
422
304
  },
423
-
424
305
  load(id) {
425
306
  if (id !== HELPERS) {
426
307
  return null;
427
308
  }
428
-
429
309
  return babel__namespace.buildExternalHelpers(null, 'module');
430
310
  },
431
-
432
311
  transform(code, filename) {
433
312
  if (!filter(filename)) return null;
434
313
  if (filename === HELPERS) return null;
435
- return transformCode(code, _objectSpread2(_objectSpread2({}, babelOptions), {}, {
314
+ return transformCode(code, {
315
+ ...babelOptions,
436
316
  filename
437
- }), overrides, customOptions, this, async transformOptions => {
317
+ }, overrides, customOptions, this, async transformOptions => {
438
318
  if (!skipPreflightCheck) {
439
319
  await preflightCheck(this, babelHelpers, transformOptions);
440
320
  }
441
-
442
321
  return babelHelpers === BUNDLED ? addBabelPlugin(transformOptions, importHelperPlugin) : transformOptions;
443
322
  });
444
323
  }
445
-
446
324
  };
447
325
  };
448
326
  }
449
-
450
327
  function getRecommendedFormat(rollupFormat) {
451
328
  switch (rollupFormat) {
452
329
  case 'amd':
453
330
  return 'amd';
454
-
455
331
  case 'iife':
456
332
  case 'umd':
457
333
  return 'umd';
458
-
459
334
  case 'system':
460
335
  return 'systemjs';
461
-
462
336
  default:
463
337
  return '<module format>';
464
338
  }
465
339
  }
466
-
467
340
  function createBabelOutputPluginFactory(customCallback = returnObject) {
468
341
  const overrides = customCallback(babel__namespace);
469
342
  return pluginOptions => {
@@ -473,7 +346,6 @@ function createBabelOutputPluginFactory(customCallback = returnObject) {
473
346
  } = getOptionsWithOverrides(pluginOptions, overrides);
474
347
  return {
475
348
  name: 'babel',
476
-
477
349
  renderStart(outputOptions) {
478
350
  const {
479
351
  extensions,
@@ -481,37 +353,42 @@ function createBabelOutputPluginFactory(customCallback = returnObject) {
481
353
  exclude,
482
354
  allowAllFormats
483
355
  } = pluginOptionsWithOverrides;
484
-
485
356
  if (extensions || include || exclude) {
486
357
  warnOnce(this, 'The "include", "exclude" and "extensions" options are ignored when transforming the output.');
487
358
  }
488
-
489
359
  if (!allowAllFormats && outputOptions.format !== 'es' && outputOptions.format !== 'cjs') {
490
360
  this.error(`Using Babel on the generated chunks is strongly discouraged for formats other than "esm" or "cjs" as it can easily break wrapper code and lead to accidentally created global variables. Instead, you should set "output.format" to "esm" and use Babel to transform to another format, e.g. by adding "presets: [['@babel/env', { modules: '${getRecommendedFormat(outputOptions.format)}' }]]" to your Babel options. If you still want to proceed, add "allowAllFormats: true" to your plugin options.`);
491
361
  }
492
362
  },
493
-
494
363
  renderChunk(code, chunk, outputOptions) {
495
364
  /* eslint-disable no-unused-vars */
496
- const _unpackOutputPluginOp = unpackOutputPluginOptions(pluginOptionsWithOverrides, outputOptions),
497
- babelOptions = _objectWithoutProperties(_unpackOutputPluginOp, ["allowAllFormats", "exclude", "extensions", "externalHelpers", "externalHelpersWhitelist", "include", "runtimeHelpers"]);
365
+ const {
366
+ allowAllFormats,
367
+ exclude,
368
+ extensions,
369
+ externalHelpers,
370
+ externalHelpersWhitelist,
371
+ include,
372
+ runtimeHelpers,
373
+ ...babelOptions
374
+ } = unpackOutputPluginOptions(pluginOptionsWithOverrides, outputOptions);
498
375
  /* eslint-enable no-unused-vars */
499
376
 
500
-
501
377
  return transformCode(code, babelOptions, overrides, customOptions, this);
502
378
  }
503
-
504
379
  };
505
380
  };
506
- } // export this for symmetry with output-related exports
507
-
381
+ }
508
382
 
383
+ // export this for symmetry with output-related exports
509
384
  const getBabelInputPlugin = createBabelInputPluginFactory();
510
385
  const getBabelOutputPlugin = createBabelOutputPluginFactory();
511
386
 
512
387
  exports.babel = getBabelInputPlugin;
513
388
  exports.createBabelInputPluginFactory = createBabelInputPluginFactory;
514
389
  exports.createBabelOutputPluginFactory = createBabelOutputPluginFactory;
515
- exports["default"] = getBabelInputPlugin;
390
+ exports.default = getBabelInputPlugin;
516
391
  exports.getBabelInputPlugin = getBabelInputPlugin;
517
392
  exports.getBabelOutputPlugin = getBabelOutputPlugin;
393
+ module.exports = Object.assign(exports.default, exports);
394
+ //# sourceMappingURL=index.js.map