1 | # @babel/preset-stage-2
|
2 |
|
3 | As of v7.0.0-beta.55, we've removed Babel's Stage presets. Please consider reading our [blog post](https://babeljs.io/blog/2018/07/27/removing-babels-stage-presets) on this decision for more details. TL;DR is that it's more beneficial in the long run to explicitly add which proposals to use.
|
4 |
|
5 | ---
|
6 |
|
7 | For a more automatic migration, we have updated [babel-upgrade](https://github.com/babel/babel-upgrade) to do this for you (you can run `npx babel-upgrade`).
|
8 |
|
9 | If you want the same configuration as before:
|
10 |
|
11 | ```jsonc
|
12 | {
|
13 | "plugins": [
|
14 | // Stage 2
|
15 | ["@babel/plugin-proposal-decorators", { "legacy": true }],
|
16 | "@babel/plugin-proposal-function-sent",
|
17 | "@babel/plugin-proposal-export-namespace-from",
|
18 | "@babel/plugin-proposal-numeric-separator",
|
19 | "@babel/plugin-proposal-throw-expressions",
|
20 |
|
21 | // Stage 3
|
22 | "@babel/plugin-syntax-dynamic-import",
|
23 | "@babel/plugin-syntax-import-meta",
|
24 | ["@babel/plugin-proposal-class-properties", { "loose": true }],
|
25 | "@babel/plugin-proposal-json-strings"
|
26 | ]
|
27 | }
|
28 | ```
|
29 |
|
30 | If you're using the same configuration across many separate projects,
|
31 | keep in mind that you can also create your own custom presets with
|
32 | whichever plugins and presets you're looking to use.
|
33 |
|
34 | ```js
|
35 | module.exports = function() {
|
36 | return {
|
37 | plugins: [
|
38 | require("@babel/plugin-syntax-dynamic-import"),
|
39 | [require("@babel/plugin-proposal-decorators"), { "legacy": true }],
|
40 | [require("@babel/plugin-proposal-class-properties"), { "loose": false }],
|
41 | ],
|
42 | presets: [
|
43 | // ...
|
44 | ],
|
45 | };
|
46 | };
|
47 | ```
|
48 |
|
49 | **NOTE: Compatibility between `@babel/plugin-proposal-class-properties` and `@babel/plugin-proposal-decorators`**
|
50 | If you are including your plugins manually and using `@babel/plugin-proposal-class-properties`, make sure that `@babel/plugin-proposal-decorators` comes before `@babel/plugin-proposal-class-properties`.
|
51 |
|
52 | When using the `legacy: true` option of `@babel/plugin-proposal-decorators`, `@babel/plugin-proposal-class-properties` must be used in `loose: true` mode.
|
53 |
|
54 | If you are not using `@babel/plugin-proposal-decorators`, `loose` mode is not needed. |
\ | No newline at end of file |