Archive syntax plugins enabled by default (#10820)

* Remove syntax plugins enabled by default

Moved to babel-archive: babel/babel-archive@8f23ddce03

- `@babel/plugin-syntax-async-generators`
- `@babel/plugin-syntax-bigint`
- `@babel/plugin-syntax-dynamic-import`
- `@babel/plugin-syntax-json-strings`
- `@babel/plugin-syntax-nullish-coalescing-operator`
- `@babel/plugin-syntax-object-rest-spread`
- `@babel/plugin-syntax-optional-catch-binding`
- `@babel/plugin-syntax-optional-chaining`

* Fix build script

* Fix jest config

* Remove archived plugins from tests
This commit is contained in:
Nicolò Ribaudo 2020-01-13 00:31:48 +01:00 committed by GitHub
parent c7f7f9b8b5
commit a677d59a63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
51 changed files with 48 additions and 507 deletions

View File

@ -1,3 +1,19 @@
// These packages undet the @babel namespace aren't in this monorepo.
const externalBabelPackages = [
"plugin-syntax-async-generators",
"plugin-syntax-bigint",
"plugin-syntax-dynamic-import",
"plugin-syntax-json-strings",
"plugin-syntax-nullish-coalescing-operator",
"plugin-syntax-object-rest-spread",
"plugin-syntax-optional-catch-binding",
"plugin-syntax-optional-chaining",
];
// prettier-ignore
const monorepoPackagePattern =
`^@babel/(?!eslint-)(?!${externalBabelPackages.join("|")})([a-zA-Z0-9_-]+)$`;
module.exports = { module.exports = {
collectCoverageFrom: [ collectCoverageFrom: [
"packages/*/src/**/*.mjs", "packages/*/src/**/*.mjs",
@ -46,7 +62,7 @@ module.exports = {
"<rootDir>/build/", "<rootDir>/build/",
], ],
moduleNameMapper: { moduleNameMapper: {
"^@babel/(?!eslint-)([a-zA-Z0-9_-]+)$": "<rootDir>/packages/babel-$1/", [monorepoPackagePattern]: "<rootDir>/packages/babel-$1/",
"^@babel/eslint-([a-zA-Z0-9_-]+)$": "<rootDir>/eslint/babel-eslint-$1/", "^@babel/eslint-([a-zA-Z0-9_-]+)$": "<rootDir>/eslint/babel-eslint-$1/",
}, },
}; };

View File

@ -2,7 +2,6 @@
"plugins": [ "plugins": [
["proposal-decorators", { "decoratorsBeforeExport": false }], ["proposal-decorators", { "decoratorsBeforeExport": false }],
"proposal-class-properties", "proposal-class-properties",
"syntax-async-generators",
["external-helpers", { "helperVersion": "7.1.5" }] ["external-helpers", { "helperVersion": "7.1.5" }]
] ]
} }

View File

@ -7,7 +7,6 @@
{ {
"helperVersion": "7.1.5" "helperVersion": "7.1.5"
} }
], ]
"syntax-async-generators"
] ]
} }

View File

@ -1,6 +1,5 @@
{ {
"plugins": [ "plugins": [
"syntax-dynamic-import",
"transform-modules-amd", "transform-modules-amd",
"external-helpers" "external-helpers"
] ]

View File

@ -1,6 +1,5 @@
{ {
"plugins": [ "plugins": [
"syntax-dynamic-import",
"transform-modules-commonjs", "transform-modules-commonjs",
"external-helpers" "external-helpers"
] ]

View File

@ -1,7 +1,6 @@
{ {
"validateLogs": true, "validateLogs": true,
"plugins": [ "plugins": [
"syntax-dynamic-import",
"transform-modules-systemjs", "transform-modules-systemjs",
"external-helpers" "external-helpers"
] ]

View File

@ -1,6 +1,5 @@
{ {
"plugins": [ "plugins": [
"proposal-logical-assignment-operators", "proposal-logical-assignment-operators"
"syntax-nullish-coalescing-operator"
] ]
} }

View File

@ -1,6 +1,5 @@
{ {
"plugins": [ "plugins": [
"syntax-async-generators",
"proposal-object-rest-spread", "proposal-object-rest-spread",
["external-helpers", { "helperVersion": "7.1.5" }] ["external-helpers", { "helperVersion": "7.1.5" }]
] ]

View File

@ -1,3 +0,0 @@
src
test
*.log

View File

@ -1,19 +0,0 @@
# @babel/plugin-syntax-async-generators
> Allow parsing of async generator functions
See our website [@babel/plugin-syntax-async-generators](https://babeljs.io/docs/en/next/babel-plugin-syntax-async-generators.html) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/plugin-syntax-async-generators
```
or using yarn:
```sh
yarn add @babel/plugin-syntax-async-generators --dev
```

View File

@ -1,24 +0,0 @@
{
"name": "@babel/plugin-syntax-async-generators",
"version": "7.8.0",
"description": "Allow parsing of async generator functions",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-syntax-async-generators",
"license": "MIT",
"type": "commonjs",
"publishConfig": {
"access": "public"
},
"main": "lib/index.js",
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "^7.8.0"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
},
"devDependencies": {
"@babel/core": "^7.8.0"
}
}

View File

@ -1,13 +0,0 @@
import { declare } from "@babel/helper-plugin-utils";
export default declare(api => {
api.assertVersion(7);
return {
name: "syntax-async-generators",
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("asyncGenerators");
},
};
});

View File

@ -1,3 +0,0 @@
node_modules
*.log
src

View File

@ -1,19 +0,0 @@
# @babel/plugin-syntax-bigint
> Allow parsing of BigInt literals
See our website [@babel/plugin-syntax-bigint](https://babeljs.io/docs/en/next/babel-plugin-syntax-bigint.html) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/plugin-syntax-bigint
```
or using yarn:
```sh
yarn add @babel/plugin-syntax-bigint --dev
```

View File

@ -1,24 +0,0 @@
{
"name": "@babel/plugin-syntax-bigint",
"version": "7.8.0",
"description": "Allow parsing of BigInt literals",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-syntax-bigint",
"license": "MIT",
"type": "commonjs",
"publishConfig": {
"access": "public"
},
"main": "lib/index.js",
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "^7.8.0"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
},
"devDependencies": {
"@babel/core": "^7.8.0"
}
}

View File

@ -1,13 +0,0 @@
import { declare } from "@babel/helper-plugin-utils";
export default declare(api => {
api.assertVersion(7);
return {
name: "syntax-bigint",
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("bigInt");
},
};
});

View File

@ -1,3 +0,0 @@
src
test
*.log

View File

@ -1,19 +0,0 @@
# @babel/plugin-syntax-dynamic-import
> Allow parsing of import()
See our website [@babel/plugin-syntax-dynamic-import](https://babeljs.io/docs/en/next/babel-plugin-syntax-dynamic-import.html) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/plugin-syntax-dynamic-import
```
or using yarn:
```sh
yarn add @babel/plugin-syntax-dynamic-import --dev
```

View File

@ -1,24 +0,0 @@
{
"name": "@babel/plugin-syntax-dynamic-import",
"version": "7.8.0",
"description": "Allow parsing of import()",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-syntax-dynamic-import",
"license": "MIT",
"type": "commonjs",
"publishConfig": {
"access": "public"
},
"main": "lib/index.js",
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "^7.8.0"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
},
"devDependencies": {
"@babel/core": "^7.8.0"
}
}

View File

@ -1,13 +0,0 @@
import { declare } from "@babel/helper-plugin-utils";
export default declare(api => {
api.assertVersion(7);
return {
name: "syntax-dynamic-import",
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("dynamicImport");
},
};
});

View File

@ -1,3 +0,0 @@
src
test
*.log

View File

@ -1,19 +0,0 @@
# @babel/plugin-syntax-json-strings
> Allow parsing of the U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR in JS strings
See our website [@babel/plugin-syntax-json-strings](https://babeljs.io/docs/en/next/babel-plugin-syntax-json-strings.html) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/plugin-syntax-json-strings
```
or using yarn:
```sh
yarn add @babel/plugin-syntax-json-strings --dev
```

View File

@ -1,24 +0,0 @@
{
"name": "@babel/plugin-syntax-json-strings",
"version": "7.8.0",
"description": "Allow parsing of the U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR in JS strings",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-syntax-json-strings",
"license": "MIT",
"type": "commonjs",
"publishConfig": {
"access": "public"
},
"main": "lib/index.js",
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "^7.8.0"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
},
"devDependencies": {
"@babel/core": "^7.8.0"
}
}

View File

@ -1,13 +0,0 @@
import { declare } from "@babel/helper-plugin-utils";
export default declare(api => {
api.assertVersion(7);
return {
name: "syntax-json-strings",
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("jsonStrings");
},
};
});

View File

@ -1,3 +0,0 @@
src
test
*.log

View File

@ -1,19 +0,0 @@
# @babel/plugin-syntax-nullish-coalescing-operator
> Allow parsing of the nullish-coalescing operator
See our website [@babel/plugin-syntax-nullish-coalescing-operator](https://babeljs.io/docs/en/next/babel-plugin-syntax-nullish-coalescing-operator.html) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/plugin-syntax-nullish-coalescing-operator
```
or using yarn:
```sh
yarn add @babel/plugin-syntax-nullish-coalescing-operator --dev
```

View File

@ -1,24 +0,0 @@
{
"name": "@babel/plugin-syntax-nullish-coalescing-operator",
"version": "7.8.0",
"description": "Allow parsing of the nullish-coalescing operator",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-syntax-nullish-coalescing-operator",
"license": "MIT",
"type": "commonjs",
"publishConfig": {
"access": "public"
},
"main": "lib/index.js",
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "^7.8.0"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
},
"devDependencies": {
"@babel/core": "^7.8.0"
}
}

View File

@ -1,13 +0,0 @@
import { declare } from "@babel/helper-plugin-utils";
export default declare(api => {
api.assertVersion(7);
return {
name: "syntax-nullish-coalescing-operator",
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("nullishCoalescingOperator");
},
};
});

View File

@ -1,3 +0,0 @@
src
test
*.log

View File

@ -1,19 +0,0 @@
# @babel/plugin-syntax-object-rest-spread
> Allow parsing of object rest/spread
See our website [@babel/plugin-syntax-object-rest-spread](https://babeljs.io/docs/en/next/babel-plugin-syntax-object-rest-spread.html) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/plugin-syntax-object-rest-spread
```
or using yarn:
```sh
yarn add @babel/plugin-syntax-object-rest-spread --dev
```

View File

@ -1,24 +0,0 @@
{
"name": "@babel/plugin-syntax-object-rest-spread",
"version": "7.8.0",
"description": "Allow parsing of object rest/spread",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-syntax-object-rest-spread",
"license": "MIT",
"type": "commonjs",
"publishConfig": {
"access": "public"
},
"main": "lib/index.js",
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "^7.8.0"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
},
"devDependencies": {
"@babel/core": "^7.8.0"
}
}

View File

@ -1,13 +0,0 @@
import { declare } from "@babel/helper-plugin-utils";
export default declare(api => {
api.assertVersion(7);
return {
name: "syntax-object-rest-spread",
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("objectRestSpread");
},
};
});

View File

@ -1,3 +0,0 @@
src
test
*.log

View File

@ -1,19 +0,0 @@
# @babel/plugin-syntax-optional-catch-binding
> Allow parsing of optional catch bindings
See our website [@babel/plugin-syntax-optional-catch-binding](https://babeljs.io/docs/en/next/babel-plugin-syntax-optional-catch-binding.html) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/plugin-syntax-optional-catch-binding
```
or using yarn:
```sh
yarn add @babel/plugin-syntax-optional-catch-binding --dev
```

View File

@ -1,24 +0,0 @@
{
"name": "@babel/plugin-syntax-optional-catch-binding",
"version": "7.8.0",
"description": "Allow parsing of optional catch bindings",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-syntax-optional-catch-binding",
"license": "MIT",
"type": "commonjs",
"publishConfig": {
"access": "public"
},
"main": "lib/index.js",
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "^7.8.0"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
},
"devDependencies": {
"@babel/core": "^7.8.0"
}
}

View File

@ -1,13 +0,0 @@
import { declare } from "@babel/helper-plugin-utils";
export default declare(api => {
api.assertVersion(7);
return {
name: "syntax-optional-catch-binding",
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("optionalCatchBinding");
},
};
});

View File

@ -1,3 +0,0 @@
src
test
*.log

View File

@ -1,19 +0,0 @@
# @babel/plugin-syntax-optional-chaining
> Allow parsing of optional properties
See our website [@babel/plugin-syntax-optional-chaining](https://babeljs.io/docs/en/next/babel-plugin-syntax-optional-chaining.html) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/plugin-syntax-optional-chaining
```
or using yarn:
```sh
yarn add @babel/plugin-syntax-optional-chaining --dev
```

View File

@ -1,24 +0,0 @@
{
"name": "@babel/plugin-syntax-optional-chaining",
"version": "7.8.0",
"description": "Allow parsing of optional properties",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-syntax-optional-chaining",
"license": "MIT",
"type": "commonjs",
"publishConfig": {
"access": "public"
},
"main": "lib/index.js",
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "^7.8.0"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
},
"devDependencies": {
"@babel/core": "^7.8.0"
}
}

View File

@ -1,13 +0,0 @@
import { declare } from "@babel/helper-plugin-utils";
export default declare(api => {
api.assertVersion(7);
return {
name: "syntax-optional-chaining",
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("optionalChaining");
},
};
});

View File

@ -1,7 +1,6 @@
{ {
"plugins": [ "plugins": [
"syntax-jsx", "syntax-jsx",
"syntax-optional-chaining",
"transform-flow-strip-types" "transform-flow-strip-types"
] ]
} }

View File

@ -1,8 +1,6 @@
{ {
"plugins": [ "plugins": [
"external-helpers", "external-helpers",
"syntax-object-rest-spread",
"syntax-optional-chaining",
[ [
"transform-modules-commonjs", "transform-modules-commonjs",
{ "strict": true, "mjsStrictNamespace": false } { "strict": true, "mjsStrictNamespace": false }

View File

@ -1,7 +1,6 @@
{ {
"plugins": [ "plugins": [
"external-helpers", "external-helpers",
"syntax-dynamic-import",
"syntax-import-meta", "syntax-import-meta",
"transform-modules-systemjs" "transform-modules-systemjs"
] ]

View File

@ -1,7 +1,6 @@
{ {
"plugins": [ "plugins": [
"external-helpers", "external-helpers",
"transform-modules-systemjs", "transform-modules-systemjs"
"syntax-object-rest-spread"
] ]
} }

View File

@ -3,7 +3,6 @@
"transform-destructuring", "transform-destructuring",
"transform-parameters", "transform-parameters",
"transform-spread", "transform-spread",
"syntax-object-rest-spread",
"transform-react-constant-elements", "transform-react-constant-elements",
"syntax-jsx", "syntax-jsx",
"external-helpers" "external-helpers"

View File

@ -3,7 +3,6 @@
"transform-destructuring", "transform-destructuring",
"transform-parameters", "transform-parameters",
"transform-spread", "transform-spread",
"syntax-object-rest-spread",
"transform-react-constant-elements", "transform-react-constant-elements",
"syntax-jsx", "syntax-jsx",
"external-helpers" "external-helpers"

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,4 @@
{ {
"plugins": ["syntax-dynamic-import"],
"presets": [ "presets": [
[ [
"../../../../lib", "../../../../lib",

View File

@ -1,5 +1,4 @@
{ {
"plugins": ["syntax-dynamic-import"],
"presets": [ "presets": [
[ [
"../../../../lib", "../../../../lib",

File diff suppressed because one or more lines are too long

View File

@ -48,26 +48,37 @@ module.exports = function() {
} }
const matches = importee.match(/^@babel\/([^/]+)$/); const matches = importee.match(/^@babel\/([^/]+)$/);
if (matches) { if (!matches) return null;
const packageFolderName = `babel-${matches[1]}`;
// resolve babel package names to their src index file // resolve babel package names to their src index file
const packageFolder = path.join(dirname, "packages", packageFolderName); const packageFolder = path.join(
const packageJson = require(path.join(packageFolder, "package.json")); dirname,
"packages",
`babel-${matches[1]}`
);
const filename = let packageJsonSource;
typeof packageJson["browser"] === "string" try {
? packageJson["browser"] packageJsonSource = fs.readFileSync(
: packageJson["main"]; path.join(packageFolder, "package.json")
return path.join(
packageFolder,
// replace lib with src in the pkg.json entry
filename.replace(/^(\.\/)?lib\//, "src/")
); );
} catch (e) {
// Some Babel packahes aren't in this repository, but in
return null;
} }
return null; const packageJson = JSON.parse(packageJsonSource);
const filename =
typeof packageJson["browser"] === "string"
? packageJson["browser"]
: packageJson["main"];
return path.join(
packageFolder,
// replace lib with src in the pkg.json entry
filename.replace(/^(\.\/)?lib\//, "src/")
);
}, },
}; };
}; };