@rollup/plugin-babel 5.1.0 → 5.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/README.md +19 -5
- package/dist/index.es.js +70 -26
- package/dist/index.js +94 -28
- package/package.json +25 -21
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# @rollup/plugin-babel ChangeLog
|
|
2
2
|
|
|
3
|
+
## v5.2.3
|
|
4
|
+
|
|
5
|
+
_2021-01-29_
|
|
6
|
+
|
|
7
|
+
### Updates
|
|
8
|
+
|
|
9
|
+
- docs: add usage with commonjs. fixes #622 (6b4b7b6)
|
|
10
|
+
- docs: update export in README (#690)
|
|
11
|
+
|
|
12
|
+
## v5.2.2
|
|
13
|
+
|
|
14
|
+
_2020-11-30_
|
|
15
|
+
|
|
16
|
+
### Bugfixes
|
|
17
|
+
|
|
18
|
+
- fix: clone cached helper identifier before returning it (#584)
|
|
19
|
+
- fix: strip hash and query param in extension filter (#533)
|
|
20
|
+
|
|
21
|
+
## v5.2.1
|
|
22
|
+
|
|
23
|
+
_2020-09-09_
|
|
24
|
+
|
|
25
|
+
### Updates
|
|
26
|
+
|
|
27
|
+
- chore: add deprecation/migration warnings for the runtime (#534)
|
|
28
|
+
|
|
29
|
+
## v5.2.0
|
|
30
|
+
|
|
31
|
+
_2020-08-13_
|
|
32
|
+
|
|
33
|
+
### Features
|
|
34
|
+
|
|
35
|
+
- feat: `export * as ns` support (#511)
|
|
36
|
+
|
|
37
|
+
### Updates
|
|
38
|
+
|
|
39
|
+
- chore: update dependencies (13526d6)
|
|
40
|
+
|
|
3
41
|
## v5.1.0
|
|
4
42
|
|
|
5
43
|
_2020-07-12_
|
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@ npm install @rollup/plugin-babel --save-dev
|
|
|
39
39
|
Create a `rollup.config.js` [configuration file](https://www.rollupjs.org/guide/en/#configuration-files) and import the plugin:
|
|
40
40
|
|
|
41
41
|
```js
|
|
42
|
-
import babel from '@rollup/plugin-babel';
|
|
42
|
+
import { babel } from '@rollup/plugin-babel';
|
|
43
43
|
|
|
44
44
|
const config = {
|
|
45
45
|
input: 'src/index.js',
|
|
@@ -55,6 +55,23 @@ export default config;
|
|
|
55
55
|
|
|
56
56
|
Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api).
|
|
57
57
|
|
|
58
|
+
### Using With `@rollup/plugin-commonjs`
|
|
59
|
+
|
|
60
|
+
When using `@rollup/plugin-babel` with `@rollup/plugin-commonjs` in the same Rollup configuration, it's important to note that `@rollup/plugin-commonjs` _must_ be placed before this plugin in the `plugins` array for the two to work together properly. e.g.
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
import { babel } from '@rollup/plugin-babel';
|
|
64
|
+
import commonjs from '@rollup/plugin-commonjs';
|
|
65
|
+
|
|
66
|
+
const config = {
|
|
67
|
+
...
|
|
68
|
+
plugins: [
|
|
69
|
+
commonjs(),
|
|
70
|
+
babel({ babelHelpers: 'bundled' })
|
|
71
|
+
],
|
|
72
|
+
};
|
|
73
|
+
```
|
|
74
|
+
|
|
58
75
|
## Options
|
|
59
76
|
|
|
60
77
|
This plugin respects Babel [configuration files](https://babeljs.io/docs/en/configuration) by default and they are generally the best place to put your configuration.
|
|
@@ -314,10 +331,7 @@ export default createBabelInputPluginFactory(babelCore => {
|
|
|
314
331
|
};
|
|
315
332
|
},
|
|
316
333
|
|
|
317
|
-
config(
|
|
318
|
-
cfg /* Passed Babel's 'PartialConfig' object. */,
|
|
319
|
-
{ code, customOptions }
|
|
320
|
-
) {
|
|
334
|
+
config(cfg /* Passed Babel's 'PartialConfig' object. */, { code, customOptions }) {
|
|
321
335
|
if (cfg.hasFilesystemConfig()) {
|
|
322
336
|
// Use the normal config
|
|
323
337
|
return cfg.options;
|
package/dist/index.es.js
CHANGED
|
@@ -96,7 +96,9 @@ const EXTERNAL = 'external'; // NOTE: DO NOT REMOVE the null character `\0` as i
|
|
|
96
96
|
|
|
97
97
|
const HELPERS = '\0rollupPluginBabelHelpers.js';
|
|
98
98
|
|
|
99
|
-
function importHelperPlugin(
|
|
99
|
+
function importHelperPlugin({
|
|
100
|
+
types: t
|
|
101
|
+
}) {
|
|
100
102
|
return {
|
|
101
103
|
pre(file) {
|
|
102
104
|
const cachedHelpers = {};
|
|
@@ -106,7 +108,7 @@ function importHelperPlugin() {
|
|
|
106
108
|
}
|
|
107
109
|
|
|
108
110
|
if (cachedHelpers[name]) {
|
|
109
|
-
return cachedHelpers[name];
|
|
111
|
+
return t.cloneNode(cachedHelpers[name]);
|
|
110
112
|
}
|
|
111
113
|
|
|
112
114
|
return cachedHelpers[name] = addNamed(file.path, name, HELPERS);
|
|
@@ -117,7 +119,7 @@ function importHelperPlugin() {
|
|
|
117
119
|
}
|
|
118
120
|
|
|
119
121
|
const addBabelPlugin = (options, plugin) => {
|
|
120
|
-
return _objectSpread2({}, options, {
|
|
122
|
+
return _objectSpread2(_objectSpread2({}, options), {}, {
|
|
121
123
|
plugins: options.plugins.concat(plugin)
|
|
122
124
|
});
|
|
123
125
|
};
|
|
@@ -129,6 +131,16 @@ function warnOnce(ctx, msg) {
|
|
|
129
131
|
}
|
|
130
132
|
const regExpCharactersRegExp = /[\\^$.*+?()[\]{}|]/g;
|
|
131
133
|
const escapeRegExpCharacters = str => str.replace(regExpCharactersRegExp, '\\$&');
|
|
134
|
+
function stripQuery(id) {
|
|
135
|
+
// strip query params from import
|
|
136
|
+
const [bareId, query] = id.split('?');
|
|
137
|
+
const suffix = `${query ? `?${query}` : ''}`;
|
|
138
|
+
return {
|
|
139
|
+
bareId,
|
|
140
|
+
query,
|
|
141
|
+
suffix
|
|
142
|
+
};
|
|
143
|
+
}
|
|
132
144
|
|
|
133
145
|
const MODULE_ERROR = 'Rollup requires that your Babel configuration keeps ES6 module syntax intact. ' + 'Unfortunately it looks like your configuration specifies a module transformer ' + 'to replace ES6 modules with another module format. To continue you have to disable it.' + '\n\n' + "Most commonly it's a CommonJS transform added by @babel/preset-env - " + 'in such case you should disable it by adding `modules: false` option to that preset ' + '(described in more detail here - https://github.com/rollup/plugins/tree/master/packages/babel#modules ).';
|
|
134
146
|
const UNEXPECTED_ERROR = 'An unexpected situation arose. Please raise an issue at ' + 'https://github.com/rollup/plugins/issues. Thanks!';
|
|
@@ -247,45 +259,65 @@ const unpackOptions = (_ref = {}) => {
|
|
|
247
259
|
} = _ref,
|
|
248
260
|
rest = _objectWithoutProperties(_ref, ["extensions", "sourcemap", "sourcemaps", "sourceMap", "sourceMaps"]);
|
|
249
261
|
|
|
250
|
-
return _objectSpread2({
|
|
262
|
+
return _objectSpread2(_objectSpread2({
|
|
251
263
|
extensions,
|
|
252
264
|
plugins: [],
|
|
253
265
|
sourceMaps: sourcemap && sourcemaps && sourceMap && sourceMaps
|
|
254
|
-
}, rest, {
|
|
266
|
+
}, rest), {}, {
|
|
255
267
|
caller: _objectSpread2({
|
|
256
268
|
name: '@rollup/plugin-babel'
|
|
257
269
|
}, rest.caller)
|
|
258
270
|
});
|
|
259
271
|
};
|
|
260
272
|
|
|
261
|
-
const
|
|
273
|
+
const warnAboutDeprecatedHelpersOption = ({
|
|
274
|
+
deprecatedOption,
|
|
275
|
+
suggestion
|
|
276
|
+
}) => {
|
|
277
|
+
// eslint-disable-next-line no-console
|
|
278
|
+
console.warn(`\`${deprecatedOption}\` has been removed in favor a \`babelHelpers\` option. Try changing your configuration to \`${suggestion}\`. ` + `Refer to the documentation to learn more: https://github.com/rollup/plugins/tree/master/packages/babel#babelhelpers`);
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
const unpackInputPluginOptions = (_ref2, rollupVersion) => {
|
|
262
282
|
let {
|
|
263
283
|
skipPreflightCheck = false
|
|
264
284
|
} = _ref2,
|
|
265
285
|
rest = _objectWithoutProperties(_ref2, ["skipPreflightCheck"]);
|
|
266
286
|
|
|
267
|
-
if (
|
|
287
|
+
if ('runtimeHelpers' in rest) {
|
|
288
|
+
warnAboutDeprecatedHelpersOption({
|
|
289
|
+
deprecatedOption: 'runtimeHelpers',
|
|
290
|
+
suggestion: `babelHelpers: 'runtime'`
|
|
291
|
+
});
|
|
292
|
+
} else if ('externalHelpers' in rest) {
|
|
293
|
+
warnAboutDeprecatedHelpersOption({
|
|
294
|
+
deprecatedOption: 'externalHelpers',
|
|
295
|
+
suggestion: `babelHelpers: 'external'`
|
|
296
|
+
});
|
|
297
|
+
} else if (!rest.babelHelpers) {
|
|
268
298
|
// eslint-disable-next-line no-console
|
|
269
299
|
console.warn("babelHelpers: 'bundled' option was used by default. It is recommended to configure this option explicitly, read more here: " + 'https://github.com/rollup/plugins/tree/master/packages/babel#babelhelpers');
|
|
270
300
|
}
|
|
271
301
|
|
|
272
|
-
return unpackOptions(_objectSpread2({}, rest, {
|
|
302
|
+
return unpackOptions(_objectSpread2(_objectSpread2({}, rest), {}, {
|
|
273
303
|
skipPreflightCheck,
|
|
274
304
|
babelHelpers: rest.babelHelpers || BUNDLED,
|
|
275
305
|
caller: _objectSpread2({
|
|
276
306
|
supportsStaticESM: true,
|
|
277
307
|
supportsDynamicImport: true,
|
|
278
|
-
supportsTopLevelAwait: true
|
|
308
|
+
supportsTopLevelAwait: true,
|
|
309
|
+
// todo: remove version checks for 1.20 - 1.25 when we bump peer deps
|
|
310
|
+
supportsExportNamespaceFrom: !rollupVersion.match(/^1\.2[0-5]\./)
|
|
279
311
|
}, rest.caller)
|
|
280
312
|
}));
|
|
281
313
|
};
|
|
282
314
|
|
|
283
315
|
const unpackOutputPluginOptions = (options, {
|
|
284
316
|
format
|
|
285
|
-
}) => unpackOptions(_objectSpread2({
|
|
317
|
+
}) => unpackOptions(_objectSpread2(_objectSpread2({
|
|
286
318
|
configFile: false,
|
|
287
319
|
sourceType: format === 'es' ? 'module' : 'script'
|
|
288
|
-
}, options, {
|
|
320
|
+
}, options), {}, {
|
|
289
321
|
caller: _objectSpread2({
|
|
290
322
|
supportsStaticESM: format === 'es'
|
|
291
323
|
}, options.caller)
|
|
@@ -319,24 +351,36 @@ function createBabelInputPluginFactory(customCallback = returnObject) {
|
|
|
319
351
|
customOptions,
|
|
320
352
|
pluginOptionsWithOverrides
|
|
321
353
|
} = getOptionsWithOverrides(pluginOptions, overrides);
|
|
354
|
+
let babelHelpers;
|
|
355
|
+
let babelOptions;
|
|
356
|
+
let filter;
|
|
357
|
+
let skipPreflightCheck;
|
|
358
|
+
return {
|
|
359
|
+
name: 'babel',
|
|
360
|
+
|
|
361
|
+
options() {
|
|
362
|
+
// todo: remove options hook and hoist declarations when version checks are removed
|
|
363
|
+
let exclude;
|
|
364
|
+
let include;
|
|
365
|
+
let extensions;
|
|
322
366
|
|
|
323
|
-
|
|
324
|
-
{
|
|
325
|
-
exclude,
|
|
326
|
-
extensions,
|
|
327
|
-
babelHelpers,
|
|
328
|
-
include,
|
|
329
|
-
skipPreflightCheck
|
|
330
|
-
} = _unpackInputPluginOpt,
|
|
331
|
-
babelOptions = _objectWithoutProperties(_unpackInputPluginOpt, ["exclude", "extensions", "babelHelpers", "include", "skipPreflightCheck"]);
|
|
367
|
+
var _unpackInputPluginOpt = unpackInputPluginOptions(pluginOptionsWithOverrides, this.meta.rollupVersion);
|
|
332
368
|
|
|
333
|
-
|
|
334
|
-
|
|
369
|
+
({
|
|
370
|
+
exclude,
|
|
371
|
+
extensions,
|
|
372
|
+
babelHelpers,
|
|
373
|
+
include,
|
|
374
|
+
skipPreflightCheck
|
|
375
|
+
} = _unpackInputPluginOpt);
|
|
376
|
+
babelOptions = _objectWithoutProperties(_unpackInputPluginOpt, ["exclude", "extensions", "babelHelpers", "include", "skipPreflightCheck"]);
|
|
377
|
+
const extensionRegExp = new RegExp(`(${extensions.map(escapeRegExpCharacters).join('|')})$`);
|
|
378
|
+
const includeExcludeFilter = createFilter(include, exclude);
|
|
335
379
|
|
|
336
|
-
|
|
380
|
+
filter = id => extensionRegExp.test(stripQuery(id).bareId) && includeExcludeFilter(id);
|
|
337
381
|
|
|
338
|
-
|
|
339
|
-
|
|
382
|
+
return null;
|
|
383
|
+
},
|
|
340
384
|
|
|
341
385
|
resolveId(id) {
|
|
342
386
|
if (id !== HELPERS) {
|
|
@@ -357,7 +401,7 @@ function createBabelInputPluginFactory(customCallback = returnObject) {
|
|
|
357
401
|
transform(code, filename) {
|
|
358
402
|
if (!filter(filename)) return null;
|
|
359
403
|
if (filename === HELPERS) return null;
|
|
360
|
-
return transformCode(code, _objectSpread2({}, babelOptions, {
|
|
404
|
+
return transformCode(code, _objectSpread2(_objectSpread2({}, babelOptions), {}, {
|
|
361
405
|
filename
|
|
362
406
|
}), overrides, customOptions, this, async transformOptions => {
|
|
363
407
|
if (!skipPreflightCheck) {
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,28 @@ var babel = require('@babel/core');
|
|
|
6
6
|
var pluginutils = require('@rollup/pluginutils');
|
|
7
7
|
var helperModuleImports = require('@babel/helper-module-imports');
|
|
8
8
|
|
|
9
|
+
function _interopNamespace(e) {
|
|
10
|
+
if (e && e.__esModule) return e;
|
|
11
|
+
var n = Object.create(null);
|
|
12
|
+
if (e) {
|
|
13
|
+
Object.keys(e).forEach(function (k) {
|
|
14
|
+
if (k !== 'default') {
|
|
15
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () {
|
|
19
|
+
return e[k];
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
n['default'] = e;
|
|
26
|
+
return Object.freeze(n);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
var babel__namespace = /*#__PURE__*/_interopNamespace(babel);
|
|
30
|
+
|
|
9
31
|
function _defineProperty(obj, key, value) {
|
|
10
32
|
if (key in obj) {
|
|
11
33
|
Object.defineProperty(obj, key, {
|
|
@@ -99,7 +121,9 @@ const EXTERNAL = 'external'; // NOTE: DO NOT REMOVE the null character `\0` as i
|
|
|
99
121
|
|
|
100
122
|
const HELPERS = '\0rollupPluginBabelHelpers.js';
|
|
101
123
|
|
|
102
|
-
function importHelperPlugin(
|
|
124
|
+
function importHelperPlugin({
|
|
125
|
+
types: t
|
|
126
|
+
}) {
|
|
103
127
|
return {
|
|
104
128
|
pre(file) {
|
|
105
129
|
const cachedHelpers = {};
|
|
@@ -109,7 +133,7 @@ function importHelperPlugin() {
|
|
|
109
133
|
}
|
|
110
134
|
|
|
111
135
|
if (cachedHelpers[name]) {
|
|
112
|
-
return cachedHelpers[name];
|
|
136
|
+
return t.cloneNode(cachedHelpers[name]);
|
|
113
137
|
}
|
|
114
138
|
|
|
115
139
|
return cachedHelpers[name] = helperModuleImports.addNamed(file.path, name, HELPERS);
|
|
@@ -120,7 +144,7 @@ function importHelperPlugin() {
|
|
|
120
144
|
}
|
|
121
145
|
|
|
122
146
|
const addBabelPlugin = (options, plugin) => {
|
|
123
|
-
return _objectSpread2({}, options, {
|
|
147
|
+
return _objectSpread2(_objectSpread2({}, options), {}, {
|
|
124
148
|
plugins: options.plugins.concat(plugin)
|
|
125
149
|
});
|
|
126
150
|
};
|
|
@@ -132,6 +156,16 @@ function warnOnce(ctx, msg) {
|
|
|
132
156
|
}
|
|
133
157
|
const regExpCharactersRegExp = /[\\^$.*+?()[\]{}|]/g;
|
|
134
158
|
const escapeRegExpCharacters = str => str.replace(regExpCharactersRegExp, '\\$&');
|
|
159
|
+
function stripQuery(id) {
|
|
160
|
+
// strip query params from import
|
|
161
|
+
const [bareId, query] = id.split('?');
|
|
162
|
+
const suffix = `${query ? `?${query}` : ''}`;
|
|
163
|
+
return {
|
|
164
|
+
bareId,
|
|
165
|
+
query,
|
|
166
|
+
suffix
|
|
167
|
+
};
|
|
168
|
+
}
|
|
135
169
|
|
|
136
170
|
const MODULE_ERROR = 'Rollup requires that your Babel configuration keeps ES6 module syntax intact. ' + 'Unfortunately it looks like your configuration specifies a module transformer ' + 'to replace ES6 modules with another module format. To continue you have to disable it.' + '\n\n' + "Most commonly it's a CommonJS transform added by @babel/preset-env - " + 'in such case you should disable it by adding `modules: false` option to that preset ' + '(described in more detail here - https://github.com/rollup/plugins/tree/master/packages/babel#modules ).';
|
|
137
171
|
const UNEXPECTED_ERROR = 'An unexpected situation arose. Please raise an issue at ' + 'https://github.com/rollup/plugins/issues. Thanks!';
|
|
@@ -250,45 +284,65 @@ const unpackOptions = (_ref = {}) => {
|
|
|
250
284
|
} = _ref,
|
|
251
285
|
rest = _objectWithoutProperties(_ref, ["extensions", "sourcemap", "sourcemaps", "sourceMap", "sourceMaps"]);
|
|
252
286
|
|
|
253
|
-
return _objectSpread2({
|
|
287
|
+
return _objectSpread2(_objectSpread2({
|
|
254
288
|
extensions,
|
|
255
289
|
plugins: [],
|
|
256
290
|
sourceMaps: sourcemap && sourcemaps && sourceMap && sourceMaps
|
|
257
|
-
}, rest, {
|
|
291
|
+
}, rest), {}, {
|
|
258
292
|
caller: _objectSpread2({
|
|
259
293
|
name: '@rollup/plugin-babel'
|
|
260
294
|
}, rest.caller)
|
|
261
295
|
});
|
|
262
296
|
};
|
|
263
297
|
|
|
264
|
-
const
|
|
298
|
+
const warnAboutDeprecatedHelpersOption = ({
|
|
299
|
+
deprecatedOption,
|
|
300
|
+
suggestion
|
|
301
|
+
}) => {
|
|
302
|
+
// eslint-disable-next-line no-console
|
|
303
|
+
console.warn(`\`${deprecatedOption}\` has been removed in favor a \`babelHelpers\` option. Try changing your configuration to \`${suggestion}\`. ` + `Refer to the documentation to learn more: https://github.com/rollup/plugins/tree/master/packages/babel#babelhelpers`);
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
const unpackInputPluginOptions = (_ref2, rollupVersion) => {
|
|
265
307
|
let {
|
|
266
308
|
skipPreflightCheck = false
|
|
267
309
|
} = _ref2,
|
|
268
310
|
rest = _objectWithoutProperties(_ref2, ["skipPreflightCheck"]);
|
|
269
311
|
|
|
270
|
-
if (
|
|
312
|
+
if ('runtimeHelpers' in rest) {
|
|
313
|
+
warnAboutDeprecatedHelpersOption({
|
|
314
|
+
deprecatedOption: 'runtimeHelpers',
|
|
315
|
+
suggestion: `babelHelpers: 'runtime'`
|
|
316
|
+
});
|
|
317
|
+
} else if ('externalHelpers' in rest) {
|
|
318
|
+
warnAboutDeprecatedHelpersOption({
|
|
319
|
+
deprecatedOption: 'externalHelpers',
|
|
320
|
+
suggestion: `babelHelpers: 'external'`
|
|
321
|
+
});
|
|
322
|
+
} else if (!rest.babelHelpers) {
|
|
271
323
|
// eslint-disable-next-line no-console
|
|
272
324
|
console.warn("babelHelpers: 'bundled' option was used by default. It is recommended to configure this option explicitly, read more here: " + 'https://github.com/rollup/plugins/tree/master/packages/babel#babelhelpers');
|
|
273
325
|
}
|
|
274
326
|
|
|
275
|
-
return unpackOptions(_objectSpread2({}, rest, {
|
|
327
|
+
return unpackOptions(_objectSpread2(_objectSpread2({}, rest), {}, {
|
|
276
328
|
skipPreflightCheck,
|
|
277
329
|
babelHelpers: rest.babelHelpers || BUNDLED,
|
|
278
330
|
caller: _objectSpread2({
|
|
279
331
|
supportsStaticESM: true,
|
|
280
332
|
supportsDynamicImport: true,
|
|
281
|
-
supportsTopLevelAwait: true
|
|
333
|
+
supportsTopLevelAwait: true,
|
|
334
|
+
// todo: remove version checks for 1.20 - 1.25 when we bump peer deps
|
|
335
|
+
supportsExportNamespaceFrom: !rollupVersion.match(/^1\.2[0-5]\./)
|
|
282
336
|
}, rest.caller)
|
|
283
337
|
}));
|
|
284
338
|
};
|
|
285
339
|
|
|
286
340
|
const unpackOutputPluginOptions = (options, {
|
|
287
341
|
format
|
|
288
|
-
}) => unpackOptions(_objectSpread2({
|
|
342
|
+
}) => unpackOptions(_objectSpread2(_objectSpread2({
|
|
289
343
|
configFile: false,
|
|
290
344
|
sourceType: format === 'es' ? 'module' : 'script'
|
|
291
|
-
}, options, {
|
|
345
|
+
}, options), {}, {
|
|
292
346
|
caller: _objectSpread2({
|
|
293
347
|
supportsStaticESM: format === 'es'
|
|
294
348
|
}, options.caller)
|
|
@@ -316,30 +370,42 @@ const returnObject = () => {
|
|
|
316
370
|
};
|
|
317
371
|
|
|
318
372
|
function createBabelInputPluginFactory(customCallback = returnObject) {
|
|
319
|
-
const overrides = customCallback(
|
|
373
|
+
const overrides = customCallback(babel__namespace);
|
|
320
374
|
return pluginOptions => {
|
|
321
375
|
const {
|
|
322
376
|
customOptions,
|
|
323
377
|
pluginOptionsWithOverrides
|
|
324
378
|
} = getOptionsWithOverrides(pluginOptions, overrides);
|
|
379
|
+
let babelHelpers;
|
|
380
|
+
let babelOptions;
|
|
381
|
+
let filter;
|
|
382
|
+
let skipPreflightCheck;
|
|
383
|
+
return {
|
|
384
|
+
name: 'babel',
|
|
385
|
+
|
|
386
|
+
options() {
|
|
387
|
+
// todo: remove options hook and hoist declarations when version checks are removed
|
|
388
|
+
let exclude;
|
|
389
|
+
let include;
|
|
390
|
+
let extensions;
|
|
325
391
|
|
|
326
|
-
|
|
327
|
-
{
|
|
328
|
-
exclude,
|
|
329
|
-
extensions,
|
|
330
|
-
babelHelpers,
|
|
331
|
-
include,
|
|
332
|
-
skipPreflightCheck
|
|
333
|
-
} = _unpackInputPluginOpt,
|
|
334
|
-
babelOptions = _objectWithoutProperties(_unpackInputPluginOpt, ["exclude", "extensions", "babelHelpers", "include", "skipPreflightCheck"]);
|
|
392
|
+
var _unpackInputPluginOpt = unpackInputPluginOptions(pluginOptionsWithOverrides, this.meta.rollupVersion);
|
|
335
393
|
|
|
336
|
-
|
|
337
|
-
|
|
394
|
+
({
|
|
395
|
+
exclude,
|
|
396
|
+
extensions,
|
|
397
|
+
babelHelpers,
|
|
398
|
+
include,
|
|
399
|
+
skipPreflightCheck
|
|
400
|
+
} = _unpackInputPluginOpt);
|
|
401
|
+
babelOptions = _objectWithoutProperties(_unpackInputPluginOpt, ["exclude", "extensions", "babelHelpers", "include", "skipPreflightCheck"]);
|
|
402
|
+
const extensionRegExp = new RegExp(`(${extensions.map(escapeRegExpCharacters).join('|')})$`);
|
|
403
|
+
const includeExcludeFilter = pluginutils.createFilter(include, exclude);
|
|
338
404
|
|
|
339
|
-
|
|
405
|
+
filter = id => extensionRegExp.test(stripQuery(id).bareId) && includeExcludeFilter(id);
|
|
340
406
|
|
|
341
|
-
|
|
342
|
-
|
|
407
|
+
return null;
|
|
408
|
+
},
|
|
343
409
|
|
|
344
410
|
resolveId(id) {
|
|
345
411
|
if (id !== HELPERS) {
|
|
@@ -360,7 +426,7 @@ function createBabelInputPluginFactory(customCallback = returnObject) {
|
|
|
360
426
|
transform(code, filename) {
|
|
361
427
|
if (!filter(filename)) return null;
|
|
362
428
|
if (filename === HELPERS) return null;
|
|
363
|
-
return transformCode(code, _objectSpread2({}, babelOptions, {
|
|
429
|
+
return transformCode(code, _objectSpread2(_objectSpread2({}, babelOptions), {}, {
|
|
364
430
|
filename
|
|
365
431
|
}), overrides, customOptions, this, async transformOptions => {
|
|
366
432
|
if (!skipPreflightCheck) {
|
|
@@ -393,7 +459,7 @@ function getRecommendedFormat(rollupFormat) {
|
|
|
393
459
|
}
|
|
394
460
|
|
|
395
461
|
function createBabelOutputPluginFactory(customCallback = returnObject) {
|
|
396
|
-
const overrides = customCallback(
|
|
462
|
+
const overrides = customCallback(babel__namespace);
|
|
397
463
|
return pluginOptions => {
|
|
398
464
|
const {
|
|
399
465
|
customOptions,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rollup/plugin-babel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"homepage": "https://github.com/rollup/plugins/tree/master/packages/babel#readme",
|
|
12
12
|
"bugs": "https://github.com/rollup/plugins/issues",
|
|
13
13
|
"main": "dist/index.js",
|
|
14
|
+
"module": "dist/index.es.js",
|
|
14
15
|
"engines": {
|
|
15
16
|
"node": ">= 10.0.0"
|
|
16
17
|
},
|
|
@@ -21,7 +22,7 @@
|
|
|
21
22
|
"ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}",
|
|
22
23
|
"ci:test": "pnpm run test -- --verbose",
|
|
23
24
|
"lint": "pnpm run lint:js && pnpm run lint:docs && pnpm run lint:package",
|
|
24
|
-
"lint:docs": "prettier --single-quote --write README.md",
|
|
25
|
+
"lint:docs": "prettier --single-quote --arrow-parens avoid --trailing-comma none --write README.md",
|
|
25
26
|
"lint:js": "eslint --fix --cache src test",
|
|
26
27
|
"lint:package": "prettier --write package.json --plugin=prettier-plugin-package",
|
|
27
28
|
"prebuild": "del-cli dist",
|
|
@@ -49,23 +50,33 @@
|
|
|
49
50
|
"@types/babel__core": "^7.1.9",
|
|
50
51
|
"rollup": "^1.20.0||^2.0.0"
|
|
51
52
|
},
|
|
53
|
+
"peerDependenciesMeta": {
|
|
54
|
+
"@types/babel__core": {
|
|
55
|
+
"optional": true
|
|
56
|
+
}
|
|
57
|
+
},
|
|
52
58
|
"dependencies": {
|
|
53
|
-
"@babel/helper-module-imports": "^7.
|
|
54
|
-
"@rollup/pluginutils": "^3.0
|
|
59
|
+
"@babel/helper-module-imports": "^7.10.4",
|
|
60
|
+
"@rollup/pluginutils": "^3.1.0"
|
|
55
61
|
},
|
|
56
62
|
"devDependencies": {
|
|
57
|
-
"@babel/core": "^7.
|
|
58
|
-
"@babel/plugin-external-helpers": "^7.
|
|
59
|
-
"@babel/plugin-proposal-decorators": "^7.
|
|
60
|
-
"@babel/plugin-syntax-dynamic-import": "^7.
|
|
61
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
62
|
-
"@babel/preset-env": "^7.
|
|
63
|
-
"@rollup/plugin-json": "^4.
|
|
63
|
+
"@babel/core": "^7.10.5",
|
|
64
|
+
"@babel/plugin-external-helpers": "^7.10.4",
|
|
65
|
+
"@babel/plugin-proposal-decorators": "^7.10.5",
|
|
66
|
+
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
67
|
+
"@babel/plugin-transform-runtime": "^7.10.5",
|
|
68
|
+
"@babel/preset-env": "^7.10.4",
|
|
69
|
+
"@rollup/plugin-json": "^4.1.0",
|
|
70
|
+
"@rollup/plugin-node-resolve": "^10.0.0",
|
|
64
71
|
"@types/babel__core": "^7.1.9",
|
|
65
|
-
"rollup": "^2.
|
|
66
|
-
"source-map": "^0.
|
|
72
|
+
"rollup": "^2.23.0",
|
|
73
|
+
"source-map": "^0.7.3"
|
|
67
74
|
},
|
|
75
|
+
"types": "types/index.d.ts",
|
|
68
76
|
"ava": {
|
|
77
|
+
"babel": {
|
|
78
|
+
"compileEnhancements": false
|
|
79
|
+
},
|
|
69
80
|
"files": [
|
|
70
81
|
"!**/fixtures/**",
|
|
71
82
|
"!**/helpers/**",
|
|
@@ -76,12 +87,5 @@
|
|
|
76
87
|
"contributors": [
|
|
77
88
|
"Bogdan Chadkin <trysound@yandex.ru>",
|
|
78
89
|
"Mateusz Burzyński <mateuszburzynski@gmail.com> (https://github.com/Andarist)"
|
|
79
|
-
]
|
|
80
|
-
"module": "dist/index.es.js",
|
|
81
|
-
"peerDependenciesMeta": {
|
|
82
|
-
"@types/babel__core": {
|
|
83
|
-
"optional": true
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
"types": "types/index.d.ts"
|
|
90
|
+
]
|
|
87
91
|
}
|