Allow plugins to assert that a specific babel version has loaded the plugin. (#7450)

This commit is contained in:
Logan Smyth 2018-03-04 14:36:54 -08:00 committed by GitHub
parent 7f8f4e86dc
commit a4795408b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
201 changed files with 875 additions and 212 deletions

View File

@ -41,6 +41,7 @@
"lodash": "^4.2.0",
"micromatch": "^2.3.11",
"resolve": "^1.3.2",
"semver": "^5.4.1",
"source-map": "^0.5.0"
},
"devDependencies": {

View File

@ -1,4 +1,7 @@
// @flow
import semver from "semver";
import { version as coreVersion } from "../../";
import type { CacheConfigurator, SimpleCacheConfigurator } from "../caching";
type EnvFunction = {
@ -9,9 +12,11 @@ type EnvFunction = {
};
export type PluginAPI = {
version: string,
cache: SimpleCacheConfigurator,
env: EnvFunction,
async: () => boolean,
assertVersion: typeof assertVersion,
};
export default function makeAPI(
@ -32,9 +37,55 @@ export default function makeAPI(
});
return {
version: coreVersion,
cache: cache.simple(),
// Expose ".env()" so people can easily get the same env that we expose using the "env" key.
env,
async: () => false,
assertVersion,
};
}
function assertVersion(range: string | number): void {
if (typeof range === "number") {
if (!Number.isInteger(range)) {
throw new Error("Expected string or integer value.");
}
range = `^${range}.0.0-0`;
}
if (typeof range !== "string") {
throw new Error("Expected string or integer value.");
}
if (semver.satisfies(coreVersion, range)) return;
const limit = Error.stackTraceLimit;
if (typeof limit === "number" && limit < 25) {
// Bump up the limit if needed so that users are more likely
// to be able to see what is calling Babel.
Error.stackTraceLimit = 25;
}
const err = new Error(
`Requires Babel "${range}", but was loaded with "${coreVersion}". ` +
`If you are sure you have a compatible version of @babel/core, ` +
`it is likely that something in your build process is loading the ` +
`wrong version. Inspect the stack trace of this error to look for ` +
`the first entry that doesn't mention "@babel/core" or "babel-core" ` +
`to see what is calling Babel.`,
);
if (typeof limit === "number") {
Error.stackTraceLimit = limit;
}
throw Object.assign(
err,
({
code: "BABEL_VERSION_UNSUPPORTED",
version: coreVersion,
range,
}: any),
);
}

View File

@ -0,0 +1,10 @@
{
"name": "@babel/helper-plugin-utils",
"version": "7.0.0-beta.40",
"description": "General utilities for plugins to use",
"author": "Logan Smyth <loganfsmyth@gmail.com>",
"homepage": "https://babeljs.io/",
"license": "MIT",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-plugin-utils",
"main": "lib/index.js"
}

View File

@ -0,0 +1,41 @@
# @babel/helper-plugin-utils
The intention of this module is to provide a place for us to expose a
standardized API layer over top of what Babel's core API provides on its own.
This is not aiming to implement APIs that are missing on a given Babel version,
but it is means to provide clear error messages if a plugin is run on a version
of Babel that doesn't have the APIs that the plugin is trying to use.
Every one of Babel's core plugins and presets will use this module, and ideally
because of that its size should be kept to a miminum because this may or may
not be deduplicated when installed.
## Usage
```js
import { declare } from "@babel/helper-plugin-utils";
export default declare((api, options, dirname) => {
return {};
});
```
## What this does
Currently, this plugin provides a few services to ensure that plugins function
well-enough to throw useful errors.
### `options` is always passed
Babel 6 does not pass a second parameter. This frequently means that plugins
written for Babel 7 that use `options` will attempt to destructure options
out of an `undefined` value. By supplying the default, we avoid that risk.
### `api.assertVersion` always exists
Babel 6 and early betas of Babel 7 do not have `assertVersion`, so this
wrapper ensures that it exists and throws a useful error message when not
supplied by Babel itself.

View File

@ -0,0 +1,65 @@
export function declare(builder) {
return (api, options, dirname) => {
if (!api.assertVersion) {
// Inject a custom version of 'assertVersion' for Babel 6 and early
// versions of Babel 7's beta that didn't have it.
api = Object.assign({}, api, {
assertVersion(range) {
throwVersionError(range, api.version);
},
});
}
return builder(api, options || {}, dirname);
};
}
function throwVersionError(range, version) {
if (typeof range === "number") {
if (!Number.isInteger(range)) {
throw new Error("Expected string or integer value.");
}
range = `^${range}.0.0-0`;
}
if (typeof range !== "string") {
throw new Error("Expected string or integer value.");
}
const limit = Error.stackTraceLimit;
if (typeof limit === "number" && limit < 25) {
// Bump up the limit if needed so that users are more likely
// to be able to see what is calling Babel.
Error.stackTraceLimit = 25;
}
let err;
if (version.slice(0, 2) === "7.") {
err = new Error(
`Requires Babel "^7.0.0-beta.41", but was loaded with "${version}". ` +
`You'll need to update your @babel/core version.`,
);
} else {
err = new Error(
`Requires Babel "${range}", but was loaded with "${version}". ` +
`If you are sure you have a compatible version of @babel/core, ` +
`it is likely that something in your build process is loading the ` +
`wrong version. Inspect the stack trace of this error to look for ` +
`the first entry that doesn't mention "@babel/core" or "babel-core" ` +
`to see what is calling Babel.`,
);
}
if (typeof limit === "number") {
Error.stackTraceLimit = limit;
}
throw Object.assign(
err,
({
code: "BABEL_VERSION_UNSUPPORTED",
version,
range,
}: any),
);
}

View File

@ -8,6 +8,9 @@
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.40"
},

View File

@ -1,9 +1,12 @@
import { declare } from "@babel/helper-plugin-utils";
import { types as t } from "@babel/core";
export default function() {
export default declare(api => {
api.assertVersion(7);
return {
pre(file) {
file.set("helpersNamespace", t.identifier("babelHelpers"));
},
};
}
});

View File

@ -9,6 +9,7 @@
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40",
"@babel/helper-remap-async-to-generator": "7.0.0-beta.40",
"@babel/plugin-syntax-async-generators": "7.0.0-beta.40"
},

View File

@ -1,8 +1,11 @@
import { declare } from "@babel/helper-plugin-utils";
import remapAsyncToGenerator from "@babel/helper-remap-async-to-generator";
import syntaxAsyncGenerators from "@babel/plugin-syntax-async-generators";
import { types as t } from "@babel/core";
export default function() {
export default declare(api => {
api.assertVersion(7);
const yieldStarVisitor = {
Function(path) {
path.skip();
@ -33,4 +36,4 @@ export default function() {
},
},
};
}
});

View File

@ -9,6 +9,7 @@
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40",
"@babel/helper-function-name": "7.0.0-beta.40",
"@babel/plugin-syntax-class-properties": "7.0.0-beta.40"
},

View File

@ -1,8 +1,11 @@
import { declare } from "@babel/helper-plugin-utils";
import nameFunction from "@babel/helper-function-name";
import syntaxClassProperties from "@babel/plugin-syntax-class-properties";
import { template, types as t } from "@babel/core";
export default function(api, options) {
export default declare((api, options) => {
api.assertVersion(7);
const { loose } = options;
const findBareSupers = {
@ -247,4 +250,4 @@ export default function(api, options) {
},
},
};
}
});

View File

@ -12,6 +12,7 @@
"decorators"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40",
"@babel/plugin-syntax-decorators": "7.0.0-beta.40"
},
"peerDependencies": {

View File

@ -1,5 +1,6 @@
// Fork of https://github.com/loganfsmyth/babel-plugin-proposal-decorators-legacy
import { declare } from "@babel/helper-plugin-utils";
import syntaxDecorators from "@babel/plugin-syntax-decorators";
import { template, types as t } from "@babel/core";
@ -26,7 +27,9 @@ const buildGetObjectInitializer = template(`
})
`);
export default function() {
export default declare(api => {
api.assertVersion(7);
const WARNING_CALLS = new WeakSet();
/**
@ -276,4 +279,4 @@ export default function() {
},
},
};
}
});

View File

@ -9,6 +9,7 @@
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40",
"@babel/plugin-syntax-do-expressions": "7.0.0-beta.40"
},
"peerDependencies": {

View File

@ -1,6 +1,9 @@
import { declare } from "@babel/helper-plugin-utils";
import syntaxDoExpressions from "@babel/plugin-syntax-do-expressions";
export default function() {
export default declare(api => {
api.assertVersion(7);
return {
inherits: syntaxDoExpressions,
@ -17,4 +20,4 @@ export default function() {
},
},
};
}
});

View File

@ -9,6 +9,7 @@
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40",
"@babel/plugin-syntax-export-default-from": "7.0.0-beta.40"
},
"peerDependencies": {

View File

@ -1,7 +1,10 @@
import { declare } from "@babel/helper-plugin-utils";
import syntaxExportDefaultFrom from "@babel/plugin-syntax-export-default-from";
import { types as t } from "@babel/core";
export default function() {
export default declare(api => {
api.assertVersion(7);
return {
inherits: syntaxExportDefaultFrom,
@ -33,4 +36,4 @@ export default function() {
},
},
};
}
});

View File

@ -9,6 +9,7 @@
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40",
"@babel/plugin-syntax-export-namespace-from": "7.0.0-beta.40"
},
"peerDependencies": {

View File

@ -1,7 +1,10 @@
import { declare } from "@babel/helper-plugin-utils";
import syntaxExportNamespaceFrom from "@babel/plugin-syntax-export-namespace-from";
import { types as t } from "@babel/core";
export default function() {
export default declare(api => {
api.assertVersion(7);
return {
inherits: syntaxExportNamespaceFrom,
@ -43,4 +46,4 @@ export default function() {
},
},
};
}
});

View File

@ -9,6 +9,7 @@
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40",
"@babel/plugin-syntax-function-bind": "7.0.0-beta.40"
},
"peerDependencies": {

View File

@ -1,7 +1,10 @@
import { declare } from "@babel/helper-plugin-utils";
import syntaxFunctionBind from "@babel/plugin-syntax-function-bind";
import { types as t } from "@babel/core";
export default function() {
export default declare(api => {
api.assertVersion(7);
function getTempId(scope) {
let id = scope.path.getData("functionBind");
if (id) return id;
@ -60,4 +63,4 @@ export default function() {
},
},
};
}
});

View File

@ -9,6 +9,7 @@
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40",
"@babel/helper-wrap-function": "7.0.0-beta.40",
"@babel/plugin-syntax-function-sent": "7.0.0-beta.40"
},

View File

@ -1,8 +1,11 @@
import { declare } from "@babel/helper-plugin-utils";
import syntaxFunctionSent from "@babel/plugin-syntax-function-sent";
import wrapFunction from "@babel/helper-wrap-function";
import { types as t } from "@babel/core";
export default function() {
export default declare(api => {
api.assertVersion(7);
const isFunctionSent = node =>
t.isIdentifier(node.meta, { name: "function" }) &&
t.isIdentifier(node.property, { name: "sent" });
@ -57,4 +60,4 @@ export default function() {
},
},
};
}
});

View File

@ -9,6 +9,7 @@
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40",
"@babel/plugin-syntax-logical-assignment-operators": "7.0.0-beta.40"
},
"peerDependencies": {

View File

@ -1,7 +1,10 @@
import { declare } from "@babel/helper-plugin-utils";
import syntaxLogicalAssignmentOperators from "@babel/plugin-syntax-logical-assignment-operators";
import { types as t } from "@babel/core";
export default function() {
export default declare(api => {
api.assertVersion(7);
return {
inherits: syntaxLogicalAssignmentOperators,
@ -39,4 +42,4 @@ export default function() {
},
},
};
}
});

View File

@ -9,6 +9,7 @@
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40",
"@babel/plugin-syntax-nullish-coalescing-operator": "7.0.0-beta.40"
},
"peerDependencies": {

View File

@ -1,7 +1,10 @@
import { declare } from "@babel/helper-plugin-utils";
import syntaxNullishCoalescingOperator from "@babel/plugin-syntax-nullish-coalescing-operator";
import { types as t } from "@babel/core";
export default function(api, { loose = false }) {
export default declare((api, { loose = false }) => {
api.assertVersion(7);
return {
inherits: syntaxNullishCoalescingOperator,
@ -43,4 +46,4 @@ export default function(api, { loose = false }) {
},
},
};
}
});

View File

@ -9,6 +9,7 @@
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40",
"@babel/plugin-syntax-numeric-separator": "7.0.0-beta.40"
},
"peerDependencies": {

View File

@ -1,7 +1,10 @@
import { declare } from "@babel/helper-plugin-utils";
import syntaxNumericSeparator from "@babel/plugin-syntax-numeric-separator";
import { types as t } from "@babel/core";
export default function() {
export default declare(api => {
api.assertVersion(7);
function replaceNumberArg({ node }) {
if (node.callee.name !== "Number") {
return;
@ -29,4 +32,4 @@ export default function() {
},
},
};
}
});

View File

@ -9,6 +9,7 @@
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40",
"@babel/plugin-syntax-object-rest-spread": "7.0.0-beta.40"
},
"peerDependencies": {

View File

@ -1,7 +1,10 @@
import { declare } from "@babel/helper-plugin-utils";
import syntaxObjectRestSpread from "@babel/plugin-syntax-object-rest-spread";
import { types as t } from "@babel/core";
export default function(api, opts) {
export default declare((api, opts) => {
api.assertVersion(7);
const { useBuiltIns = false, loose = false } = opts;
if (typeof loose !== "boolean") {
@ -404,4 +407,4 @@ export default function(api, opts) {
},
},
};
}
});

View File

@ -9,6 +9,7 @@
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40",
"@babel/plugin-syntax-optional-catch-binding": "7.0.0-beta.40"
},
"peerDependencies": {

View File

@ -1,6 +1,9 @@
import { declare } from "@babel/helper-plugin-utils";
import syntaxOptionalCatchBinding from "@babel/plugin-syntax-optional-catch-binding";
export default function() {
export default declare(api => {
api.assertVersion(7);
return {
inherits: syntaxOptionalCatchBinding,
@ -14,4 +17,4 @@ export default function() {
},
},
};
}
});

View File

@ -9,6 +9,7 @@
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40",
"@babel/plugin-syntax-optional-chaining": "7.0.0-beta.40"
},
"peerDependencies": {

View File

@ -1,7 +1,10 @@
import { declare } from "@babel/helper-plugin-utils";
import syntaxOptionalChaining from "@babel/plugin-syntax-optional-chaining";
import { types as t } from "@babel/core";
export default function(api, options) {
export default declare((api, options) => {
api.assertVersion(7);
const { loose = false } = options;
function optional(path, replacementPath) {
@ -136,4 +139,4 @@ export default function(api, options) {
},
},
};
}
});

View File

@ -9,6 +9,7 @@
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40",
"@babel/plugin-syntax-pipeline-operator": "7.0.0-beta.40"
},
"peerDependencies": {

View File

@ -1,7 +1,10 @@
import { declare } from "@babel/helper-plugin-utils";
import syntaxPipelineOperator from "@babel/plugin-syntax-pipeline-operator";
import { types as t } from "@babel/core";
export default function() {
export default declare(api => {
api.assertVersion(7);
return {
inherits: syntaxPipelineOperator,
@ -57,4 +60,4 @@ export default function() {
},
},
};
}
});

View File

@ -9,6 +9,7 @@
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40",
"@babel/plugin-syntax-throw-expressions": "7.0.0-beta.40"
},
"peerDependencies": {

View File

@ -1,7 +1,10 @@
import { declare } from "@babel/helper-plugin-utils";
import syntaxThrowExpressions from "@babel/plugin-syntax-throw-expressions";
import { types as t } from "@babel/core";
export default function() {
export default declare(api => {
api.assertVersion(7);
return {
inherits: syntaxThrowExpressions,
@ -20,4 +23,4 @@ export default function() {
},
},
};
}
});

View File

@ -19,6 +19,7 @@
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-proposal-unicode-property-regex",
"bugs": "https://github.com/babel/babel/issues",
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40",
"@babel/helper-regex": "7.0.0-beta.40",
"regexpu-core": "^4.1.3"
},

View File

@ -1,7 +1,10 @@
import { declare } from "@babel/helper-plugin-utils";
import rewritePattern from "regexpu-core";
import * as regex from "@babel/helper-regex";
export default function(api, options) {
export default declare((api, options) => {
api.assertVersion(7);
const { useUnicodeFlag = true } = options;
if (typeof useUnicodeFlag !== "boolean") {
throw new Error(".useUnicodeFlag must be a boolean, or undefined");
@ -24,4 +27,4 @@ export default function(api, options) {
},
},
};
}
});

View File

@ -8,6 +8,9 @@
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.40"
},

View File

@ -1,7 +1,11 @@
export default function() {
import { declare } from "@babel/helper-plugin-utils";
export default declare(api => {
api.assertVersion(7);
return {
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("asyncGenerators");
},
};
}
});

View File

@ -8,6 +8,9 @@
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.40"
},

View File

@ -1,7 +1,11 @@
export default function() {
import { declare } from "@babel/helper-plugin-utils";
export default declare(api => {
api.assertVersion(7);
return {
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("classProperties");
},
};
}
});

View File

@ -8,6 +8,9 @@
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.40"
},

View File

@ -1,7 +1,11 @@
export default function() {
import { declare } from "@babel/helper-plugin-utils";
export default declare(api => {
api.assertVersion(7);
return {
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("decorators");
},
};
}
});

View File

@ -8,6 +8,9 @@
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.40"
},

View File

@ -1,7 +1,11 @@
export default function() {
import { declare } from "@babel/helper-plugin-utils";
export default declare(api => {
api.assertVersion(7);
return {
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("doExpressions");
},
};
}
});

View File

@ -8,6 +8,9 @@
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.40"
},

View File

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

View File

@ -8,6 +8,9 @@
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.40"
},

View File

@ -1,7 +1,11 @@
export default function() {
import { declare } from "@babel/helper-plugin-utils";
export default declare(api => {
api.assertVersion(7);
return {
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("exportDefaultFrom");
},
};
}
});

View File

@ -8,6 +8,9 @@
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.40"
},

View File

@ -1,7 +1,11 @@
export default function() {
import { declare } from "@babel/helper-plugin-utils";
export default declare(api => {
api.assertVersion(7);
return {
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("exportNamespaceFrom");
},
};
}
});

View File

@ -8,6 +8,9 @@
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.40"
},

View File

@ -1,7 +1,11 @@
export default function() {
import { declare } from "@babel/helper-plugin-utils";
export default declare(api => {
api.assertVersion(7);
return {
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("flow");
},
};
}
});

View File

@ -8,6 +8,9 @@
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.40"
},

View File

@ -1,7 +1,11 @@
export default function() {
import { declare } from "@babel/helper-plugin-utils";
export default declare(api => {
api.assertVersion(7);
return {
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("functionBind");
},
};
}
});

View File

@ -8,6 +8,9 @@
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.40"
},

View File

@ -1,7 +1,11 @@
export default function() {
import { declare } from "@babel/helper-plugin-utils";
export default declare(api => {
api.assertVersion(7);
return {
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("functionSent");
},
};
}
});

View File

@ -8,6 +8,9 @@
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.40"
},

View File

@ -1,7 +1,11 @@
export default function() {
import { declare } from "@babel/helper-plugin-utils";
export default declare(api => {
api.assertVersion(7);
return {
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("importMeta");
},
};
}
});

View File

@ -8,6 +8,9 @@
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.40"
},

View File

@ -1,7 +1,11 @@
export default function() {
import { declare } from "@babel/helper-plugin-utils";
export default declare(api => {
api.assertVersion(7);
return {
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("jsx");
},
};
}
});

View File

@ -8,6 +8,9 @@
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.40"
},

View File

@ -1,7 +1,11 @@
export default function() {
import { declare } from "@babel/helper-plugin-utils";
export default declare(api => {
api.assertVersion(7);
return {
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("logicalAssignment");
},
};
}
});

View File

@ -8,6 +8,9 @@
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.40"
},

View File

@ -1,7 +1,11 @@
export default function() {
import { declare } from "@babel/helper-plugin-utils";
export default declare(api => {
api.assertVersion(7);
return {
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("nullishCoalescingOperator");
},
};
}
});

View File

@ -8,6 +8,9 @@
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.40"
},

View File

@ -1,7 +1,11 @@
export default function() {
import { declare } from "@babel/helper-plugin-utils";
export default declare(api => {
api.assertVersion(7);
return {
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("numericSeparator");
},
};
}
});

View File

@ -8,6 +8,9 @@
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.40"
},

View File

@ -1,7 +1,11 @@
export default function() {
import { declare } from "@babel/helper-plugin-utils";
export default declare(api => {
api.assertVersion(7);
return {
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("objectRestSpread");
},
};
}
});

View File

@ -8,6 +8,9 @@
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.40"
},

View File

@ -1,7 +1,11 @@
export default function() {
import { declare } from "@babel/helper-plugin-utils";
export default declare(api => {
api.assertVersion(7);
return {
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("optionalCatchBinding");
},
};
}
});

View File

@ -8,6 +8,9 @@
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.40"
},

View File

@ -1,7 +1,11 @@
export default function() {
import { declare } from "@babel/helper-plugin-utils";
export default declare(api => {
api.assertVersion(7);
return {
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("optionalChaining");
},
};
}
});

View File

@ -8,6 +8,9 @@
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.40"
},

View File

@ -1,7 +1,11 @@
export default function() {
import { declare } from "@babel/helper-plugin-utils";
export default declare(api => {
api.assertVersion(7);
return {
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("pipelineOperator");
},
};
}
});

View File

@ -8,6 +8,9 @@
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.40"
},

View File

@ -1,7 +1,11 @@
export default function() {
import { declare } from "@babel/helper-plugin-utils";
export default declare(api => {
api.assertVersion(7);
return {
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("throwExpressions");
},
};
}
});

View File

@ -9,6 +9,9 @@
"babel-plugin",
"typescript"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.40"
},

View File

@ -1,4 +1,8 @@
export default function() {
import { declare } from "@babel/helper-plugin-utils";
export default declare(api => {
api.assertVersion(7);
return {
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push(
@ -8,4 +12,4 @@ export default function() {
);
},
};
}
});

View File

@ -8,6 +8,9 @@
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.40"
},

View File

@ -1,6 +1,9 @@
import { declare } from "@babel/helper-plugin-utils";
import type NodePath from "@babel/traverse";
export default function(api, options) {
export default declare((api, options) => {
api.assertVersion(7);
const { spec } = options;
return {
visitor: {
@ -20,4 +23,4 @@ export default function(api, options) {
},
},
};
}
});

View File

@ -9,6 +9,7 @@
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40",
"@babel/helper-module-imports": "7.0.0-beta.40",
"@babel/helper-remap-async-to-generator": "7.0.0-beta.40"
},

View File

@ -1,8 +1,11 @@
import { declare } from "@babel/helper-plugin-utils";
import remapAsyncToGenerator from "@babel/helper-remap-async-to-generator";
import { addNamed } from "@babel/helper-module-imports";
import { types as t } from "@babel/core";
export default function(api, options) {
export default declare((api, options) => {
api.assertVersion(7);
const { method, module } = options;
if (method && module) {
@ -37,4 +40,4 @@ export default function(api, options) {
},
},
};
}
});

View File

@ -8,6 +8,9 @@
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.40"
},

View File

@ -1,6 +1,9 @@
import { declare } from "@babel/helper-plugin-utils";
import { types as t } from "@babel/core";
export default function() {
export default declare(api => {
api.assertVersion(7);
function statementList(key, path) {
const paths: Array = path.get(key);
@ -41,4 +44,4 @@ export default function() {
},
},
};
}
});

View File

@ -6,6 +6,7 @@
"license": "MIT",
"main": "lib/index.js",
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40",
"lodash": "^4.2.0"
},
"keywords": [

View File

@ -1,3 +1,4 @@
import { declare } from "@babel/helper-plugin-utils";
import type NodePath from "@babel/traverse";
import type Scope from "@babel/traverse";
import { visitor as tdzVisitor } from "./tdz";
@ -7,7 +8,9 @@ import { traverse, template, types as t } from "@babel/core";
const DONE = new WeakSet();
export default function(api, opts) {
export default declare((api, opts) => {
api.assertVersion(7);
const { throwIfClosureRequired = false, tdz: tdzEnabled = false } = opts;
if (typeof throwIfClosureRequired !== "boolean") {
throw new Error(`.throwIfClosureRequired must be a boolean, or undefined`);
@ -94,7 +97,7 @@ export default function(api, opts) {
},
},
};
}
});
function ignoreBlock(path) {
return t.isLoop(path.parent) || t.isCatchClause(path.parent);

View File

@ -6,6 +6,7 @@
"license": "MIT",
"main": "lib/index.js",
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40",
"@babel/helper-annotate-as-pure": "7.0.0-beta.40",
"@babel/helper-define-map": "7.0.0-beta.40",
"@babel/helper-function-name": "7.0.0-beta.40",

View File

@ -1,3 +1,4 @@
import { declare } from "@babel/helper-plugin-utils";
import LooseTransformer from "./loose";
import VanillaTransformer from "./vanilla";
import annotateAsPure from "@babel/helper-annotate-as-pure";
@ -14,7 +15,9 @@ const builtinClasses = new Set([
...getBuiltinClasses("browser"),
]);
export default function(api, options) {
export default declare((api, options) => {
api.assertVersion(7);
const { loose } = options;
const Constructor = loose ? LooseTransformer : VanillaTransformer;
@ -65,4 +68,4 @@ export default function(api, options) {
},
},
};
}
});

View File

@ -8,6 +8,9 @@
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.40"
},

View File

@ -1,6 +1,9 @@
import { declare } from "@babel/helper-plugin-utils";
import { template, types as t } from "@babel/core";
export default function(api, options) {
export default declare((api, options) => {
api.assertVersion(7);
const { loose } = options;
const pushComputedProps = loose
? pushComputedPropsLoose
@ -199,4 +202,4 @@ export default function(api, options) {
},
},
};
}
});

View File

@ -8,6 +8,9 @@
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.40"
},

View File

@ -1,6 +1,9 @@
import { declare } from "@babel/helper-plugin-utils";
import { types as t } from "@babel/core";
export default function(api, options) {
export default declare((api, options) => {
api.assertVersion(7);
const { loose = false } = options;
if (typeof loose !== "boolean") {
throw new Error(`.loose must be a boolean or undefined`);
@ -583,4 +586,4 @@ export default function(api, options) {
},
},
};
}
});

View File

@ -21,6 +21,7 @@
},
"bugs": "https://github.com/babel/babel/issues",
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40",
"@babel/helper-regex": "7.0.0-beta.40",
"regexpu-core": "^4.1.3"
},

View File

@ -1,7 +1,10 @@
import { declare } from "@babel/helper-plugin-utils";
import rewritePattern from "regexpu-core";
import * as regex from "@babel/helper-regex";
export default function() {
export default declare(api => {
api.assertVersion(7);
return {
visitor: {
RegExpLiteral(path) {
@ -17,4 +20,4 @@ export default function() {
},
},
};
}
});

View File

@ -8,6 +8,9 @@
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.40"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.40"
},

Some files were not shown because too many files have changed in this diff Show More