1 | # @babel/preset-stage-1
|
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 1
|
15 | "@babel/plugin-proposal-export-default-from",
|
16 | "@babel/plugin-proposal-logical-assignment-operators",
|
17 | ["@babel/plugin-proposal-optional-chaining", { "loose": false }],
|
18 | ["@babel/plugin-proposal-pipeline-operator", { "proposal": "minimal" }],
|
19 | ["@babel/plugin-proposal-nullish-coalescing-operator", { "loose": false }],
|
20 | "@babel/plugin-proposal-do-expressions",
|
21 |
|
22 | // Stage 2
|
23 | ["@babel/plugin-proposal-decorators", { "legacy": true }],
|
24 | "@babel/plugin-proposal-function-sent",
|
25 | "@babel/plugin-proposal-export-namespace-from",
|
26 | "@babel/plugin-proposal-numeric-separator",
|
27 | "@babel/plugin-proposal-throw-expressions",
|
28 |
|
29 | // Stage 3
|
30 | "@babel/plugin-syntax-dynamic-import",
|
31 | "@babel/plugin-syntax-import-meta",
|
32 | ["@babel/plugin-proposal-class-properties", { "loose": true }],
|
33 | "@babel/plugin-proposal-json-strings"
|
34 | ]
|
35 | }
|
36 | ```
|
37 |
|
38 | If you're using the same configuration across many separate projects,
|
39 | keep in mind that you can also create your own custom presets with
|
40 | whichever plugins and presets you're looking to use.
|
41 |
|
42 | ```js
|
43 | module.exports = function() {
|
44 | return {
|
45 | plugins: [
|
46 | require("@babel/plugin-syntax-dynamic-import"),
|
47 | [require("@babel/plugin-proposal-decorators"), { "legacy": true }],
|
48 | [require("@babel/plugin-proposal-class-properties"), { "loose": false }],
|
49 | ],
|
50 | presets: [
|
51 | // ...
|
52 | ],
|
53 | };
|
54 | };
|
55 | ```
|
56 |
|
57 | **NOTE: Compatibility between `@babel/plugin-proposal-class-properties` and `@babel/plugin-proposal-decorators`**
|
58 | 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`.
|
59 |
|
60 | When using the `legacy: true` option of `@babel/plugin-proposal-decorators`, `@babel/plugin-proposal-class-properties` must be used in `loose: true` mode.
|
61 |
|
62 | If you are not using `@babel/plugin-proposal-decorators`, `loose` mode is not needed. |
\ | No newline at end of file |