@rollup/plugin-babel 6.0.4 → 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 +25 -1
- package/dist/cjs/index.js +67 -60
- package/dist/es/index.js +67 -60
- package/package.json +17 -18
- package/types/index.d.ts +12 -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
|
|
|
@@ -200,6 +200,30 @@ export default {
|
|
|
200
200
|
|
|
201
201
|
The `include`, `exclude` and `extensions` options are ignored when using `getBabelOutputPlugin` and `createBabelOutputPluginFactory` will produce warnings, and there are a few more points to note that users should be aware of.
|
|
202
202
|
|
|
203
|
+
When transforming generated code, you can instead control which chunks are processed by matching their manual chunk names via the `includeChunks`/`excludeChunks` options. These patterns are matched against `chunk.name` as provided to Rollup's `renderChunk` hook and are especially useful to skip already-transpiled/minified vendor chunks:
|
|
204
|
+
|
|
205
|
+
```js
|
|
206
|
+
// rollup.config.js
|
|
207
|
+
import { getBabelOutputPlugin } from '@rollup/plugin-babel';
|
|
208
|
+
|
|
209
|
+
export default {
|
|
210
|
+
input: 'main.js',
|
|
211
|
+
manualChunks(id) {
|
|
212
|
+
if (id.includes('big-library')) return 'vendor';
|
|
213
|
+
},
|
|
214
|
+
output: {
|
|
215
|
+
format: 'es',
|
|
216
|
+
plugins: [
|
|
217
|
+
getBabelOutputPlugin({
|
|
218
|
+
presets: ['@babel/preset-env'],
|
|
219
|
+
// Do not transform the 'vendor' manual chunk
|
|
220
|
+
excludeChunks: ['vendor']
|
|
221
|
+
})
|
|
222
|
+
]
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
```
|
|
226
|
+
|
|
203
227
|
You can also run the plugin twice on the code, once when processing the input files to transpile special syntax to JavaScript and once on the output to transpile to a lower compatibility target:
|
|
204
228
|
|
|
205
229
|
```js
|
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
|
};
|
|
@@ -344,6 +335,9 @@ function createBabelOutputPluginFactory(customCallback = returnObject) {
|
|
|
344
335
|
customOptions,
|
|
345
336
|
pluginOptionsWithOverrides
|
|
346
337
|
} = getOptionsWithOverrides(pluginOptions, overrides);
|
|
338
|
+
|
|
339
|
+
// cache for chunk name filter (includeChunks/excludeChunks)
|
|
340
|
+
let chunkNameFilter;
|
|
347
341
|
return {
|
|
348
342
|
name: 'babel',
|
|
349
343
|
renderStart(outputOptions) {
|
|
@@ -364,6 +358,8 @@ function createBabelOutputPluginFactory(customCallback = returnObject) {
|
|
|
364
358
|
/* eslint-disable no-unused-vars */
|
|
365
359
|
const {
|
|
366
360
|
allowAllFormats,
|
|
361
|
+
includeChunks,
|
|
362
|
+
excludeChunks,
|
|
367
363
|
exclude,
|
|
368
364
|
extensions,
|
|
369
365
|
externalHelpers,
|
|
@@ -373,7 +369,18 @@ function createBabelOutputPluginFactory(customCallback = returnObject) {
|
|
|
373
369
|
...babelOptions
|
|
374
370
|
} = unpackOutputPluginOptions(pluginOptionsWithOverrides, outputOptions);
|
|
375
371
|
/* eslint-enable no-unused-vars */
|
|
376
|
-
|
|
372
|
+
// If includeChunks/excludeChunks are specified, filter by chunk.name
|
|
373
|
+
if (includeChunks != null || excludeChunks != null) {
|
|
374
|
+
if (!chunkNameFilter) {
|
|
375
|
+
chunkNameFilter = pluginutils.createFilter(includeChunks, excludeChunks, {
|
|
376
|
+
resolve: false
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
if (!chunkNameFilter(chunk.name)) {
|
|
380
|
+
// Skip transforming this chunk
|
|
381
|
+
return null;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
377
384
|
return transformCode(code, babelOptions, overrides, customOptions, this);
|
|
378
385
|
}
|
|
379
386
|
};
|
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
|
};
|
|
@@ -321,6 +312,9 @@ function createBabelOutputPluginFactory(customCallback = returnObject) {
|
|
|
321
312
|
customOptions,
|
|
322
313
|
pluginOptionsWithOverrides
|
|
323
314
|
} = getOptionsWithOverrides(pluginOptions, overrides);
|
|
315
|
+
|
|
316
|
+
// cache for chunk name filter (includeChunks/excludeChunks)
|
|
317
|
+
let chunkNameFilter;
|
|
324
318
|
return {
|
|
325
319
|
name: 'babel',
|
|
326
320
|
renderStart(outputOptions) {
|
|
@@ -341,6 +335,8 @@ function createBabelOutputPluginFactory(customCallback = returnObject) {
|
|
|
341
335
|
/* eslint-disable no-unused-vars */
|
|
342
336
|
const {
|
|
343
337
|
allowAllFormats,
|
|
338
|
+
includeChunks,
|
|
339
|
+
excludeChunks,
|
|
344
340
|
exclude,
|
|
345
341
|
extensions,
|
|
346
342
|
externalHelpers,
|
|
@@ -350,7 +346,18 @@ function createBabelOutputPluginFactory(customCallback = returnObject) {
|
|
|
350
346
|
...babelOptions
|
|
351
347
|
} = unpackOutputPluginOptions(pluginOptionsWithOverrides, outputOptions);
|
|
352
348
|
/* eslint-enable no-unused-vars */
|
|
353
|
-
|
|
349
|
+
// If includeChunks/excludeChunks are specified, filter by chunk.name
|
|
350
|
+
if (includeChunks != null || excludeChunks != null) {
|
|
351
|
+
if (!chunkNameFilter) {
|
|
352
|
+
chunkNameFilter = createFilter(includeChunks, excludeChunks, {
|
|
353
|
+
resolve: false
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
if (!chunkNameFilter(chunk.name)) {
|
|
357
|
+
// Skip transforming this chunk
|
|
358
|
+
return null;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
354
361
|
return transformCode(code, babelOptions, overrides, customOptions, this);
|
|
355
362
|
}
|
|
356
363
|
};
|
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
|
},
|
|
@@ -23,20 +23,6 @@
|
|
|
23
23
|
"engines": {
|
|
24
24
|
"node": ">=14.0.0"
|
|
25
25
|
},
|
|
26
|
-
"scripts": {
|
|
27
|
-
"build": "rollup -c",
|
|
28
|
-
"ci:coverage": "nyc pnpm test && nyc report --reporter=text-lcov > coverage.lcov",
|
|
29
|
-
"ci:lint": "pnpm build && pnpm lint",
|
|
30
|
-
"ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}",
|
|
31
|
-
"ci:test": "pnpm test -- --verbose",
|
|
32
|
-
"prebuild": "del-cli dist",
|
|
33
|
-
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
|
|
34
|
-
"prerelease": "pnpm build",
|
|
35
|
-
"pretest": "pnpm build",
|
|
36
|
-
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
|
|
37
|
-
"test": "ava",
|
|
38
|
-
"test:ts": "tsc types/index.d.ts test/types.ts --noEmit"
|
|
39
|
-
},
|
|
40
26
|
"files": [
|
|
41
27
|
"dist",
|
|
42
28
|
"!dist/**/*.map",
|
|
@@ -55,7 +41,7 @@
|
|
|
55
41
|
"peerDependencies": {
|
|
56
42
|
"@babel/core": "^7.0.0",
|
|
57
43
|
"@types/babel__core": "^7.1.9",
|
|
58
|
-
"rollup": "^
|
|
44
|
+
"rollup": "^2.0.0||^3.0.0||^4.0.0"
|
|
59
45
|
},
|
|
60
46
|
"peerDependenciesMeta": {
|
|
61
47
|
"rollup": {
|
|
@@ -94,5 +80,18 @@
|
|
|
94
80
|
"contributors": [
|
|
95
81
|
"Bogdan Chadkin <trysound@yandex.ru>",
|
|
96
82
|
"Mateusz Burzyński <mateuszburzynski@gmail.com> (https://github.com/Andarist)"
|
|
97
|
-
]
|
|
98
|
-
|
|
83
|
+
],
|
|
84
|
+
"scripts": {
|
|
85
|
+
"build": "rollup -c",
|
|
86
|
+
"ci:coverage": "nyc pnpm test && nyc report --reporter=text-lcov > coverage.lcov",
|
|
87
|
+
"ci:lint": "pnpm build && pnpm lint",
|
|
88
|
+
"ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}",
|
|
89
|
+
"ci:test": "pnpm test -- --verbose",
|
|
90
|
+
"prebuild": "del-cli dist",
|
|
91
|
+
"prerelease": "pnpm build",
|
|
92
|
+
"pretest": "pnpm build",
|
|
93
|
+
"release": "pnpm --workspace-root package:release $(pwd)",
|
|
94
|
+
"test": "ava",
|
|
95
|
+
"test:ts": "tsc types/index.d.ts test/types.ts --noEmit"
|
|
96
|
+
}
|
|
97
|
+
}
|
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']
|
|
@@ -48,6 +48,16 @@ export interface RollupBabelOutputPluginOptions
|
|
|
48
48
|
* @default false
|
|
49
49
|
*/
|
|
50
50
|
allowAllFormats?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Limit transforming of generated code to specific manual chunks by name.
|
|
53
|
+
* These patterns are matched against the `chunk.name` value in Rollup's `renderChunk` hook.
|
|
54
|
+
*/
|
|
55
|
+
includeChunks?: FilterPattern;
|
|
56
|
+
/**
|
|
57
|
+
* Exclude specific manual chunks by name from transforming the generated code.
|
|
58
|
+
* These patterns are matched against the `chunk.name` value in Rollup's `renderChunk` hook.
|
|
59
|
+
*/
|
|
60
|
+
excludeChunks?: FilterPattern;
|
|
51
61
|
}
|
|
52
62
|
|
|
53
63
|
export type RollupBabelCustomInputPluginOptions = (
|