Throw when using Stage presets (#8293)

* inline stage presets into standalone, throw error with using Stage presets
This commit is contained in:
Henry Zhu 2018-07-23 22:22:52 -04:00 committed by GitHub
parent 6f3a800677
commit c70a32ab9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 470 additions and 259 deletions

View File

@ -1,7 +1,10 @@
{ {
"compact": false, "compact": false,
"presets": [ "presets": [
"env", "env"
["stage-2", { "decoratorsLegacy": true }] ],
"plugins": [
"external-helpers",
"proposal-object-rest-spread"
] ]
} }

View File

@ -1,6 +1,5 @@
{ {
"presets": [ "presets": [
["stage-0", { "decoratorsLegacy": true, "pipelineProposal": "minimal" }],
"env" "env"
] ]
} }

View File

@ -1,7 +1,6 @@
{ {
"plugins": ["external-helpers", ["proposal-class-properties", {"loose": true}]], "plugins": ["external-helpers", ["proposal-class-properties", {"loose": true}]],
"presets": [ "presets": [
["stage-0", { "decoratorsLegacy": true, "pipelineProposal": "minimal" }],
"env" "env"
] ]
} }

View File

@ -1,7 +1,6 @@
{ {
"plugins": ["external-helpers", "proposal-class-properties"], "plugins": ["external-helpers", "proposal-class-properties"],
"presets": [ "presets": [
["stage-0", { "decoratorsLegacy": true, "pipelineProposal": "minimal" }],
"env" "env"
] ]
} }

View File

@ -1,6 +1,8 @@
{ {
"presets": [ "presets": [
"env", "env"
["stage-2", { "decoratorsLegacy": true }] ],
"plugins": [
"proposal-class-properties"
] ]
} }

View File

@ -1,6 +1,5 @@
{ {
"presets": [ "presets": [
"env", "env"
["stage-0", { "decoratorsLegacy": true, "pipelineProposal": "minimal" }]
] ]
} }

View File

@ -1,19 +1,64 @@
# @babel/preset-stage-0 # @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 // Stage 1
npm install --save-dev @babel/preset-stage-0 "@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 ```js
yarn add @babel/preset-stage-0 --dev 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: [
// ...
],
};
};
``` ```

View File

@ -6,16 +6,5 @@
"homepage": "https://babeljs.io/", "homepage": "https://babeljs.io/",
"license": "MIT", "license": "MIT",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-preset-stage-0", "repository": "https://github.com/babel/babel/tree/master/packages/babel-preset-stage-0",
"main": "lib/index.js", "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"
}
} }

View File

@ -1,39 +1,60 @@
import { declare } from "@babel/helper-plugin-utils"; export default function() {
import presetStage1 from "@babel/preset-stage-1"; 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 { // Stage 1
loose = false, "@babel/plugin-proposal-export-default-from",
useBuiltIns = false, "@babel/plugin-proposal-logical-assignment-operators",
decoratorsLegacy = true, ["@babel/plugin-proposal-optional-chaining", { "loose": false }],
pipelineProposal = "minimal", ["@babel/plugin-proposal-pipeline-operator", { "proposal": "minimal" }],
} = opts; ["@babel/plugin-proposal-nullish-coalescing-operator", { "loose": false }],
"@babel/plugin-proposal-do-expressions",
if (typeof loose !== "boolean") { // Stage 2
throw new Error("@babel/preset-stage-0 'loose' option must be a boolean."); ["@babel/plugin-proposal-decorators", { "legacy": true }],
} "@babel/plugin-proposal-function-sent",
if (typeof useBuiltIns !== "boolean") { "@babel/plugin-proposal-export-namespace-from",
throw new Error( "@babel/plugin-proposal-numeric-separator",
"@babel/preset-stage-0 'useBuiltIns' option must be a boolean.", "@babel/plugin-proposal-throw-expressions",
);
}
if (typeof decoratorsLegacy !== "boolean") {
throw new Error(
"@babel/preset-stage-0 'decoratorsLegacy' option must be a boolean.",
);
}
// 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 { return {
plugins: [
require("@babel/plugin-syntax-dynamic-import"),
[require("@babel/plugin-proposal-decorators"), { "legacy": true }],
[require("@babel/plugin-proposal-class-properties"), { "loose": false }],
],
presets: [ presets: [
[ // ...
presetStage1,
{ loose, useBuiltIns, decoratorsLegacy, pipelineProposal },
], ],
],
plugins: [transformFunctionBind],
}; };
}); };
`);
}

View File

@ -1,19 +1,61 @@
# @babel/preset-stage-1 # @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 // Stage 2
npm install --save-dev @babel/preset-stage-1 ["@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 ```js
yarn add @babel/preset-stage-1 --dev 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: [
// ...
],
};
};
``` ```

View File

@ -6,21 +6,5 @@
"homepage": "https://babeljs.io/", "homepage": "https://babeljs.io/",
"license": "MIT", "license": "MIT",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-preset-stage-1", "repository": "https://github.com/babel/babel/tree/master/packages/babel-preset-stage-1",
"main": "lib/index.js", "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"
}
} }

View File

@ -1,46 +1,57 @@
import { declare } from "@babel/helper-plugin-utils"; export default function() {
import presetStage2 from "@babel/preset-stage-2"; 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-1"
import transformExportDefaultFrom from "@babel/plugin-proposal-export-default-from"; If you want the same configuration as before:
import transformLogicalAssignmentOperators from "@babel/plugin-proposal-logical-assignment-operators";
import transformOptionalChaining from "@babel/plugin-proposal-optional-chaining";
import transformPipelineOperator from "@babel/plugin-proposal-pipeline-operator";
import transformNullishCoalescingOperator from "@babel/plugin-proposal-nullish-coalescing-operator";
import transformDoExpressions from "@babel/plugin-proposal-do-expressions";
export default declare((api, opts = {}) => { {
api.assertVersion(7); "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",
const { // Stage 2
loose = false, ["@babel/plugin-proposal-decorators", { "legacy": true }],
useBuiltIns = false, "@babel/plugin-proposal-function-sent",
decoratorsLegacy = true, "@babel/plugin-proposal-export-namespace-from",
pipelineProposal = "minimal", "@babel/plugin-proposal-numeric-separator",
} = opts; "@babel/plugin-proposal-throw-expressions",
if (typeof loose !== "boolean") { // Stage 3
throw new Error("@babel/preset-stage-1 'loose' option must be a boolean."); "@babel/plugin-syntax-dynamic-import",
} "@babel/plugin-syntax-import-meta",
if (typeof useBuiltIns !== "boolean") { ["@babel/plugin-proposal-class-properties", { "loose": false }],
throw new Error( "@babel/plugin-proposal-json-strings"
"@babel/preset-stage-1 'useBuiltIns' option must be a boolean.", ]
); }
}
if (typeof decoratorsLegacy !== "boolean") {
throw new Error(
"@babel/preset-stage-1 'decoratorsLegacy' option must be a boolean.",
);
}
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 { return {
presets: [[presetStage2, { loose, useBuiltIns, decoratorsLegacy }]],
plugins: [ plugins: [
transformExportDefaultFrom, require("@babel/plugin-syntax-dynamic-import"),
transformLogicalAssignmentOperators, [require("@babel/plugin-proposal-decorators"), { "legacy": true }],
[transformOptionalChaining, { loose }], [require("@babel/plugin-proposal-class-properties"), { "loose": false }],
[transformPipelineOperator, { proposal: pipelineProposal }], ],
[transformNullishCoalescingOperator, { loose }], presets: [
transformDoExpressions, // ...
], ],
}; };
}); };
`);
}

View File

@ -1,19 +1,53 @@
# @babel/preset-stage-2 # @babel/preset-stage-2
> Babel preset for stage 2 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-2"
See our website [@babel/preset-stage-2](https://babeljs.io/docs/en/next/babel-preset-stage-2.html) for more information. ---
## Install If you want the same configuration as before:
Using npm: ```json
{
"plugins": [
// 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",
```sh // Stage 3
npm install --save-dev @babel/preset-stage-2 "@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 ```js
yarn add @babel/preset-stage-2 --dev 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: [
// ...
],
};
};
``` ```

View File

@ -6,20 +6,5 @@
"homepage": "https://babeljs.io/", "homepage": "https://babeljs.io/",
"license": "MIT", "license": "MIT",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-preset-stage-2", "repository": "https://github.com/babel/babel/tree/master/packages/babel-preset-stage-2",
"main": "lib/index.js", "main": "lib/index.js"
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.54",
"@babel/plugin-proposal-decorators": "7.0.0-beta.54",
"@babel/plugin-proposal-export-namespace-from": "7.0.0-beta.54",
"@babel/plugin-proposal-function-sent": "7.0.0-beta.54",
"@babel/plugin-proposal-numeric-separator": "7.0.0-beta.54",
"@babel/plugin-proposal-throw-expressions": "7.0.0-beta.54",
"@babel/preset-stage-3": "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"
}
} }

View File

@ -1,39 +1,49 @@
import { declare } from "@babel/helper-plugin-utils"; export default function() {
import presetStage3 from "@babel/preset-stage-3"; 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-2"
import transformDecorators from "@babel/plugin-proposal-decorators"; If you want the same configuration as before:
import transformFunctionSent from "@babel/plugin-proposal-function-sent";
import transformExportNamespaceFrom from "@babel/plugin-proposal-export-namespace-from";
import transformNumericSeparator from "@babel/plugin-proposal-numeric-separator";
import transformThrowExpressions from "@babel/plugin-proposal-throw-expressions";
export default declare((api, opts = {}) => { {
api.assertVersion(7); "plugins": [
// 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",
const { loose = false, useBuiltIns = false, decoratorsLegacy = true } = opts; // 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 (typeof loose !== "boolean") { If you're using the same configuration across many separate projects,
throw new Error("@babel/preset-stage-2 'loose' option must be a boolean."); keep in mind that you can also create your own custom presets with
} whichever plugins and presets you're looking to use.
if (typeof useBuiltIns !== "boolean") {
throw new Error(
"@babel/preset-stage-2 'useBuiltIns' option must be a boolean.",
);
}
if (typeof decoratorsLegacy !== "boolean") {
throw new Error(
"@babel/preset-stage-2 'decoratorsLegacy' option must be a boolean.",
);
}
module.exports = function() {
return { return {
presets: [[presetStage3, { loose, useBuiltIns }]],
plugins: [ plugins: [
[transformDecorators, { legacy: decoratorsLegacy }], require("@babel/plugin-syntax-dynamic-import"),
transformFunctionSent, [require("@babel/plugin-proposal-decorators"), { "legacy": true }],
transformExportNamespaceFrom, [require("@babel/plugin-proposal-class-properties"), { "loose": false }],
transformNumericSeparator, ],
transformThrowExpressions, presets: [
// ...
], ],
}; };
}); };
`);
}

View File

@ -1,19 +1,45 @@
# @babel/preset-stage-3 # @babel/preset-stage-3
> Babel preset for stage 3 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-3"
See our website [@babel/preset-stage-3](https://babeljs.io/docs/en/next/babel-preset-stage-3.html) for more information. ---
## Install If you want the same configuration as before:
Using npm: ```json
{
```sh "plugins": [
npm install --save-dev @babel/preset-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 ```js
yarn add @babel/preset-stage-3 --dev 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: [
// ...
],
};
};
``` ```

View File

@ -6,22 +6,5 @@
"homepage": "https://babeljs.io/", "homepage": "https://babeljs.io/",
"license": "MIT", "license": "MIT",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-preset-stage-3", "repository": "https://github.com/babel/babel/tree/master/packages/babel-preset-stage-3",
"main": "lib/index.js", "main": "lib/index.js"
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.54",
"@babel/plugin-proposal-async-generator-functions": "7.0.0-beta.54",
"@babel/plugin-proposal-class-properties": "7.0.0-beta.54",
"@babel/plugin-proposal-json-strings": "7.0.0-beta.54",
"@babel/plugin-proposal-object-rest-spread": "7.0.0-beta.54",
"@babel/plugin-proposal-optional-catch-binding": "7.0.0-beta.54",
"@babel/plugin-proposal-unicode-property-regex": "7.0.0-beta.54",
"@babel/plugin-syntax-dynamic-import": "7.0.0-beta.54",
"@babel/plugin-syntax-import-meta": "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"
}
} }

View File

@ -1,43 +1,42 @@
import { declare } from "@babel/helper-plugin-utils"; export default function() {
import syntaxDynamicImport from "@babel/plugin-syntax-dynamic-import"; throw new Error(`
import syntaxImportMeta from "@babel/plugin-syntax-import-meta"; As of v7.0.0-beta.54, we've decided to remove
import transformAsyncGeneratorFunctions from "@babel/plugin-proposal-async-generator-functions"; the official Babel Stage presets. You can find more information
import transformClassProperties from "@babel/plugin-proposal-class-properties"; at issue #7770: https://github.com/babel/babel/issues/7770, but
import transformJsonStrings from "@babel/plugin-proposal-json-strings"; the TL;DR is that it's causing more harm than convenience in that
import transformObjectRestSpread from "@babel/plugin-proposal-object-rest-spread"; the preset is always out of date, each change is usually going to
import transformOptionalCatchBinding from "@babel/plugin-proposal-optional-catch-binding"; require a major version bump and thus people will be behind,
import transformUnicodePropertyRegex from "@babel/plugin-proposal-unicode-property-regex"; 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-3"
export default declare((api, opts) => { If you want the same configuration as before:
api.assertVersion(7);
let loose = false; {
let useBuiltIns = false; "plugins": [
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-syntax-import-meta",
["@babel/plugin-proposal-class-properties", { "loose": false }],
"@babel/plugin-proposal-json-strings"
]
}
if (opts !== undefined) {
if (opts.loose !== undefined) loose = opts.loose;
if (opts.useBuiltIns !== undefined) useBuiltIns = opts.useBuiltIns;
}
if (typeof loose !== "boolean") { If you're using the same configuration across many separate projects,
throw new Error("@babel/preset-stage-3 'loose' option must be a boolean."); keep in mind that you can also create your own custom presets with
} whichever plugins and presets you're looking to use.
if (typeof useBuiltIns !== "boolean") {
throw new Error(
"@babel/preset-stage-3 'useBuiltIns' option must be a boolean.",
);
}
module.exports = function() {
return { return {
plugins: [ plugins: [
syntaxDynamicImport, require("@babel/plugin-syntax-dynamic-import"),
syntaxImportMeta, [require("@babel/plugin-proposal-decorators"), { "legacy": true }],
transformAsyncGeneratorFunctions, [require("@babel/plugin-proposal-class-properties"), { "loose": false }],
[transformClassProperties, { loose }], ],
transformJsonStrings, presets: [
[transformObjectRestSpread, { loose, useBuiltIns }], // ...
transformOptionalCatchBinding,
transformUnicodePropertyRegex,
], ],
}; };
}); };
`);
}

View File

@ -233,10 +233,10 @@ registerPresets({
}; };
}, },
react: require("@babel/preset-react"), react: require("@babel/preset-react"),
"stage-0": require("@babel/preset-stage-0"), "stage-0": require("./preset-stage-0"),
"stage-1": require("@babel/preset-stage-1"), "stage-1": require("./preset-stage-1"),
"stage-2": require("@babel/preset-stage-2"), "stage-2": require("./preset-stage-2"),
"stage-3": require("@babel/preset-stage-3"), "stage-3": require("./preset-stage-3"),
"es2015-loose": { "es2015-loose": {
presets: [[require("./preset-es2015"), { loose: true }]], presets: [[require("./preset-es2015"), { loose: true }]],
}, },

View File

@ -24,7 +24,6 @@ import transformES2015Instanceof from "@babel/plugin-transform-instanceof";
import transformRegenerator from "@babel/plugin-transform-regenerator"; import transformRegenerator from "@babel/plugin-transform-regenerator";
export default (_, opts) => { export default (_, opts) => {
const moduleTypes = ["commonjs", "cjs", "amd", "umd", "systemjs"];
let loose = false; let loose = false;
let modules = "commonjs"; let modules = "commonjs";
let spec = false; let spec = false;
@ -35,19 +34,6 @@ export default (_, opts) => {
if (opts.spec !== undefined) spec = opts.spec; if (opts.spec !== undefined) spec = opts.spec;
} }
if (typeof loose !== "boolean") {
throw new Error("Preset es2015 'loose' option must be a boolean.");
}
if (typeof spec !== "boolean") {
throw new Error("Preset es2015 'spec' option must be a boolean.");
}
if (modules !== false && moduleTypes.indexOf(modules) === -1) {
throw new Error(
"Preset es2015 'modules' option must be 'false' to indicate no modules\n" +
"or a module type which be be one of: 'commonjs' (default), 'amd', 'umd', 'systemjs'",
);
}
// be DRY // be DRY
const optsLoose = { loose }; const optsLoose = { loose };

View File

@ -0,0 +1,22 @@
import presetStage1 from "./preset-stage-1";
import transformFunctionBind from "@babel/plugin-proposal-function-bind";
export default (_, opts = {}) => {
const {
loose = false,
useBuiltIns = false,
decoratorsLegacy = false,
pipelineProposal = "minimal",
} = opts;
return {
presets: [
[
presetStage1,
{ loose, useBuiltIns, decoratorsLegacy, pipelineProposal },
],
],
plugins: [transformFunctionBind],
};
};

View File

@ -0,0 +1,29 @@
import presetStage2 from "./preset-stage-2";
import transformExportDefaultFrom from "@babel/plugin-proposal-export-default-from";
import transformLogicalAssignmentOperators from "@babel/plugin-proposal-logical-assignment-operators";
import transformOptionalChaining from "@babel/plugin-proposal-optional-chaining";
import transformPipelineOperator from "@babel/plugin-proposal-pipeline-operator";
import transformNullishCoalescingOperator from "@babel/plugin-proposal-nullish-coalescing-operator";
import transformDoExpressions from "@babel/plugin-proposal-do-expressions";
export default (_, opts = {}) => {
const {
loose = false,
useBuiltIns = false,
decoratorsLegacy = false,
pipelineProposal = "minimal",
} = opts;
return {
presets: [[presetStage2, { loose, useBuiltIns, decoratorsLegacy }]],
plugins: [
transformExportDefaultFrom,
transformLogicalAssignmentOperators,
[transformOptionalChaining, { loose }],
[transformPipelineOperator, { proposal: pipelineProposal }],
[transformNullishCoalescingOperator, { loose }],
transformDoExpressions,
],
};
};

View File

@ -0,0 +1,22 @@
import presetStage3 from "./preset-stage-3";
import transformDecorators from "@babel/plugin-proposal-decorators";
import transformFunctionSent from "@babel/plugin-proposal-function-sent";
import transformExportNamespaceFrom from "@babel/plugin-proposal-export-namespace-from";
import transformNumericSeparator from "@babel/plugin-proposal-numeric-separator";
import transformThrowExpressions from "@babel/plugin-proposal-throw-expressions";
export default (_, opts = {}) => {
const { loose = false, useBuiltIns = false, decoratorsLegacy = false } = opts;
return {
presets: [[presetStage3, { loose, useBuiltIns }]],
plugins: [
[transformDecorators, { legacy: decoratorsLegacy }],
transformFunctionSent,
transformExportNamespaceFrom,
transformNumericSeparator,
transformThrowExpressions,
],
};
};

View File

@ -0,0 +1,21 @@
import syntaxDynamicImport from "@babel/plugin-syntax-dynamic-import";
import syntaxImportMeta from "@babel/plugin-syntax-import-meta";
import transformClassProperties from "@babel/plugin-proposal-class-properties";
import transformJsonStrings from "@babel/plugin-proposal-json-strings";
export default (_, opts) => {
let loose = false;
if (opts !== undefined) {
if (opts.loose !== undefined) loose = opts.loose;
}
return {
plugins: [
syntaxDynamicImport,
syntaxImportMeta,
[transformClassProperties, { loose }],
transformJsonStrings,
],
};
};

View File

@ -66,6 +66,7 @@ yarn add ${name} --dev
packages packages
.filter(x => x !== "README.md") // ignore root readme .filter(x => x !== "README.md") // ignore root readme
.filter(x => x.indexOf("babel-preset-stage-") === -1) // ignore stages
.forEach(id => { .forEach(id => {
const { name, description } = getPackageJson(id); const { name, description } = getPackageJson(id);
const readmePath = join(packageDir, id, "README.md"); const readmePath = join(packageDir, id, "README.md");