@rollup/plugin-babel 5.0.4 → 5.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @rollup/plugin-babel ChangeLog
2
2
 
3
+ ## v5.1.0
4
+
5
+ _2020-07-12_
6
+
7
+ ### Features
8
+
9
+ - feat: add typings (#462)
10
+
11
+ ### Updates
12
+
13
+ - docs: add note about excluding @babel/runtime helpers via regex (#483)
14
+
3
15
  ## v5.0.4
4
16
 
5
17
  _2020-06-22_
package/README.md CHANGED
@@ -91,7 +91,7 @@ It is recommended to configure this option explicitly (even if with its default
91
91
 
92
92
  We recommend to follow these guidelines to determine the most appropriate value for your project:
93
93
 
94
- - `'runtime'` - you should use this especially when building libraries with Rollup. It has to be used in combination with `@babel/plugin-transform-runtime` and you should also specify `@babel/runtime` as dependency of your package (don't forget to tell Rollup to treat it as your external dependency when bundling for `cjs` & `es` formats).
94
+ - `'runtime'` - you should use this especially when building libraries with Rollup. It has to be used in combination with `@babel/plugin-transform-runtime` and you should also specify `@babel/runtime` as dependency of your package. Don't forget to tell Rollup to treat the helpers imported from within the `@babel/runtime` module as external dependencies when bundling for `cjs` & `es` formats. This can be accomplished via regex (`external: [/@babel\/runtime/]`) or a function (`external: id => id.includes('@babel/runtime')`). It's important to not only specify `external: ['@babel/runtime']` since the helpers are imported from nested paths (e.g `@babel/runtime/helpers/get`) and [Rollup will only exclude modules that match strings exactly](https://rollupjs.org/guide/en/#peer-dependencies).
95
95
  - `'bundled'` - you should use this if you want your resulting bundle to contain those helpers (at most one copy of each). Useful especially if you bundle an application code.
96
96
  - `'external'` - use this only if you know what you are doing. It will reference helpers on **global** `babelHelpers` object. Used in combination with `@babel/plugin-external-helpers`.
97
97
  - `'inline'` - this is not recommended. Helpers will be inserted in each file using this option. This can cause serious code duplication. This is the default Babel behavior as Babel operates on isolated files - however, as Rollup is a bundler and is project-aware (and therefore likely operating across multiple input files), the default of this plugin is `"bundled"`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rollup/plugin-babel",
3
- "version": "5.0.4",
3
+ "version": "5.1.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -25,12 +25,14 @@
25
25
  "lint:js": "eslint --fix --cache src test",
26
26
  "lint:package": "prettier --write package.json --plugin=prettier-plugin-package",
27
27
  "prebuild": "del-cli dist",
28
- "prepublishOnly": "pnpm run lint && pnpm run test && pnpm run build",
28
+ "prepublishOnly": "pnpm run lint && pnpm run test && pnpm run build && pnpm run test:ts",
29
29
  "pretest": "pnpm run build",
30
- "test": "ava"
30
+ "test": "ava",
31
+ "test:ts": "tsc types/index.d.ts test/types.ts --noEmit"
31
32
  },
32
33
  "files": [
33
34
  "dist",
35
+ "types",
34
36
  "README.md",
35
37
  "LICENSE"
36
38
  ],
@@ -44,6 +46,7 @@
44
46
  ],
45
47
  "peerDependencies": {
46
48
  "@babel/core": "^7.0.0",
49
+ "@types/babel__core": "^7.1.9",
47
50
  "rollup": "^1.20.0||^2.0.0"
48
51
  },
49
52
  "dependencies": {
@@ -58,6 +61,7 @@
58
61
  "@babel/plugin-transform-runtime": "^7.7.4",
59
62
  "@babel/preset-env": "^7.9.0",
60
63
  "@rollup/plugin-json": "^4.0.0",
64
+ "@types/babel__core": "^7.1.9",
61
65
  "rollup": "^2.0.0",
62
66
  "source-map": "^0.6.1"
63
67
  },
@@ -73,5 +77,11 @@
73
77
  "Bogdan Chadkin <trysound@yandex.ru>",
74
78
  "Mateusz Burzyński <mateuszburzynski@gmail.com> (https://github.com/Andarist)"
75
79
  ],
76
- "module": "dist/index.es.js"
80
+ "module": "dist/index.es.js",
81
+ "peerDependenciesMeta": {
82
+ "@types/babel__core": {
83
+ "optional": true
84
+ }
85
+ },
86
+ "types": "types/index.d.ts"
77
87
  }
@@ -0,0 +1,106 @@
1
+ import { Plugin } from 'rollup';
2
+ import { FilterPattern } from '@rollup/pluginutils';
3
+ import * as babelCore from '@babel/core';
4
+
5
+ export interface RollupBabelInputPluginOptions
6
+ extends Omit<babelCore.TransformOptions, 'include' | 'exclude'> {
7
+ /**
8
+ * A minimatch 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
+ * @default undefined;
10
+ */
11
+ include?: FilterPattern;
12
+ /**
13
+ * A minimatch 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
+ * @default undefined;
15
+ */
16
+ exclude?: FilterPattern;
17
+ /**
18
+ * 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.
19
+ * @default ['.js', '.jsx', '.es6', '.es', '.mjs']
20
+ */
21
+ extensions?: string[];
22
+ /**
23
+ * It is recommended to configure this option explicitly (even if with its default value) so an informed decision is taken on how those babel helpers are inserted into the code.
24
+ * @default 'bundled'
25
+ */
26
+ babelHelpers?: 'bundled' | 'runtime' | 'inline' | 'external';
27
+ /**
28
+ * Before transpiling your input files this plugin also transpile a short piece of code for each input file. This is used to validate some misconfiguration errors, but for sufficiently big projects it can slow your build times so if you are confident about your configuration then you might disable those checks with this option.
29
+ * @default false
30
+ */
31
+ skipPreflightCheck?: boolean;
32
+ }
33
+
34
+ export interface RollupBabelOutputPluginOptions
35
+ extends Omit<babelCore.TransformOptions, 'include' | 'exclude'> {
36
+ /**
37
+ * Use with other formats than UMD/IIFE.
38
+ * @default false
39
+ */
40
+ allowAllFormats?: boolean;
41
+ }
42
+
43
+ export type RollupBabelCustomInputPluginOptions = (
44
+ options: RollupBabelInputPluginOptions & Record<string, any>
45
+ ) => {
46
+ customOptions: Record<string, any>;
47
+ pluginOptions: RollupBabelInputPluginOptions;
48
+ };
49
+ export type RollupBabelCustomOutputPluginOptions = (
50
+ options: RollupBabelOutputPluginOptions & Record<string, any>
51
+ ) => {
52
+ customOptions: Record<string, any>;
53
+ pluginOptions: RollupBabelOutputPluginOptions;
54
+ };
55
+ export type RollupBabelCustomPluginConfig = (
56
+ cfg: babelCore.PartialConfig,
57
+ options: { code: string; customOptions: Record<string, any> }
58
+ ) => babelCore.TransformOptions;
59
+ export type RollupBabelCustomPluginResult = (
60
+ result: babelCore.BabelFileResult,
61
+ options: {
62
+ code: string;
63
+ customOptions: Record<string, any>;
64
+ config: babelCore.PartialConfig;
65
+ transformOptions: babelCore.TransformOptions;
66
+ }
67
+ ) => babelCore.BabelFileResult;
68
+ export interface RollupBabelCustomInputPlugin {
69
+ options?: RollupBabelCustomInputPluginOptions;
70
+ config?: RollupBabelCustomPluginConfig;
71
+ result?: RollupBabelCustomPluginResult;
72
+ }
73
+ export interface RollupBabelCustomOutputPlugin {
74
+ options?: RollupBabelCustomOutputPluginOptions;
75
+ config?: RollupBabelCustomPluginConfig;
76
+ result?: RollupBabelCustomPluginResult;
77
+ }
78
+ export type RollupBabelCustomInputPluginBuilder = (
79
+ babel: typeof babelCore
80
+ ) => RollupBabelCustomInputPlugin;
81
+ export type RollupBabelCustomOutputPluginBuilder = (
82
+ babel: typeof babelCore
83
+ ) => RollupBabelCustomOutputPlugin;
84
+
85
+ /**
86
+ * A Rollup plugin for seamless integration between Rollup and Babel.
87
+ * @param options - Plugin options.
88
+ * @returns Plugin instance.
89
+ */
90
+ export function getBabelInputPlugin(options?: RollupBabelInputPluginOptions): Plugin;
91
+ export function getBabelOutputPlugin(options?: RollupBabelOutputPluginOptions): Plugin;
92
+
93
+ export function createBabelInputPluginFactory(
94
+ customCallback?: RollupBabelCustomInputPluginBuilder
95
+ ): typeof getBabelInputPlugin;
96
+ export function createBabelOutputPluginFactory(
97
+ customCallback?: RollupBabelCustomOutputPluginBuilder
98
+ ): typeof getBabelOutputPlugin;
99
+
100
+ /**
101
+ * A Rollup plugin for seamless integration between Rollup and Babel.
102
+ * @param options - Plugin options.
103
+ * @returns Plugin instance.
104
+ */
105
+ export function babel(options?: RollupBabelInputPluginOptions): Plugin;
106
+ export default babel;