@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 +11 -11
- package/dist/{index.js → cjs/index.js} +75 -198
- package/dist/{index.es.js → es/index.js} +70 -193
- package/dist/es/package.json +1 -0
- package/package.json +27 -21
- package/types/index.d.ts +2 -2
- package/CHANGELOG.md +0 -292
|
@@ -2,97 +2,13 @@ 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';
|
|
93
|
-
const EXTERNAL = 'external';
|
|
94
|
-
// e.g. https://github.com/rollup/rollup-plugin-node-resolve/blob/313a3e32f432f9eb18cc4c231cc7aac6df317a51/src/index.js#L74
|
|
8
|
+
const EXTERNAL = 'external';
|
|
95
9
|
|
|
10
|
+
// NOTE: DO NOT REMOVE the null character `\0` as it may be used by other plugins
|
|
11
|
+
// e.g. https://github.com/rollup/rollup-plugin-node-resolve/blob/313a3e32f432f9eb18cc4c231cc7aac6df317a51/src/index.js#L74
|
|
96
12
|
const HELPERS = '\0rollupPluginBabelHelpers.js';
|
|
97
13
|
|
|
98
14
|
function importHelperPlugin({
|
|
@@ -105,22 +21,20 @@ function importHelperPlugin({
|
|
|
105
21
|
if (!file.availableHelper(name)) {
|
|
106
22
|
return null;
|
|
107
23
|
}
|
|
108
|
-
|
|
109
24
|
if (cachedHelpers[name]) {
|
|
110
25
|
return t.cloneNode(cachedHelpers[name]);
|
|
111
26
|
}
|
|
112
|
-
|
|
113
27
|
return cachedHelpers[name] = addNamed(file.path, name, HELPERS);
|
|
114
28
|
});
|
|
115
29
|
}
|
|
116
|
-
|
|
117
30
|
};
|
|
118
31
|
}
|
|
119
32
|
|
|
120
33
|
const addBabelPlugin = (options, plugin) => {
|
|
121
|
-
return
|
|
34
|
+
return {
|
|
35
|
+
...options,
|
|
122
36
|
plugins: options.plugins.concat(plugin)
|
|
123
|
-
}
|
|
37
|
+
};
|
|
124
38
|
};
|
|
125
39
|
const warned = {};
|
|
126
40
|
function warnOnce(ctx, msg) {
|
|
@@ -145,7 +59,6 @@ const MODULE_ERROR = 'Rollup requires that your Babel configuration keeps ES6 mo
|
|
|
145
59
|
const UNEXPECTED_ERROR = 'An unexpected situation arose. Please raise an issue at ' + 'https://github.com/rollup/plugins/issues. Thanks!';
|
|
146
60
|
const PREFLIGHT_TEST_STRING = '__ROLLUP__PREFLIGHT_CHECK_DO_NOT_TOUCH__';
|
|
147
61
|
const PREFLIGHT_INPUT = `export default "${PREFLIGHT_TEST_STRING}";`;
|
|
148
|
-
|
|
149
62
|
function helpersTestTransform() {
|
|
150
63
|
return {
|
|
151
64
|
visitor: {
|
|
@@ -154,72 +67,62 @@ function helpersTestTransform() {
|
|
|
154
67
|
path.replaceWith(state.file.addHelper('inherits'));
|
|
155
68
|
}
|
|
156
69
|
}
|
|
157
|
-
|
|
158
70
|
}
|
|
159
71
|
};
|
|
160
72
|
}
|
|
73
|
+
const mismatchError = (actual, expected, filename) => `You have declared using "${expected}" babelHelpers, but transforming ${filename} resulted in "${actual}". Please check your configuration.`;
|
|
161
74
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
75
|
+
// Revert to /\/helpers\/(esm\/)?inherits/ when Babel 8 gets released, this was fixed in https://github.com/babel/babel/issues/14185
|
|
165
76
|
const inheritsHelperRe = /[\\/]+helpers[\\/]+(esm[\\/]+)?inherits/;
|
|
166
77
|
async function preflightCheck(ctx, babelHelpers, transformOptions) {
|
|
167
78
|
const finalOptions = addBabelPlugin(transformOptions, helpersTestTransform);
|
|
168
|
-
const check = (await babel.transformAsync(PREFLIGHT_INPUT, finalOptions)).code;
|
|
79
|
+
const check = (await babel.transformAsync(PREFLIGHT_INPUT, finalOptions)).code;
|
|
169
80
|
|
|
81
|
+
// Babel sometimes splits ExportDefaultDeclaration into 2 statements, so we also check for ExportNamedDeclaration
|
|
170
82
|
if (!/export (d|{)/.test(check)) {
|
|
171
83
|
ctx.error(MODULE_ERROR);
|
|
172
84
|
}
|
|
173
|
-
|
|
174
85
|
if (inheritsHelperRe.test(check)) {
|
|
175
86
|
if (babelHelpers === RUNTIME) {
|
|
176
87
|
return;
|
|
177
88
|
}
|
|
178
|
-
|
|
179
89
|
ctx.error(mismatchError(RUNTIME, babelHelpers, transformOptions.filename));
|
|
180
90
|
}
|
|
181
|
-
|
|
182
91
|
if (check.includes('babelHelpers.inherits')) {
|
|
183
92
|
if (babelHelpers === EXTERNAL) {
|
|
184
93
|
return;
|
|
185
94
|
}
|
|
186
|
-
|
|
187
95
|
ctx.error(mismatchError(EXTERNAL, babelHelpers, transformOptions.filename));
|
|
188
|
-
}
|
|
189
|
-
|
|
96
|
+
}
|
|
190
97
|
|
|
98
|
+
// test unminifiable string content
|
|
191
99
|
if (check.includes('Super expression must either be null or a function')) {
|
|
192
100
|
if (babelHelpers === INLINE || babelHelpers === BUNDLED) {
|
|
193
101
|
return;
|
|
194
102
|
}
|
|
195
|
-
|
|
196
103
|
if (babelHelpers === RUNTIME && !transformOptions.plugins.length) {
|
|
197
104
|
ctx.error(`You must use the \`@babel/plugin-transform-runtime\` plugin when \`babelHelpers\` is "${RUNTIME}".\n`);
|
|
198
105
|
}
|
|
199
|
-
|
|
200
106
|
ctx.error(mismatchError(INLINE, babelHelpers, transformOptions.filename));
|
|
201
107
|
}
|
|
202
|
-
|
|
203
108
|
ctx.error(UNEXPECTED_ERROR);
|
|
204
109
|
}
|
|
205
110
|
|
|
206
111
|
async function transformCode(inputCode, babelOptions, overrides, customOptions, ctx, finalizeOptions) {
|
|
207
112
|
// loadPartialConfigAsync has become available in @babel/core@7.8.0
|
|
208
|
-
const config = await (babel.loadPartialConfigAsync || babel.loadPartialConfig)(babelOptions);
|
|
113
|
+
const config = await (babel.loadPartialConfigAsync || babel.loadPartialConfig)(babelOptions);
|
|
209
114
|
|
|
115
|
+
// file is ignored by babel
|
|
210
116
|
if (!config) {
|
|
211
117
|
return null;
|
|
212
118
|
}
|
|
213
|
-
|
|
214
119
|
let transformOptions = !overrides.config ? config.options : await overrides.config.call(ctx, config, {
|
|
215
120
|
code: inputCode,
|
|
216
121
|
customOptions
|
|
217
122
|
});
|
|
218
|
-
|
|
219
123
|
if (finalizeOptions) {
|
|
220
124
|
transformOptions = await finalizeOptions(transformOptions);
|
|
221
125
|
}
|
|
222
|
-
|
|
223
126
|
if (!overrides.result) {
|
|
224
127
|
const {
|
|
225
128
|
code,
|
|
@@ -230,7 +133,6 @@ async function transformCode(inputCode, babelOptions, overrides, customOptions,
|
|
|
230
133
|
map
|
|
231
134
|
};
|
|
232
135
|
}
|
|
233
|
-
|
|
234
136
|
const result = await babel.transformAsync(inputCode, transformOptions);
|
|
235
137
|
const {
|
|
236
138
|
code,
|
|
@@ -247,29 +149,27 @@ async function transformCode(inputCode, babelOptions, overrides, customOptions,
|
|
|
247
149
|
};
|
|
248
150
|
}
|
|
249
151
|
|
|
250
|
-
const unpackOptions = (
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
return _objectSpread2(_objectSpread2({
|
|
152
|
+
const unpackOptions = ({
|
|
153
|
+
extensions = babel.DEFAULT_EXTENSIONS,
|
|
154
|
+
// rollup uses sourcemap, babel uses sourceMaps
|
|
155
|
+
// just normalize them here so people don't have to worry about it
|
|
156
|
+
sourcemap = true,
|
|
157
|
+
sourcemaps = true,
|
|
158
|
+
sourceMap = true,
|
|
159
|
+
sourceMaps = true,
|
|
160
|
+
...rest
|
|
161
|
+
} = {}) => {
|
|
162
|
+
return {
|
|
263
163
|
extensions,
|
|
264
164
|
plugins: [],
|
|
265
|
-
sourceMaps: sourcemap && sourcemaps && sourceMap && sourceMaps
|
|
266
|
-
|
|
267
|
-
caller:
|
|
268
|
-
name: '@rollup/plugin-babel'
|
|
269
|
-
|
|
270
|
-
|
|
165
|
+
sourceMaps: sourcemap && sourcemaps && sourceMap && sourceMaps,
|
|
166
|
+
...rest,
|
|
167
|
+
caller: {
|
|
168
|
+
name: '@rollup/plugin-babel',
|
|
169
|
+
...rest.caller
|
|
170
|
+
}
|
|
171
|
+
};
|
|
271
172
|
};
|
|
272
|
-
|
|
273
173
|
const warnAboutDeprecatedHelpersOption = ({
|
|
274
174
|
deprecatedOption,
|
|
275
175
|
suggestion
|
|
@@ -277,13 +177,10 @@ const warnAboutDeprecatedHelpersOption = ({
|
|
|
277
177
|
// eslint-disable-next-line no-console
|
|
278
178
|
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
179
|
};
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
} = _ref2,
|
|
285
|
-
rest = _objectWithoutProperties(_ref2, ["skipPreflightCheck"]);
|
|
286
|
-
|
|
180
|
+
const unpackInputPluginOptions = ({
|
|
181
|
+
skipPreflightCheck = false,
|
|
182
|
+
...rest
|
|
183
|
+
}, rollupVersion) => {
|
|
287
184
|
if ('runtimeHelpers' in rest) {
|
|
288
185
|
warnAboutDeprecatedHelpersOption({
|
|
289
186
|
deprecatedOption: 'runtimeHelpers',
|
|
@@ -298,52 +195,48 @@ const unpackInputPluginOptions = (_ref2, rollupVersion) => {
|
|
|
298
195
|
// eslint-disable-next-line no-console
|
|
299
196
|
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
197
|
}
|
|
301
|
-
|
|
302
|
-
|
|
198
|
+
return unpackOptions({
|
|
199
|
+
...rest,
|
|
303
200
|
skipPreflightCheck,
|
|
304
201
|
babelHelpers: rest.babelHelpers || BUNDLED,
|
|
305
|
-
caller:
|
|
202
|
+
caller: {
|
|
306
203
|
supportsStaticESM: true,
|
|
307
204
|
supportsDynamicImport: true,
|
|
308
205
|
supportsTopLevelAwait: true,
|
|
309
206
|
// todo: remove version checks for 1.20 - 1.25 when we bump peer deps
|
|
310
|
-
supportsExportNamespaceFrom: !rollupVersion.match(/^1\.2[0-5]\./)
|
|
311
|
-
|
|
312
|
-
|
|
207
|
+
supportsExportNamespaceFrom: !rollupVersion.match(/^1\.2[0-5]\./),
|
|
208
|
+
...rest.caller
|
|
209
|
+
}
|
|
210
|
+
});
|
|
313
211
|
};
|
|
314
|
-
|
|
315
212
|
const unpackOutputPluginOptions = (options, {
|
|
316
213
|
format
|
|
317
|
-
}) => unpackOptions(
|
|
214
|
+
}) => unpackOptions({
|
|
318
215
|
configFile: false,
|
|
319
|
-
sourceType: format === 'es' ? 'module' : 'script'
|
|
320
|
-
|
|
321
|
-
caller:
|
|
322
|
-
supportsStaticESM: format === 'es'
|
|
323
|
-
|
|
324
|
-
}
|
|
325
|
-
|
|
216
|
+
sourceType: format === 'es' ? 'module' : 'script',
|
|
217
|
+
...options,
|
|
218
|
+
caller: {
|
|
219
|
+
supportsStaticESM: format === 'es',
|
|
220
|
+
...options.caller
|
|
221
|
+
}
|
|
222
|
+
});
|
|
326
223
|
function getOptionsWithOverrides(pluginOptions = {}, overrides = {}) {
|
|
327
224
|
if (!overrides.options) return {
|
|
328
225
|
customOptions: null,
|
|
329
226
|
pluginOptionsWithOverrides: pluginOptions
|
|
330
227
|
};
|
|
331
228
|
const overridden = overrides.options(pluginOptions);
|
|
332
|
-
|
|
333
229
|
if (typeof overridden.then === 'function') {
|
|
334
230
|
throw new Error(".options hook can't be asynchronous. It should return `{ customOptions, pluginsOptions }` synchronously.");
|
|
335
231
|
}
|
|
336
|
-
|
|
337
232
|
return {
|
|
338
233
|
customOptions: overridden.customOptions || null,
|
|
339
234
|
pluginOptionsWithOverrides: overridden.pluginOptions || pluginOptions
|
|
340
235
|
};
|
|
341
236
|
}
|
|
342
|
-
|
|
343
237
|
const returnObject = () => {
|
|
344
238
|
return {};
|
|
345
239
|
};
|
|
346
|
-
|
|
347
240
|
function createBabelInputPluginFactory(customCallback = returnObject) {
|
|
348
241
|
const overrides = customCallback(babel);
|
|
349
242
|
return pluginOptions => {
|
|
@@ -357,89 +250,70 @@ function createBabelInputPluginFactory(customCallback = returnObject) {
|
|
|
357
250
|
let skipPreflightCheck;
|
|
358
251
|
return {
|
|
359
252
|
name: 'babel',
|
|
360
|
-
|
|
361
253
|
options() {
|
|
362
254
|
// todo: remove options hook and hoist declarations when version checks are removed
|
|
363
255
|
let exclude;
|
|
364
256
|
let include;
|
|
365
257
|
let extensions;
|
|
366
258
|
let customFilter;
|
|
367
|
-
|
|
368
|
-
var _unpackInputPluginOpt = unpackInputPluginOptions(pluginOptionsWithOverrides, this.meta.rollupVersion);
|
|
369
|
-
|
|
370
259
|
({
|
|
371
260
|
exclude,
|
|
372
261
|
extensions,
|
|
373
262
|
babelHelpers,
|
|
374
263
|
include,
|
|
375
264
|
filter: customFilter,
|
|
376
|
-
skipPreflightCheck
|
|
377
|
-
|
|
378
|
-
|
|
265
|
+
skipPreflightCheck,
|
|
266
|
+
...babelOptions
|
|
267
|
+
} = unpackInputPluginOptions(pluginOptionsWithOverrides, this.meta.rollupVersion));
|
|
379
268
|
const extensionRegExp = new RegExp(`(${extensions.map(escapeRegExpCharacters).join('|')})$`);
|
|
380
|
-
|
|
381
269
|
if (customFilter && (include || exclude)) {
|
|
382
270
|
throw new Error('Could not handle include or exclude with custom filter together');
|
|
383
271
|
}
|
|
384
|
-
|
|
385
272
|
const userDefinedFilter = typeof customFilter === 'function' ? customFilter : createFilter(include, exclude);
|
|
386
|
-
|
|
387
273
|
filter = id => extensionRegExp.test(stripQuery(id).bareId) && userDefinedFilter(id);
|
|
388
|
-
|
|
389
274
|
return null;
|
|
390
275
|
},
|
|
391
|
-
|
|
392
276
|
resolveId(id) {
|
|
393
277
|
if (id !== HELPERS) {
|
|
394
278
|
return null;
|
|
395
279
|
}
|
|
396
|
-
|
|
397
280
|
return id;
|
|
398
281
|
},
|
|
399
|
-
|
|
400
282
|
load(id) {
|
|
401
283
|
if (id !== HELPERS) {
|
|
402
284
|
return null;
|
|
403
285
|
}
|
|
404
|
-
|
|
405
286
|
return babel.buildExternalHelpers(null, 'module');
|
|
406
287
|
},
|
|
407
|
-
|
|
408
288
|
transform(code, filename) {
|
|
409
289
|
if (!filter(filename)) return null;
|
|
410
290
|
if (filename === HELPERS) return null;
|
|
411
|
-
return transformCode(code,
|
|
291
|
+
return transformCode(code, {
|
|
292
|
+
...babelOptions,
|
|
412
293
|
filename
|
|
413
|
-
}
|
|
294
|
+
}, overrides, customOptions, this, async transformOptions => {
|
|
414
295
|
if (!skipPreflightCheck) {
|
|
415
296
|
await preflightCheck(this, babelHelpers, transformOptions);
|
|
416
297
|
}
|
|
417
|
-
|
|
418
298
|
return babelHelpers === BUNDLED ? addBabelPlugin(transformOptions, importHelperPlugin) : transformOptions;
|
|
419
299
|
});
|
|
420
300
|
}
|
|
421
|
-
|
|
422
301
|
};
|
|
423
302
|
};
|
|
424
303
|
}
|
|
425
|
-
|
|
426
304
|
function getRecommendedFormat(rollupFormat) {
|
|
427
305
|
switch (rollupFormat) {
|
|
428
306
|
case 'amd':
|
|
429
307
|
return 'amd';
|
|
430
|
-
|
|
431
308
|
case 'iife':
|
|
432
309
|
case 'umd':
|
|
433
310
|
return 'umd';
|
|
434
|
-
|
|
435
311
|
case 'system':
|
|
436
312
|
return 'systemjs';
|
|
437
|
-
|
|
438
313
|
default:
|
|
439
314
|
return '<module format>';
|
|
440
315
|
}
|
|
441
316
|
}
|
|
442
|
-
|
|
443
317
|
function createBabelOutputPluginFactory(customCallback = returnObject) {
|
|
444
318
|
const overrides = customCallback(babel);
|
|
445
319
|
return pluginOptions => {
|
|
@@ -449,7 +323,6 @@ function createBabelOutputPluginFactory(customCallback = returnObject) {
|
|
|
449
323
|
} = getOptionsWithOverrides(pluginOptions, overrides);
|
|
450
324
|
return {
|
|
451
325
|
name: 'babel',
|
|
452
|
-
|
|
453
326
|
renderStart(outputOptions) {
|
|
454
327
|
const {
|
|
455
328
|
extensions,
|
|
@@ -457,32 +330,36 @@ function createBabelOutputPluginFactory(customCallback = returnObject) {
|
|
|
457
330
|
exclude,
|
|
458
331
|
allowAllFormats
|
|
459
332
|
} = pluginOptionsWithOverrides;
|
|
460
|
-
|
|
461
333
|
if (extensions || include || exclude) {
|
|
462
334
|
warnOnce(this, 'The "include", "exclude" and "extensions" options are ignored when transforming the output.');
|
|
463
335
|
}
|
|
464
|
-
|
|
465
336
|
if (!allowAllFormats && outputOptions.format !== 'es' && outputOptions.format !== 'cjs') {
|
|
466
337
|
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.`);
|
|
467
338
|
}
|
|
468
339
|
},
|
|
469
|
-
|
|
470
340
|
renderChunk(code, chunk, outputOptions) {
|
|
471
341
|
/* eslint-disable no-unused-vars */
|
|
472
|
-
const
|
|
473
|
-
|
|
342
|
+
const {
|
|
343
|
+
allowAllFormats,
|
|
344
|
+
exclude,
|
|
345
|
+
extensions,
|
|
346
|
+
externalHelpers,
|
|
347
|
+
externalHelpersWhitelist,
|
|
348
|
+
include,
|
|
349
|
+
runtimeHelpers,
|
|
350
|
+
...babelOptions
|
|
351
|
+
} = unpackOutputPluginOptions(pluginOptionsWithOverrides, outputOptions);
|
|
474
352
|
/* eslint-enable no-unused-vars */
|
|
475
353
|
|
|
476
|
-
|
|
477
354
|
return transformCode(code, babelOptions, overrides, customOptions, this);
|
|
478
355
|
}
|
|
479
|
-
|
|
480
356
|
};
|
|
481
357
|
};
|
|
482
|
-
}
|
|
483
|
-
|
|
358
|
+
}
|
|
484
359
|
|
|
360
|
+
// export this for symmetry with output-related exports
|
|
485
361
|
const getBabelInputPlugin = createBabelInputPluginFactory();
|
|
486
362
|
const getBabelOutputPlugin = createBabelOutputPluginFactory();
|
|
487
363
|
|
|
488
364
|
export { getBabelInputPlugin as babel, createBabelInputPluginFactory, createBabelOutputPluginFactory, getBabelInputPlugin as default, getBabelInputPlugin, getBabelOutputPlugin };
|
|
365
|
+
//# 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": "
|
|
3
|
+
"version": "6.0.1",
|
|
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.
|
|
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": ">=
|
|
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
|
|
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": "^5.0.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.
|
|
69
|
-
"@rollup/plugin-json": "^
|
|
70
|
-
"@rollup/plugin-node-resolve": "^
|
|
76
|
+
"@babel/plugin-transform-runtime": "^7.19.1",
|
|
77
|
+
"@babel/preset-env": "^7.19.1",
|
|
78
|
+
"@rollup/plugin-json": "^5.0.0",
|
|
79
|
+
"@rollup/plugin-node-resolve": "^15.0.0",
|
|
71
80
|
"@types/babel__core": "^7.1.9",
|
|
72
|
-
"rollup": "^2.
|
|
73
|
-
"source-map": "^0.7.
|
|
81
|
+
"rollup": "^3.2.3",
|
|
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;
|