@rollup/plugin-babel 5.3.1 → 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 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,96 +19,11 @@ 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';
@@ -142,9 +56,9 @@ function importHelperPlugin({
142
56
  }
143
57
 
144
58
  const addBabelPlugin = (options, plugin) => {
145
- return _objectSpread2(_objectSpread2({}, options), {}, {
59
+ return { ...options,
146
60
  plugins: options.plugins.concat(plugin)
147
- });
61
+ };
148
62
  };
149
63
  const warned = {};
150
64
  function warnOnce(ctx, msg) {
@@ -271,27 +185,26 @@ async function transformCode(inputCode, babelOptions, overrides, customOptions,
271
185
  };
272
186
  }
273
187
 
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({
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 {
287
199
  extensions,
288
200
  plugins: [],
289
- sourceMaps: sourcemap && sourcemaps && sourceMap && sourceMaps
290
- }, rest), {}, {
291
- caller: _objectSpread2({
292
- name: '@rollup/plugin-babel'
293
- }, rest.caller)
294
- });
201
+ sourceMaps: sourcemap && sourcemaps && sourceMap && sourceMaps,
202
+ ...rest,
203
+ caller: {
204
+ name: '@rollup/plugin-babel',
205
+ ...rest.caller
206
+ }
207
+ };
295
208
  };
296
209
 
297
210
  const warnAboutDeprecatedHelpersOption = ({
@@ -302,12 +215,10 @@ const warnAboutDeprecatedHelpersOption = ({
302
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`);
303
216
  };
304
217
 
305
- const unpackInputPluginOptions = (_ref2, rollupVersion) => {
306
- let {
307
- skipPreflightCheck = false
308
- } = _ref2,
309
- rest = _objectWithoutProperties(_ref2, ["skipPreflightCheck"]);
310
-
218
+ const unpackInputPluginOptions = ({
219
+ skipPreflightCheck = false,
220
+ ...rest
221
+ }, rollupVersion) => {
311
222
  if ('runtimeHelpers' in rest) {
312
223
  warnAboutDeprecatedHelpersOption({
313
224
  deprecatedOption: 'runtimeHelpers',
@@ -323,29 +234,31 @@ const unpackInputPluginOptions = (_ref2, rollupVersion) => {
323
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');
324
235
  }
325
236
 
326
- return unpackOptions(_objectSpread2(_objectSpread2({}, rest), {}, {
237
+ return unpackOptions({ ...rest,
327
238
  skipPreflightCheck,
328
239
  babelHelpers: rest.babelHelpers || BUNDLED,
329
- caller: _objectSpread2({
240
+ caller: {
330
241
  supportsStaticESM: true,
331
242
  supportsDynamicImport: true,
332
243
  supportsTopLevelAwait: true,
333
244
  // 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
- }));
245
+ supportsExportNamespaceFrom: !rollupVersion.match(/^1\.2[0-5]\./),
246
+ ...rest.caller
247
+ }
248
+ });
337
249
  };
338
250
 
339
251
  const unpackOutputPluginOptions = (options, {
340
252
  format
341
- }) => unpackOptions(_objectSpread2(_objectSpread2({
253
+ }) => unpackOptions({
342
254
  configFile: false,
343
- sourceType: format === 'es' ? 'module' : 'script'
344
- }, options), {}, {
345
- caller: _objectSpread2({
346
- supportsStaticESM: format === 'es'
347
- }, options.caller)
348
- }));
255
+ sourceType: format === 'es' ? 'module' : 'script',
256
+ ...options,
257
+ caller: {
258
+ supportsStaticESM: format === 'es',
259
+ ...options.caller
260
+ }
261
+ });
349
262
 
350
263
  function getOptionsWithOverrides(pluginOptions = {}, overrides = {}) {
351
264
  if (!overrides.options) return {
@@ -388,18 +301,15 @@ function createBabelInputPluginFactory(customCallback = returnObject) {
388
301
  let include;
389
302
  let extensions;
390
303
  let customFilter;
391
-
392
- var _unpackInputPluginOpt = unpackInputPluginOptions(pluginOptionsWithOverrides, this.meta.rollupVersion);
393
-
394
304
  ({
395
305
  exclude,
396
306
  extensions,
397
307
  babelHelpers,
398
308
  include,
399
309
  filter: customFilter,
400
- skipPreflightCheck
401
- } = _unpackInputPluginOpt);
402
- babelOptions = _objectWithoutProperties(_unpackInputPluginOpt, ["exclude", "extensions", "babelHelpers", "include", "filter", "skipPreflightCheck"]);
310
+ skipPreflightCheck,
311
+ ...babelOptions
312
+ } = unpackInputPluginOptions(pluginOptionsWithOverrides, this.meta.rollupVersion));
403
313
  const extensionRegExp = new RegExp(`(${extensions.map(escapeRegExpCharacters).join('|')})$`);
404
314
 
405
315
  if (customFilter && (include || exclude)) {
@@ -432,9 +342,9 @@ function createBabelInputPluginFactory(customCallback = returnObject) {
432
342
  transform(code, filename) {
433
343
  if (!filter(filename)) return null;
434
344
  if (filename === HELPERS) return null;
435
- return transformCode(code, _objectSpread2(_objectSpread2({}, babelOptions), {}, {
345
+ return transformCode(code, { ...babelOptions,
436
346
  filename
437
- }), overrides, customOptions, this, async transformOptions => {
347
+ }, overrides, customOptions, this, async transformOptions => {
438
348
  if (!skipPreflightCheck) {
439
349
  await preflightCheck(this, babelHelpers, transformOptions);
440
350
  }
@@ -493,11 +403,18 @@ function createBabelOutputPluginFactory(customCallback = returnObject) {
493
403
 
494
404
  renderChunk(code, chunk, outputOptions) {
495
405
  /* eslint-disable no-unused-vars */
496
- const _unpackOutputPluginOp = unpackOutputPluginOptions(pluginOptionsWithOverrides, outputOptions),
497
- babelOptions = _objectWithoutProperties(_unpackOutputPluginOp, ["allowAllFormats", "exclude", "extensions", "externalHelpers", "externalHelpersWhitelist", "include", "runtimeHelpers"]);
406
+ const {
407
+ allowAllFormats,
408
+ exclude,
409
+ extensions,
410
+ externalHelpers,
411
+ externalHelpersWhitelist,
412
+ include,
413
+ runtimeHelpers,
414
+ ...babelOptions
415
+ } = unpackOutputPluginOptions(pluginOptionsWithOverrides, outputOptions);
498
416
  /* eslint-enable no-unused-vars */
499
417
 
500
-
501
418
  return transformCode(code, babelOptions, overrides, customOptions, this);
502
419
  }
503
420
 
@@ -512,6 +429,8 @@ const getBabelOutputPlugin = createBabelOutputPluginFactory();
512
429
  exports.babel = getBabelInputPlugin;
513
430
  exports.createBabelInputPluginFactory = createBabelInputPluginFactory;
514
431
  exports.createBabelOutputPluginFactory = createBabelOutputPluginFactory;
515
- exports["default"] = getBabelInputPlugin;
432
+ exports.default = getBabelInputPlugin;
516
433
  exports.getBabelInputPlugin = getBabelInputPlugin;
517
434
  exports.getBabelOutputPlugin = getBabelOutputPlugin;
435
+ module.exports = Object.assign(exports.default, exports);
436
+ //# sourceMappingURL=index.js.map
@@ -2,91 +2,6 @@ import * as babel from '@babel/core';
2
2
  import { createFilter } from '@rollup/pluginutils';
3
3
  import { addNamed } from '@babel/helper-module-imports';
4
4
 
5
- function _defineProperty(obj, key, value) {
6
- if (key in obj) {
7
- Object.defineProperty(obj, key, {
8
- value: value,
9
- enumerable: true,
10
- configurable: true,
11
- writable: true
12
- });
13
- } else {
14
- obj[key] = value;
15
- }
16
-
17
- return obj;
18
- }
19
-
20
- function ownKeys(object, enumerableOnly) {
21
- var keys = Object.keys(object);
22
-
23
- if (Object.getOwnPropertySymbols) {
24
- var symbols = Object.getOwnPropertySymbols(object);
25
- if (enumerableOnly) symbols = symbols.filter(function (sym) {
26
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
27
- });
28
- keys.push.apply(keys, symbols);
29
- }
30
-
31
- return keys;
32
- }
33
-
34
- function _objectSpread2(target) {
35
- for (var i = 1; i < arguments.length; i++) {
36
- var source = arguments[i] != null ? arguments[i] : {};
37
-
38
- if (i % 2) {
39
- ownKeys(Object(source), true).forEach(function (key) {
40
- _defineProperty(target, key, source[key]);
41
- });
42
- } else if (Object.getOwnPropertyDescriptors) {
43
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
44
- } else {
45
- ownKeys(Object(source)).forEach(function (key) {
46
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
47
- });
48
- }
49
- }
50
-
51
- return target;
52
- }
53
-
54
- function _objectWithoutPropertiesLoose(source, excluded) {
55
- if (source == null) return {};
56
- var target = {};
57
- var sourceKeys = Object.keys(source);
58
- var key, i;
59
-
60
- for (i = 0; i < sourceKeys.length; i++) {
61
- key = sourceKeys[i];
62
- if (excluded.indexOf(key) >= 0) continue;
63
- target[key] = source[key];
64
- }
65
-
66
- return target;
67
- }
68
-
69
- function _objectWithoutProperties(source, excluded) {
70
- if (source == null) return {};
71
-
72
- var target = _objectWithoutPropertiesLoose(source, excluded);
73
-
74
- var key, i;
75
-
76
- if (Object.getOwnPropertySymbols) {
77
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
78
-
79
- for (i = 0; i < sourceSymbolKeys.length; i++) {
80
- key = sourceSymbolKeys[i];
81
- if (excluded.indexOf(key) >= 0) continue;
82
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
83
- target[key] = source[key];
84
- }
85
- }
86
-
87
- return target;
88
- }
89
-
90
5
  const BUNDLED = 'bundled';
91
6
  const INLINE = 'inline';
92
7
  const RUNTIME = 'runtime';
@@ -118,9 +33,9 @@ function importHelperPlugin({
118
33
  }
119
34
 
120
35
  const addBabelPlugin = (options, plugin) => {
121
- return _objectSpread2(_objectSpread2({}, options), {}, {
36
+ return { ...options,
122
37
  plugins: options.plugins.concat(plugin)
123
- });
38
+ };
124
39
  };
125
40
  const warned = {};
126
41
  function warnOnce(ctx, msg) {
@@ -247,27 +162,26 @@ async function transformCode(inputCode, babelOptions, overrides, customOptions,
247
162
  };
248
163
  }
249
164
 
250
- const unpackOptions = (_ref = {}) => {
251
- let {
252
- extensions = babel.DEFAULT_EXTENSIONS,
253
- // rollup uses sourcemap, babel uses sourceMaps
254
- // just normalize them here so people don't have to worry about it
255
- sourcemap = true,
256
- sourcemaps = true,
257
- sourceMap = true,
258
- sourceMaps = true
259
- } = _ref,
260
- rest = _objectWithoutProperties(_ref, ["extensions", "sourcemap", "sourcemaps", "sourceMap", "sourceMaps"]);
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
- }, rest), {}, {
267
- caller: _objectSpread2({
268
- name: '@rollup/plugin-babel'
269
- }, rest.caller)
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 = (_ref2, rollupVersion) => {
282
- let {
283
- skipPreflightCheck = false
284
- } = _ref2,
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(_objectSpread2(_objectSpread2({}, rest), {}, {
214
+ return unpackOptions({ ...rest,
303
215
  skipPreflightCheck,
304
216
  babelHelpers: rest.babelHelpers || BUNDLED,
305
- caller: _objectSpread2({
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
- }, rest.caller)
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(_objectSpread2(_objectSpread2({
230
+ }) => unpackOptions({
318
231
  configFile: false,
319
- sourceType: format === 'es' ? 'module' : 'script'
320
- }, options), {}, {
321
- caller: _objectSpread2({
322
- supportsStaticESM: format === 'es'
323
- }, options.caller)
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
- } = _unpackInputPluginOpt);
378
- babelOptions = _objectWithoutProperties(_unpackInputPluginOpt, ["exclude", "extensions", "babelHelpers", "include", "filter", "skipPreflightCheck"]);
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)) {
@@ -408,9 +319,9 @@ function createBabelInputPluginFactory(customCallback = returnObject) {
408
319
  transform(code, filename) {
409
320
  if (!filter(filename)) return null;
410
321
  if (filename === HELPERS) return null;
411
- return transformCode(code, _objectSpread2(_objectSpread2({}, babelOptions), {}, {
322
+ return transformCode(code, { ...babelOptions,
412
323
  filename
413
- }), overrides, customOptions, this, async transformOptions => {
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 _unpackOutputPluginOp = unpackOutputPluginOptions(pluginOptionsWithOverrides, outputOptions),
473
- babelOptions = _objectWithoutProperties(_unpackOutputPluginOp, ["allowAllFormats", "exclude", "extensions", "externalHelpers", "externalHelpersWhitelist", "include", "runtimeHelpers"]);
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
 
@@ -486,3 +404,4 @@ const getBabelInputPlugin = createBabelInputPluginFactory();
486
404
  const getBabelOutputPlugin = createBabelOutputPluginFactory();
487
405
 
488
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@rollup/plugin-babel",
3
- "version": "5.3.1",
3
+ "version": "6.0.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -13,10 +13,15 @@
13
13
  "author": "Rich Harris",
14
14
  "homepage": "https://github.com/rollup/plugins/tree/master/packages/babel#readme",
15
15
  "bugs": "https://github.com/rollup/plugins/issues",
16
- "main": "dist/index.js",
17
- "module": "dist/index.es.js",
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
+ },
18
23
  "engines": {
19
- "node": ">= 10.0.0"
24
+ "node": ">=14.0.0"
20
25
  },
21
26
  "scripts": {
22
27
  "build": "rollup -c",
@@ -27,12 +32,13 @@
27
32
  "prebuild": "del-cli dist",
28
33
  "prerelease": "pnpm build",
29
34
  "pretest": "pnpm build",
30
- "release": "pnpm plugin:release --workspace-root -- --pkg $npm_package_name",
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.10.4",
60
- "@rollup/pluginutils": "^3.1.0"
68
+ "@babel/helper-module-imports": "^7.18.6",
69
+ "@rollup/pluginutils": "^4.2.1"
61
70
  },
62
71
  "devDependencies": {
63
- "@babel/core": "^7.10.5",
64
- "@babel/plugin-external-helpers": "^7.10.4",
65
- "@babel/plugin-proposal-decorators": "^7.10.5",
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.10.5",
68
- "@babel/preset-env": "^7.10.4",
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": "^10.0.0",
79
+ "@rollup/plugin-node-resolve": "^14.1.0",
71
80
  "@types/babel__core": "^7.1.9",
72
- "rollup": "^2.67.3",
73
- "source-map": "^0.7.3"
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 minimatch 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.
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 minimatch 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.
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,292 +0,0 @@
1
- # @rollup/plugin-babel ChangeLog
2
-
3
- ## v5.3.1
4
-
5
- _2022-02-22_
6
-
7
- ### Bugfixes
8
-
9
- - fix: consider path delimeter on windows (#1090)
10
-
11
- ## v5.3.0
12
-
13
- _2021-02-14_
14
-
15
- ### Features
16
-
17
- - feat: add custom filter option (#767)
18
- - feat: pass rollup context as this context into override config function (#784)
19
-
20
- ### Updates
21
-
22
- - docs: typo in README.md (#800)
23
- - chore: commit updated readme format (bfda6d8)
24
-
25
- ## v5.2.3
26
-
27
- _2021-01-29_
28
-
29
- ### Updates
30
-
31
- - docs: add usage with commonjs. fixes #622 (6b4b7b6)
32
- - docs: update export in README (#690)
33
-
34
- ## v5.2.2
35
-
36
- _2020-11-30_
37
-
38
- ### Bugfixes
39
-
40
- - fix: clone cached helper identifier before returning it (#584)
41
- - fix: strip hash and query param in extension filter (#533)
42
-
43
- ## v5.2.1
44
-
45
- _2020-09-09_
46
-
47
- ### Updates
48
-
49
- - chore: add deprecation/migration warnings for the runtime (#534)
50
-
51
- ## v5.2.0
52
-
53
- _2020-08-13_
54
-
55
- ### Features
56
-
57
- - feat: `export * as ns` support (#511)
58
-
59
- ### Updates
60
-
61
- - chore: update dependencies (13526d6)
62
-
63
- ## v5.1.0
64
-
65
- _2020-07-12_
66
-
67
- ### Features
68
-
69
- - feat: add typings (#462)
70
-
71
- ### Updates
72
-
73
- - docs: add note about excluding @babel/runtime helpers via regex (#483)
74
-
75
- ## v5.0.4
76
-
77
- _2020-06-22_
78
-
79
- ### Updates
80
-
81
- - docs: remove unused import in "Usage" example (#460)
82
- - docs: update node requirement in readme (#443)
83
- - docs: fix typo in readme (#447)
84
-
85
- ## v5.0.3
86
-
87
- _2020-06-05_
88
-
89
- ### Updates
90
-
91
- - docs: update `babelHelpers` description (#397)
92
-
93
- ## v5.0.2
94
-
95
- _2020-05-20_
96
-
97
- ### Bugfixes
98
-
99
- - fix: use loadPartialConfigAsync when it is available (#359)
100
-
101
- ### Updates
102
-
103
- - docs: Cleanup misleading leftovers in the README (#377)
104
- - docs: correct breaking change note in v5 CHANGELOG (#368)
105
-
106
- ## v5.0.1
107
-
108
- _2020-05-20_
109
-
110
- ### Bugfixes
111
-
112
- - fix: use loadPartialConfigAsync when it is available (#359)
113
-
114
- ### Updates
115
-
116
- - docs: Cleanup misleading leftovers in the README (#377)
117
- - docs: correct breaking change note in v5 CHANGELOG (#368)
118
-
119
- # @rollup/plugin-babel changelog
120
-
121
- ## 5.0.0
122
-
123
- _2020-04-27_
124
-
125
- ### Features
126
-
127
- - Added `getBabelOutputPlugin` and `createBabelOutputPluginFactory` exports which can be used to transform generated code
128
- - 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.
129
- - Published as `@rollup/plugin-babel`
130
-
131
- ### Updates
132
-
133
- - Default export exported as `getBabelInputPlugin` for symmetry with `getBabelOutputPlugin`
134
-
135
- ### Breaking Changes
136
-
137
- - Minimum compatible Rollup version is 1.2.0
138
- - Minimum supported Node version is 10.0.0
139
- - `.custom` factory is now available as separate `createBabelInputPluginFactory` export
140
- - 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.
141
-
142
- ## 4.3.2
143
-
144
- - Fixed usage with `externalHelpers: true` option
145
-
146
- ## 4.3.1
147
-
148
- - Add `.js` extension to the virtual babel helpers file (only matters when using `preserveModules` option in rollup)
149
-
150
- ## 4.3.0
151
-
152
- - Added `.custom` builder.
153
- - Fail build when a plugin tries to add non existent babel helper
154
-
155
- ## 4.2.0
156
-
157
- Allow `rollup@1` as peer dependency.
158
-
159
- ## 4.1.0
160
-
161
- - Fixed "preflight check" for ignored files.
162
- - Return `null` when no transformation has been done (fixing source maps for this case)
163
-
164
- ## 4.0.3
165
-
166
- Fixed fallback class transform in "preflight check".
167
-
168
- ## 4.0.2
169
-
170
- Fixed `rollup` peer dependency.
171
-
172
- ## 4.0.0
173
-
174
- Babel 7 compatible! (dropped Babel 6 compatibility though).
175
-
176
- Additionally:
177
-
178
- - 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
179
- - 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.
180
-
181
- ## 3.0.3
182
-
183
- - Drop babel7 support. Use 4.0.0-beta if you use babel 7
184
- - Use "module" in addition to "jsnext:main" ([#150](https://github.com/rollup/rollup-plugin-babel/issues/150))
185
- - Remove unused babel helpers namespace declaration & expression ([#164](https://github.com/rollup/rollup-plugin-babel/issues/164))
186
-
187
- ## 3.0.2
188
-
189
- - Fix regression with Babel 6 ([#158](https://github.com/rollup/rollup-plugin-babel/issues/158))
190
-
191
- ## 3.0.1
192
-
193
- - Wasn't working, fix bug with transform (not using es2015-classes for preflight check)
194
-
195
- ## 3.0.0
196
-
197
- - Drop Node 0.10/0.12 (Use native `Object.assign`)
198
- - Change `babel-core` to be a peerDependency
199
- - Support `babel-core` v7 as well as a peerDep (no changes necessary)
200
-
201
- ## 2.7.1
202
-
203
- - Prevent erroneous warnings about duplicated runtime helpers ([#105](https://github.com/rollup/rollup-plugin-babel/issues/105))
204
- - Ignore `ignore` option in preflight check ([#102](https://github.com/rollup/rollup-plugin-babel/issues/102))
205
- - Allow custom `moduleName` with `runtime-helpers` ([#95](https://github.com/rollup/rollup-plugin-babel/issues/95))
206
-
207
- ## 2.7.0
208
-
209
- - Add `externalHelpersWhitelist` option ([#92](https://github.com/rollup/rollup-plugin-babel/pull/92))
210
- - Ignore `only` option during preflight checks ([#98](https://github.com/rollup/rollup-plugin-babel/issues/98))
211
- - Use `options.onwarn` if available ([#84](https://github.com/rollup/rollup-plugin-babel/issues/84))
212
- - Update documentation and dependencies
213
-
214
- ## 2.6.1
215
-
216
- - Return a `name`
217
-
218
- ## 2.6.0
219
-
220
- - Use `\0` convention for helper module ID ([#64](https://github.com/rollup/rollup-plugin-babel/issues/64))
221
-
222
- ## 2.5.1
223
-
224
- - Don't mutate `options.plugins` ([#47](https://github.com/rollup/rollup-plugin-babel/issues/47))
225
-
226
- ## 2.5.0
227
-
228
- - Import `babelHelpers` rather than injecting them – allows `transform` function to be pure ([#rollup/658](https://github.com/rollup/rollup/pull/658#issuecomment-223876824))
229
-
230
- ## 2.4.0
231
-
232
- - Add `externalHelpers` option ([#41](https://github.com/rollup/rollup-plugin-babel/pull/41))
233
-
234
- ## 2.3.9
235
-
236
- - Do not rename Babel helpers ([#34](https://github.com/rollup/rollup-plugin-babel/pull/34))
237
-
238
- ## 2.3.8
239
-
240
- - Create new version to (hopefully) solve bizarre CI issue
241
-
242
- ## 2.3.7
243
-
244
- - Be less clever about renaming Babel helpers ([#19](https://github.com/rollup/rollup-plugin-babel/issues/19))
245
-
246
- ## 2.3.6
247
-
248
- - Fix cache misses in preflight check ([#29](https://github.com/rollup/rollup-plugin-babel/pull/29))
249
-
250
- ## 2.3.5
251
-
252
- - Use class transformer local to plugin, not project being built
253
-
254
- ## 2.3.4
255
-
256
- - 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))
257
-
258
- ## 2.3.3
259
-
260
- - Fix helper renaming ([#22](https://github.com/rollup/rollup-plugin-babel/issues/22))
261
-
262
- ## 2.3.1-2
263
-
264
- - Include correct files in npm package
265
-
266
- ## 2.3.0
267
-
268
- - Allow `transform-runtime` Babel plugin, if combined with `runtimeHelpers: true` option ([#17](https://github.com/rollup/rollup-plugin-babel/issues/17))
269
- - More permissive handling of helpers – only warn if inline helpers are duplicated
270
- - Handle plugins that change export patterns ([#18](https://github.com/rollup/rollup-plugin-babel/issues/18))
271
-
272
- ## 2.2.0
273
-
274
- - Preflight checks are run per-file, to avoid configuration snafus ([#16](https://github.com/rollup/rollup-plugin-babel/issues/16))
275
-
276
- ## 2.1.0
277
-
278
- - Generate sourcemaps by default
279
-
280
- ## 2.0.1
281
-
282
- - Use object-assign ponyfill
283
- - Add travis support
284
- - Fix test
285
-
286
- ## 2.0.0
287
-
288
- - Babel 6 compatible
289
-
290
- ## 1.0.0
291
-
292
- - First release