@rollup/plugin-babel 6.0.4 → 6.1.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 +24 -0
- package/dist/cjs/index.js +17 -1
- package/dist/es/index.js +17 -1
- package/package.json +16 -17
- package/types/index.d.ts +10 -0
package/README.md
CHANGED
|
@@ -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
|
@@ -344,6 +344,9 @@ function createBabelOutputPluginFactory(customCallback = returnObject) {
|
|
|
344
344
|
customOptions,
|
|
345
345
|
pluginOptionsWithOverrides
|
|
346
346
|
} = getOptionsWithOverrides(pluginOptions, overrides);
|
|
347
|
+
|
|
348
|
+
// cache for chunk name filter (includeChunks/excludeChunks)
|
|
349
|
+
let chunkNameFilter;
|
|
347
350
|
return {
|
|
348
351
|
name: 'babel',
|
|
349
352
|
renderStart(outputOptions) {
|
|
@@ -364,6 +367,8 @@ function createBabelOutputPluginFactory(customCallback = returnObject) {
|
|
|
364
367
|
/* eslint-disable no-unused-vars */
|
|
365
368
|
const {
|
|
366
369
|
allowAllFormats,
|
|
370
|
+
includeChunks,
|
|
371
|
+
excludeChunks,
|
|
367
372
|
exclude,
|
|
368
373
|
extensions,
|
|
369
374
|
externalHelpers,
|
|
@@ -373,7 +378,18 @@ function createBabelOutputPluginFactory(customCallback = returnObject) {
|
|
|
373
378
|
...babelOptions
|
|
374
379
|
} = unpackOutputPluginOptions(pluginOptionsWithOverrides, outputOptions);
|
|
375
380
|
/* eslint-enable no-unused-vars */
|
|
376
|
-
|
|
381
|
+
// If includeChunks/excludeChunks are specified, filter by chunk.name
|
|
382
|
+
if (includeChunks != null || excludeChunks != null) {
|
|
383
|
+
if (!chunkNameFilter) {
|
|
384
|
+
chunkNameFilter = pluginutils.createFilter(includeChunks, excludeChunks, {
|
|
385
|
+
resolve: false
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
if (!chunkNameFilter(chunk.name)) {
|
|
389
|
+
// Skip transforming this chunk
|
|
390
|
+
return null;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
377
393
|
return transformCode(code, babelOptions, overrides, customOptions, this);
|
|
378
394
|
}
|
|
379
395
|
};
|
package/dist/es/index.js
CHANGED
|
@@ -321,6 +321,9 @@ function createBabelOutputPluginFactory(customCallback = returnObject) {
|
|
|
321
321
|
customOptions,
|
|
322
322
|
pluginOptionsWithOverrides
|
|
323
323
|
} = getOptionsWithOverrides(pluginOptions, overrides);
|
|
324
|
+
|
|
325
|
+
// cache for chunk name filter (includeChunks/excludeChunks)
|
|
326
|
+
let chunkNameFilter;
|
|
324
327
|
return {
|
|
325
328
|
name: 'babel',
|
|
326
329
|
renderStart(outputOptions) {
|
|
@@ -341,6 +344,8 @@ function createBabelOutputPluginFactory(customCallback = returnObject) {
|
|
|
341
344
|
/* eslint-disable no-unused-vars */
|
|
342
345
|
const {
|
|
343
346
|
allowAllFormats,
|
|
347
|
+
includeChunks,
|
|
348
|
+
excludeChunks,
|
|
344
349
|
exclude,
|
|
345
350
|
extensions,
|
|
346
351
|
externalHelpers,
|
|
@@ -350,7 +355,18 @@ function createBabelOutputPluginFactory(customCallback = returnObject) {
|
|
|
350
355
|
...babelOptions
|
|
351
356
|
} = unpackOutputPluginOptions(pluginOptionsWithOverrides, outputOptions);
|
|
352
357
|
/* eslint-enable no-unused-vars */
|
|
353
|
-
|
|
358
|
+
// If includeChunks/excludeChunks are specified, filter by chunk.name
|
|
359
|
+
if (includeChunks != null || excludeChunks != null) {
|
|
360
|
+
if (!chunkNameFilter) {
|
|
361
|
+
chunkNameFilter = createFilter(includeChunks, excludeChunks, {
|
|
362
|
+
resolve: false
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
if (!chunkNameFilter(chunk.name)) {
|
|
366
|
+
// Skip transforming this chunk
|
|
367
|
+
return null;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
354
370
|
return transformCode(code, babelOptions, overrides, customOptions, this);
|
|
355
371
|
}
|
|
356
372
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rollup/plugin-babel",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.1.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",
|
|
@@ -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
|
@@ -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 = (
|