standalone: update preset-stage-* (#13476)

* Move classStaticBlock to stage-3

* Remove stage-4 proposals

* Move PrivatePropertyInObject

* Remove options from preset-stage-3

* Move RecordAndTuple to stage-2

* Move ModuleBlocks to stage-2

* Undo breaking change

Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
This commit is contained in:
Sosuke Suzuki 2021-08-04 07:36:38 +09:00 committed by GitHub
parent ddaf0d4296
commit 13af87cd3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 17 deletions

View File

@ -9,20 +9,24 @@ export default (_: any, opts: any = {}) => {
decoratorsBeforeExport,
pipelineProposal = "minimal",
pipelineTopicToken = "%",
recordAndTupleSyntax: recordAndTupleSyntax = "hash",
recordAndTupleSyntax,
} = opts;
return {
presets: [
[
presetStage2,
{ loose, useBuiltIns, decoratorsLegacy, decoratorsBeforeExport },
{
loose,
useBuiltIns,
decoratorsLegacy,
decoratorsBeforeExport,
recordAndTupleSyntax,
},
],
],
plugins: [
babelPlugins.syntaxDecimal,
[babelPlugins.syntaxRecordAndTuple, { syntaxType: recordAndTupleSyntax }],
babelPlugins.syntaxModuleBlocks,
babelPlugins.proposalExportDefaultFrom,
[
babelPlugins.proposalPipelineOperator,

View File

@ -7,19 +7,20 @@ export default (_: any, opts: any = {}) => {
useBuiltIns = false,
decoratorsLegacy = false,
decoratorsBeforeExport,
recordAndTupleSyntax = "hash",
} = opts;
return {
presets: [[presetStage3, { loose, useBuiltIns }]],
plugins: [
babelPlugins.proposalClassStaticBlock,
[
babelPlugins.proposalDecorators,
{ legacy: decoratorsLegacy, decoratorsBeforeExport },
],
babelPlugins.proposalFunctionSent,
babelPlugins.proposalPrivatePropertyInObject,
babelPlugins.proposalThrowExpressions,
[babelPlugins.syntaxRecordAndTuple, { syntaxType: recordAndTupleSyntax }],
babelPlugins.syntaxModuleBlocks,
],
};
};

View File

@ -1,15 +1,14 @@
import * as babelPlugins from "./generated/plugins";
export default (_: any, opts: any) => {
let loose = false;
export default (_: any, { loose = false } = {}) => {
const plugins = [
babelPlugins.syntaxImportAssertions,
babelPlugins.proposalClassStaticBlock,
];
if (opts !== undefined) {
if (opts.loose !== undefined) loose = opts.loose;
}
return {
plugins: [
babelPlugins.syntaxImportAssertions,
if (!process.env.BABEL_8_BREAKING) {
// These are Stage 4
plugins.push(
babelPlugins.syntaxImportMeta,
babelPlugins.syntaxTopLevelAwait,
babelPlugins.proposalExportNamespaceFrom,
@ -20,6 +19,9 @@ export default (_: any, opts: any) => {
babelPlugins.proposalJsonStrings,
babelPlugins.proposalNumericSeparator,
[babelPlugins.proposalPrivateMethods, { loose }],
],
};
babelPlugins.proposalPrivatePropertyInObject,
);
}
return { plugins };
};