@rollup/plugin-babel 6.1.0 → 7.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 +1 -1
- package/dist/cjs/index.js +50 -59
- package/dist/es/index.js +50 -59
- package/package.json +2 -2
- package/types/index.d.ts +2 -2
package/README.md
CHANGED
|
@@ -94,7 +94,7 @@ A [picomatch pattern](https://github.com/micromatch/picomatch), or array of patt
|
|
|
94
94
|
|
|
95
95
|
### `filter`
|
|
96
96
|
|
|
97
|
-
Type: (id: string) => boolean
|
|
97
|
+
Type: `(id: string, code: string) => Promise<boolean> | boolean`<br>
|
|
98
98
|
|
|
99
99
|
Custom [filter function](https://github.com/rollup/plugins/tree/master/packages/pluginutils#createfilter) can be used to determine whether or not certain modules should be operated upon.
|
|
100
100
|
|
package/dist/cjs/index.js
CHANGED
|
@@ -67,16 +67,6 @@ function warnOnce(ctx, msg) {
|
|
|
67
67
|
}
|
|
68
68
|
const regExpCharactersRegExp = /[\\^$.*+?()[\]{}|]/g;
|
|
69
69
|
const escapeRegExpCharacters = str => str.replace(regExpCharactersRegExp, '\\$&');
|
|
70
|
-
function stripQuery(id) {
|
|
71
|
-
// strip query params from import
|
|
72
|
-
const [bareId, query] = id.split('?');
|
|
73
|
-
const suffix = `${query ? `?${query}` : ''}`;
|
|
74
|
-
return {
|
|
75
|
-
bareId,
|
|
76
|
-
query,
|
|
77
|
-
suffix
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
70
|
|
|
81
71
|
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 ).';
|
|
82
72
|
const UNEXPECTED_ERROR = 'An unexpected situation arose. Please raise an issue at ' + 'https://github.com/rollup/plugins/issues. Thanks!';
|
|
@@ -203,7 +193,7 @@ const warnAboutDeprecatedHelpersOption = ({
|
|
|
203
193
|
const unpackInputPluginOptions = ({
|
|
204
194
|
skipPreflightCheck = false,
|
|
205
195
|
...rest
|
|
206
|
-
}
|
|
196
|
+
}) => {
|
|
207
197
|
if ('runtimeHelpers' in rest) {
|
|
208
198
|
warnAboutDeprecatedHelpersOption({
|
|
209
199
|
deprecatedOption: 'runtimeHelpers',
|
|
@@ -226,8 +216,7 @@ const unpackInputPluginOptions = ({
|
|
|
226
216
|
supportsStaticESM: true,
|
|
227
217
|
supportsDynamicImport: true,
|
|
228
218
|
supportsTopLevelAwait: true,
|
|
229
|
-
|
|
230
|
-
supportsExportNamespaceFrom: !rollupVersion.match(/^1\.2[0-5]\./),
|
|
219
|
+
supportsExportNamespaceFrom: true,
|
|
231
220
|
...rest.caller
|
|
232
221
|
}
|
|
233
222
|
});
|
|
@@ -267,59 +256,61 @@ function createBabelInputPluginFactory(customCallback = returnObject) {
|
|
|
267
256
|
customOptions,
|
|
268
257
|
pluginOptionsWithOverrides
|
|
269
258
|
} = getOptionsWithOverrides(pluginOptions, overrides);
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
259
|
+
const {
|
|
260
|
+
exclude,
|
|
261
|
+
extensions,
|
|
262
|
+
babelHelpers,
|
|
263
|
+
include,
|
|
264
|
+
filter: customFilter,
|
|
265
|
+
skipPreflightCheck,
|
|
266
|
+
...babelOptions
|
|
267
|
+
} = unpackInputPluginOptions(pluginOptionsWithOverrides);
|
|
268
|
+
const extensionRegExp = new RegExp(`(${extensions.map(escapeRegExpCharacters).join('|')})(\\?.*)?(#.*)?$`);
|
|
269
|
+
if (customFilter && (include || exclude)) {
|
|
270
|
+
throw new Error('Could not handle include or exclude with custom filter together');
|
|
271
|
+
}
|
|
272
|
+
const userDefinedFilter = typeof customFilter === 'function' ? customFilter : pluginutils.createFilter(include, exclude);
|
|
273
|
+
const filter = (id, code) => extensionRegExp.test(id) && userDefinedFilter(id, code);
|
|
274
|
+
const helpersFilter = {
|
|
275
|
+
id: new RegExp(`^${escapeRegExpCharacters(HELPERS)}$`)
|
|
276
|
+
};
|
|
274
277
|
return {
|
|
275
278
|
name: 'babel',
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
exclude,
|
|
284
|
-
extensions,
|
|
285
|
-
babelHelpers,
|
|
286
|
-
include,
|
|
287
|
-
filter: customFilter,
|
|
288
|
-
skipPreflightCheck,
|
|
289
|
-
...babelOptions
|
|
290
|
-
} = unpackInputPluginOptions(pluginOptionsWithOverrides, this.meta.rollupVersion));
|
|
291
|
-
const extensionRegExp = new RegExp(`(${extensions.map(escapeRegExpCharacters).join('|')})$`);
|
|
292
|
-
if (customFilter && (include || exclude)) {
|
|
293
|
-
throw new Error('Could not handle include or exclude with custom filter together');
|
|
279
|
+
resolveId: {
|
|
280
|
+
filter: helpersFilter,
|
|
281
|
+
handler(id) {
|
|
282
|
+
if (id !== HELPERS) {
|
|
283
|
+
return null;
|
|
284
|
+
}
|
|
285
|
+
return id;
|
|
294
286
|
}
|
|
295
|
-
const userDefinedFilter = typeof customFilter === 'function' ? customFilter : pluginutils.createFilter(include, exclude);
|
|
296
|
-
filter = id => extensionRegExp.test(stripQuery(id).bareId) && userDefinedFilter(id);
|
|
297
|
-
return null;
|
|
298
287
|
},
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
288
|
+
load: {
|
|
289
|
+
filter: helpersFilter,
|
|
290
|
+
handler(id) {
|
|
291
|
+
if (id !== HELPERS) {
|
|
292
|
+
return null;
|
|
293
|
+
}
|
|
294
|
+
return babel__namespace.buildExternalHelpers(null, 'module');
|
|
302
295
|
}
|
|
303
|
-
return id;
|
|
304
296
|
},
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
297
|
+
transform: {
|
|
298
|
+
filter: {
|
|
299
|
+
id: extensionRegExp
|
|
300
|
+
},
|
|
301
|
+
async handler(code, filename) {
|
|
302
|
+
if (!(await filter(filename, code))) return null;
|
|
303
|
+
if (filename === HELPERS) return null;
|
|
304
|
+
return transformCode(code, {
|
|
305
|
+
...babelOptions,
|
|
306
|
+
filename
|
|
307
|
+
}, overrides, customOptions, this, async transformOptions => {
|
|
308
|
+
if (!skipPreflightCheck) {
|
|
309
|
+
await preflightCheck(this, babelHelpers, transformOptions);
|
|
310
|
+
}
|
|
311
|
+
return babelHelpers === BUNDLED ? addBabelPlugin(transformOptions, importHelperPlugin) : transformOptions;
|
|
312
|
+
});
|
|
308
313
|
}
|
|
309
|
-
return babel__namespace.buildExternalHelpers(null, 'module');
|
|
310
|
-
},
|
|
311
|
-
transform(code, filename) {
|
|
312
|
-
if (!filter(filename)) return null;
|
|
313
|
-
if (filename === HELPERS) return null;
|
|
314
|
-
return transformCode(code, {
|
|
315
|
-
...babelOptions,
|
|
316
|
-
filename
|
|
317
|
-
}, overrides, customOptions, this, async transformOptions => {
|
|
318
|
-
if (!skipPreflightCheck) {
|
|
319
|
-
await preflightCheck(this, babelHelpers, transformOptions);
|
|
320
|
-
}
|
|
321
|
-
return babelHelpers === BUNDLED ? addBabelPlugin(transformOptions, importHelperPlugin) : transformOptions;
|
|
322
|
-
});
|
|
323
314
|
}
|
|
324
315
|
};
|
|
325
316
|
};
|
package/dist/es/index.js
CHANGED
|
@@ -44,16 +44,6 @@ function warnOnce(ctx, msg) {
|
|
|
44
44
|
}
|
|
45
45
|
const regExpCharactersRegExp = /[\\^$.*+?()[\]{}|]/g;
|
|
46
46
|
const escapeRegExpCharacters = str => str.replace(regExpCharactersRegExp, '\\$&');
|
|
47
|
-
function stripQuery(id) {
|
|
48
|
-
// strip query params from import
|
|
49
|
-
const [bareId, query] = id.split('?');
|
|
50
|
-
const suffix = `${query ? `?${query}` : ''}`;
|
|
51
|
-
return {
|
|
52
|
-
bareId,
|
|
53
|
-
query,
|
|
54
|
-
suffix
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
47
|
|
|
58
48
|
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 ).';
|
|
59
49
|
const UNEXPECTED_ERROR = 'An unexpected situation arose. Please raise an issue at ' + 'https://github.com/rollup/plugins/issues. Thanks!';
|
|
@@ -180,7 +170,7 @@ const warnAboutDeprecatedHelpersOption = ({
|
|
|
180
170
|
const unpackInputPluginOptions = ({
|
|
181
171
|
skipPreflightCheck = false,
|
|
182
172
|
...rest
|
|
183
|
-
}
|
|
173
|
+
}) => {
|
|
184
174
|
if ('runtimeHelpers' in rest) {
|
|
185
175
|
warnAboutDeprecatedHelpersOption({
|
|
186
176
|
deprecatedOption: 'runtimeHelpers',
|
|
@@ -203,8 +193,7 @@ const unpackInputPluginOptions = ({
|
|
|
203
193
|
supportsStaticESM: true,
|
|
204
194
|
supportsDynamicImport: true,
|
|
205
195
|
supportsTopLevelAwait: true,
|
|
206
|
-
|
|
207
|
-
supportsExportNamespaceFrom: !rollupVersion.match(/^1\.2[0-5]\./),
|
|
196
|
+
supportsExportNamespaceFrom: true,
|
|
208
197
|
...rest.caller
|
|
209
198
|
}
|
|
210
199
|
});
|
|
@@ -244,59 +233,61 @@ function createBabelInputPluginFactory(customCallback = returnObject) {
|
|
|
244
233
|
customOptions,
|
|
245
234
|
pluginOptionsWithOverrides
|
|
246
235
|
} = getOptionsWithOverrides(pluginOptions, overrides);
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
236
|
+
const {
|
|
237
|
+
exclude,
|
|
238
|
+
extensions,
|
|
239
|
+
babelHelpers,
|
|
240
|
+
include,
|
|
241
|
+
filter: customFilter,
|
|
242
|
+
skipPreflightCheck,
|
|
243
|
+
...babelOptions
|
|
244
|
+
} = unpackInputPluginOptions(pluginOptionsWithOverrides);
|
|
245
|
+
const extensionRegExp = new RegExp(`(${extensions.map(escapeRegExpCharacters).join('|')})(\\?.*)?(#.*)?$`);
|
|
246
|
+
if (customFilter && (include || exclude)) {
|
|
247
|
+
throw new Error('Could not handle include or exclude with custom filter together');
|
|
248
|
+
}
|
|
249
|
+
const userDefinedFilter = typeof customFilter === 'function' ? customFilter : createFilter(include, exclude);
|
|
250
|
+
const filter = (id, code) => extensionRegExp.test(id) && userDefinedFilter(id, code);
|
|
251
|
+
const helpersFilter = {
|
|
252
|
+
id: new RegExp(`^${escapeRegExpCharacters(HELPERS)}$`)
|
|
253
|
+
};
|
|
251
254
|
return {
|
|
252
255
|
name: 'babel',
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
exclude,
|
|
261
|
-
extensions,
|
|
262
|
-
babelHelpers,
|
|
263
|
-
include,
|
|
264
|
-
filter: customFilter,
|
|
265
|
-
skipPreflightCheck,
|
|
266
|
-
...babelOptions
|
|
267
|
-
} = unpackInputPluginOptions(pluginOptionsWithOverrides, this.meta.rollupVersion));
|
|
268
|
-
const extensionRegExp = new RegExp(`(${extensions.map(escapeRegExpCharacters).join('|')})$`);
|
|
269
|
-
if (customFilter && (include || exclude)) {
|
|
270
|
-
throw new Error('Could not handle include or exclude with custom filter together');
|
|
256
|
+
resolveId: {
|
|
257
|
+
filter: helpersFilter,
|
|
258
|
+
handler(id) {
|
|
259
|
+
if (id !== HELPERS) {
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
return id;
|
|
271
263
|
}
|
|
272
|
-
const userDefinedFilter = typeof customFilter === 'function' ? customFilter : createFilter(include, exclude);
|
|
273
|
-
filter = id => extensionRegExp.test(stripQuery(id).bareId) && userDefinedFilter(id);
|
|
274
|
-
return null;
|
|
275
264
|
},
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
265
|
+
load: {
|
|
266
|
+
filter: helpersFilter,
|
|
267
|
+
handler(id) {
|
|
268
|
+
if (id !== HELPERS) {
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
271
|
+
return babel.buildExternalHelpers(null, 'module');
|
|
279
272
|
}
|
|
280
|
-
return id;
|
|
281
273
|
},
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
274
|
+
transform: {
|
|
275
|
+
filter: {
|
|
276
|
+
id: extensionRegExp
|
|
277
|
+
},
|
|
278
|
+
async handler(code, filename) {
|
|
279
|
+
if (!(await filter(filename, code))) return null;
|
|
280
|
+
if (filename === HELPERS) return null;
|
|
281
|
+
return transformCode(code, {
|
|
282
|
+
...babelOptions,
|
|
283
|
+
filename
|
|
284
|
+
}, overrides, customOptions, this, async transformOptions => {
|
|
285
|
+
if (!skipPreflightCheck) {
|
|
286
|
+
await preflightCheck(this, babelHelpers, transformOptions);
|
|
287
|
+
}
|
|
288
|
+
return babelHelpers === BUNDLED ? addBabelPlugin(transformOptions, importHelperPlugin) : transformOptions;
|
|
289
|
+
});
|
|
285
290
|
}
|
|
286
|
-
return babel.buildExternalHelpers(null, 'module');
|
|
287
|
-
},
|
|
288
|
-
transform(code, filename) {
|
|
289
|
-
if (!filter(filename)) return null;
|
|
290
|
-
if (filename === HELPERS) return null;
|
|
291
|
-
return transformCode(code, {
|
|
292
|
-
...babelOptions,
|
|
293
|
-
filename
|
|
294
|
-
}, overrides, customOptions, this, async transformOptions => {
|
|
295
|
-
if (!skipPreflightCheck) {
|
|
296
|
-
await preflightCheck(this, babelHelpers, transformOptions);
|
|
297
|
-
}
|
|
298
|
-
return babelHelpers === BUNDLED ? addBabelPlugin(transformOptions, importHelperPlugin) : transformOptions;
|
|
299
|
-
});
|
|
300
291
|
}
|
|
301
292
|
};
|
|
302
293
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rollup/plugin-babel",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@babel/core": "^7.0.0",
|
|
43
43
|
"@types/babel__core": "^7.1.9",
|
|
44
|
-
"rollup": "^
|
|
44
|
+
"rollup": "^2.0.0||^3.0.0||^4.0.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependenciesMeta": {
|
|
47
47
|
"rollup": {
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Plugin, PluginContext, TransformPluginContext } from 'rollup';
|
|
2
|
-
import type { FilterPattern
|
|
2
|
+
import type { FilterPattern } from '@rollup/pluginutils';
|
|
3
3
|
import type * as babelCore from '@babel/core';
|
|
4
4
|
|
|
5
5
|
export interface RollupBabelInputPluginOptions
|
|
@@ -23,7 +23,7 @@ export interface RollupBabelInputPluginOptions
|
|
|
23
23
|
* const filter = createFilter(include, exclude, {});
|
|
24
24
|
* @default undefined;
|
|
25
25
|
*/
|
|
26
|
-
filter?:
|
|
26
|
+
filter?: (id: string, code: string) => Promise<boolean> | boolean;
|
|
27
27
|
/**
|
|
28
28
|
* An array of file extensions that Babel should transpile. If you want to transpile TypeScript files with this plugin it's essential to include .ts and .tsx in this option.
|
|
29
29
|
* @default ['.js', '.jsx', '.es6', '.es', '.mjs']
|