Skip to content

Commit

Permalink
Throw when using Stage presets (#8293)
Browse files Browse the repository at this point in the history
* inline stage presets into standalone, throw error with using Stage presets
  • Loading branch information
hzoo committed Jul 24, 2018
1 parent 6f3a800 commit c70a32a
Show file tree
Hide file tree
Showing 25 changed files with 469 additions and 258 deletions.
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"
]
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"presets": [
["stage-0", { "decoratorsLegacy": true, "pipelineProposal": "minimal" }],
"env"
]
}
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"
]
}
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"
]
}
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"
]
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"presets": [
"env",
["stage-0", { "decoratorsLegacy": true, "pipelineProposal": "minimal" }]
"env"
]
}
63 changes: 54 additions & 9 deletions packages/babel-preset-stage-0/README.md
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: [
// ...
],
};
};
```
13 changes: 1 addition & 12 deletions packages/babel-preset-stage-0/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,5 @@
"homepage": "https://babeljs.io/",
"license": "MIT",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-preset-stage-0",
"main": "lib/index.js",
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.54",
"@babel/plugin-proposal-function-bind": "7.0.0-beta.54",
"@babel/preset-stage-1": "7.0.0-beta.54"
},
"peerDependencies": {
"@babel/core": ">=7.0.0-beta.50 <7.0.0-rc.0"
},
"devDependencies": {
"@babel/core": "7.0.0-beta.54"
}
"main": "lib/index.js"
}
81 changes: 51 additions & 30 deletions packages/babel-preset-stage-0/src/index.js
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],
};
});
};
`);
}
60 changes: 51 additions & 9 deletions packages/babel-preset-stage-1/README.md
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: [
// ...
],
};
};
```
18 changes: 1 addition & 17 deletions packages/babel-preset-stage-1/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,5 @@
"homepage": "https://babeljs.io/",
"license": "MIT",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-preset-stage-1",
"main": "lib/index.js",
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.54",
"@babel/plugin-proposal-do-expressions": "7.0.0-beta.54",
"@babel/plugin-proposal-export-default-from": "7.0.0-beta.54",
"@babel/plugin-proposal-logical-assignment-operators": "7.0.0-beta.54",
"@babel/plugin-proposal-nullish-coalescing-operator": "7.0.0-beta.54",
"@babel/plugin-proposal-optional-chaining": "7.0.0-beta.54",
"@babel/plugin-proposal-pipeline-operator": "7.0.0-beta.54",
"@babel/preset-stage-2": "7.0.0-beta.54"
},
"peerDependencies": {
"@babel/core": ">=7.0.0-beta.50 <7.0.0-rc.0"
},
"devDependencies": {
"@babel/core": "7.0.0-beta.54"
}
"main": "lib/index.js"
}

0 comments on commit c70a32a

Please sign in to comment.