-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Throw when using Stage presets (#8293)
* inline stage presets into standalone, throw error with using Stage presets
- Loading branch information
Showing
25 changed files
with
469 additions
and
258 deletions.
There are no files selected for viewing
7 changes: 5 additions & 2 deletions
7
packages/babel-core/test/fixtures/transformation/misc/regression-4855/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
{ | ||
"compact": false, | ||
"presets": [ | ||
"env", | ||
["stage-2", { "decoratorsLegacy": true }] | ||
"env" | ||
], | ||
"plugins": [ | ||
"external-helpers", | ||
"proposal-object-rest-spread" | ||
] | ||
} |
1 change: 0 additions & 1 deletion
1
...es/babel-plugin-proposal-class-properties/test/fixtures/private-loose/foobar/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
{ | ||
"presets": [ | ||
["stage-0", { "decoratorsLegacy": true, "pipelineProposal": "minimal" }], | ||
"env" | ||
] | ||
} |
1 change: 0 additions & 1 deletion
1
...ges/babel-plugin-proposal-class-properties/test/fixtures/public-loose/foobar/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
{ | ||
"plugins": ["external-helpers", ["proposal-class-properties", {"loose": true}]], | ||
"presets": [ | ||
["stage-0", { "decoratorsLegacy": true, "pipelineProposal": "minimal" }], | ||
"env" | ||
] | ||
} |
1 change: 0 additions & 1 deletion
1
packages/babel-plugin-proposal-class-properties/test/fixtures/public/foobar/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
{ | ||
"plugins": ["external-helpers", "proposal-class-properties"], | ||
"presets": [ | ||
["stage-0", { "decoratorsLegacy": true, "pipelineProposal": "minimal" }], | ||
"env" | ||
] | ||
} |
6 changes: 4 additions & 2 deletions
6
packages/babel-plugin-proposal-class-properties/test/fixtures/regression/6154/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
{ | ||
"presets": [ | ||
"env", | ||
["stage-2", { "decoratorsLegacy": true }] | ||
"env" | ||
], | ||
"plugins": [ | ||
"proposal-class-properties" | ||
] | ||
} |
3 changes: 1 addition & 2 deletions
3
packages/babel-plugin-proposal-decorators/test/fixtures/legacy-regression/7030/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
{ | ||
"presets": [ | ||
"env", | ||
["stage-0", { "decoratorsLegacy": true, "pipelineProposal": "minimal" }] | ||
"env" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,64 @@ | ||
# @babel/preset-stage-0 | ||
|
||
> Babel preset for stage 0 plugins | ||
> As of v7.0.0-beta.54, we've decided to remove | ||
the official Babel Stage presets. You can find more information | ||
at issue [#7770](https://github.com/babel/babel/issues/7770), but | ||
the TL;DR is that it's causing more harm than convenience in that | ||
the preset is always out of date, each change is usually going to | ||
require a major version bump and thus people will be behind, | ||
and it encouraged too many people to opt-in to too many proposals | ||
that they didn't intend to. This is intended to be the last publish | ||
of "@babel/preset-stage-0" | ||
|
||
See our website [@babel/preset-stage-0](https://babeljs.io/docs/en/next/babel-preset-stage-0.html) for more information. | ||
--- | ||
|
||
## Install | ||
If you want the same configuration as before: | ||
|
||
Using npm: | ||
```json | ||
{ | ||
"plugins": [ | ||
// Stage 0 | ||
"@babel/plugin-proposal-function-bind", | ||
|
||
```sh | ||
npm install --save-dev @babel/preset-stage-0 | ||
// Stage 1 | ||
"@babel/plugin-proposal-export-default-from", | ||
"@babel/plugin-proposal-logical-assignment-operators", | ||
["@babel/plugin-proposal-optional-chaining", { "loose": false }], | ||
["@babel/plugin-proposal-pipeline-operator", { "proposal": "minimal" }], | ||
["@babel/plugin-proposal-nullish-coalescing-operator", { "loose": false }], | ||
"@babel/plugin-proposal-do-expressions", | ||
|
||
// Stage 2 | ||
["@babel/plugin-proposal-decorators", { "legacy": true }], | ||
"@babel/plugin-proposal-function-sent", | ||
"@babel/plugin-proposal-export-namespace-from", | ||
"@babel/plugin-proposal-numeric-separator", | ||
"@babel/plugin-proposal-throw-expressions", | ||
|
||
// Stage 3 | ||
"@babel/plugin-syntax-dynamic-import", | ||
"@babel/plugin-syntax-import-meta", | ||
["@babel/plugin-proposal-class-properties", { "loose": false }], | ||
"@babel/plugin-proposal-json-strings" | ||
] | ||
} | ||
``` | ||
|
||
or using yarn: | ||
If you're using the same configuration across many separate projects, | ||
keep in mind that you can also create your own custom presets with | ||
whichever plugins and presets you're looking to use. | ||
|
||
```sh | ||
yarn add @babel/preset-stage-0 --dev | ||
```js | ||
module.exports = function() { | ||
return { | ||
plugins: [ | ||
require("@babel/plugin-syntax-dynamic-import"), | ||
[require("@babel/plugin-proposal-decorators"), { "legacy": true }], | ||
[require("@babel/plugin-proposal-class-properties"), { "loose": false }], | ||
], | ||
presets: [ | ||
// ... | ||
], | ||
}; | ||
}; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,60 @@ | ||
import { declare } from "@babel/helper-plugin-utils"; | ||
import presetStage1 from "@babel/preset-stage-1"; | ||
export default function() { | ||
throw new Error(` | ||
As of v7.0.0-beta.54, we've decided to remove | ||
the official Babel Stage presets. You can find more information | ||
at issue #7770: https://github.com/babel/babel/issues/7770, but | ||
the TL;DR is that it's causing more harm than convenience in that | ||
the preset is always out of date, each change is usually going to | ||
require a major version bump and thus people will be behind, | ||
and it encouraged too many people to opt-in to too many proposals | ||
that they didn't intend to. This is intended to be the last publish | ||
of "@babel/preset-stage-0" | ||
import transformFunctionBind from "@babel/plugin-proposal-function-bind"; | ||
If you want the same configuration as before: | ||
export default declare((api, opts = {}) => { | ||
api.assertVersion(7); | ||
{ | ||
"plugins": [ | ||
// Stage 0 | ||
"@babel/plugin-proposal-function-bind", | ||
const { | ||
loose = false, | ||
useBuiltIns = false, | ||
decoratorsLegacy = true, | ||
pipelineProposal = "minimal", | ||
} = opts; | ||
// Stage 1 | ||
"@babel/plugin-proposal-export-default-from", | ||
"@babel/plugin-proposal-logical-assignment-operators", | ||
["@babel/plugin-proposal-optional-chaining", { "loose": false }], | ||
["@babel/plugin-proposal-pipeline-operator", { "proposal": "minimal" }], | ||
["@babel/plugin-proposal-nullish-coalescing-operator", { "loose": false }], | ||
"@babel/plugin-proposal-do-expressions", | ||
if (typeof loose !== "boolean") { | ||
throw new Error("@babel/preset-stage-0 'loose' option must be a boolean."); | ||
} | ||
if (typeof useBuiltIns !== "boolean") { | ||
throw new Error( | ||
"@babel/preset-stage-0 'useBuiltIns' option must be a boolean.", | ||
); | ||
} | ||
if (typeof decoratorsLegacy !== "boolean") { | ||
throw new Error( | ||
"@babel/preset-stage-0 'decoratorsLegacy' option must be a boolean.", | ||
); | ||
} | ||
// Stage 2 | ||
["@babel/plugin-proposal-decorators", { "legacy": true }], | ||
"@babel/plugin-proposal-function-sent", | ||
"@babel/plugin-proposal-export-namespace-from", | ||
"@babel/plugin-proposal-numeric-separator", | ||
"@babel/plugin-proposal-throw-expressions", | ||
// Stage 3 | ||
"@babel/plugin-syntax-dynamic-import", | ||
"@babel/plugin-syntax-import-meta", | ||
["@babel/plugin-proposal-class-properties", { "loose": false }], | ||
"@babel/plugin-proposal-json-strings" | ||
] | ||
} | ||
If you're using the same configuration across many separate projects, | ||
keep in mind that you can also create your own custom presets with | ||
whichever plugins and presets you're looking to use. | ||
module.exports = function() { | ||
return { | ||
plugins: [ | ||
require("@babel/plugin-syntax-dynamic-import"), | ||
[require("@babel/plugin-proposal-decorators"), { "legacy": true }], | ||
[require("@babel/plugin-proposal-class-properties"), { "loose": false }], | ||
], | ||
presets: [ | ||
[ | ||
presetStage1, | ||
{ loose, useBuiltIns, decoratorsLegacy, pipelineProposal }, | ||
], | ||
// ... | ||
], | ||
plugins: [transformFunctionBind], | ||
}; | ||
}); | ||
}; | ||
`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,61 @@ | ||
# @babel/preset-stage-1 | ||
|
||
> Babel preset for stage 1 plugins | ||
> As of v7.0.0-beta.54, we've decided to remove | ||
the official Babel Stage presets. You can find more information | ||
at issue [#7770](https://github.com/babel/babel/issues/7770), but | ||
the TL;DR is that it's causing more harm than convenience in that | ||
the preset is always out of date, each change is usually going to | ||
require a major version bump and thus people will be behind, | ||
and it encouraged too many people to opt-in to too many proposals | ||
that they didn't intend to. This is intended to be the last publish | ||
of "@babel/preset-stage-1" | ||
|
||
See our website [@babel/preset-stage-1](https://babeljs.io/docs/en/next/babel-preset-stage-1.html) for more information. | ||
--- | ||
|
||
## Install | ||
If you want the same configuration as before: | ||
|
||
Using npm: | ||
```json | ||
{ | ||
"plugins": [ | ||
// Stage 1 | ||
"@babel/plugin-proposal-export-default-from", | ||
"@babel/plugin-proposal-logical-assignment-operators", | ||
["@babel/plugin-proposal-optional-chaining", { "loose": false }], | ||
["@babel/plugin-proposal-pipeline-operator", { "proposal": "minimal" }], | ||
["@babel/plugin-proposal-nullish-coalescing-operator", { "loose": false }], | ||
"@babel/plugin-proposal-do-expressions", | ||
|
||
```sh | ||
npm install --save-dev @babel/preset-stage-1 | ||
// Stage 2 | ||
["@babel/plugin-proposal-decorators", { "legacy": true }], | ||
"@babel/plugin-proposal-function-sent", | ||
"@babel/plugin-proposal-export-namespace-from", | ||
"@babel/plugin-proposal-numeric-separator", | ||
"@babel/plugin-proposal-throw-expressions", | ||
|
||
// Stage 3 | ||
"@babel/plugin-syntax-dynamic-import", | ||
"@babel/plugin-syntax-import-meta", | ||
["@babel/plugin-proposal-class-properties", { "loose": false }], | ||
"@babel/plugin-proposal-json-strings" | ||
] | ||
} | ||
``` | ||
|
||
or using yarn: | ||
If you're using the same configuration across many separate projects, | ||
keep in mind that you can also create your own custom presets with | ||
whichever plugins and presets you're looking to use. | ||
|
||
```sh | ||
yarn add @babel/preset-stage-1 --dev | ||
```js | ||
module.exports = function() { | ||
return { | ||
plugins: [ | ||
require("@babel/plugin-syntax-dynamic-import"), | ||
[require("@babel/plugin-proposal-decorators"), { "legacy": true }], | ||
[require("@babel/plugin-proposal-class-properties"), { "loose": false }], | ||
], | ||
presets: [ | ||
// ... | ||
], | ||
}; | ||
}; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.