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
201 changed files with 875 additions and 212 deletions

View File

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

View File

@@ -12,12 +12,15 @@
* var __jsxFileName = 'this/file.js';
* <sometag __source={{fileName: __jsxFileName, lineNumber: 10}}/>
*/
import { declare } from "@babel/helper-plugin-utils";
import { types as t } from "@babel/core";
const TRACE_ID = "__source";
const FILE_NAME_VAR = "_jsxFileName";
export default function() {
export default declare(api => {
api.assertVersion(7);
function makeTrace(fileNameIdentifier, lineNumber) {
const fileLineLiteral =
lineNumber != null ? t.numericLiteral(lineNumber) : t.nullLiteral();
@@ -71,4 +74,4 @@ export default function() {
return {
visitor,
};
}
});