remove deprecated features
This commit is contained in:
parent
23e0aa8b60
commit
ab78685124
@ -4,16 +4,14 @@ import * as babylon from "babylon";
|
||||
import * as util from "../util";
|
||||
import fs from "fs";
|
||||
|
||||
export { util, babylon as acorn, transform };
|
||||
export { util, transform };
|
||||
export { pipeline, lint } from "../transformation";
|
||||
export { canCompile } from "../util";
|
||||
|
||||
export { default as File } from "../transformation/file";
|
||||
export { default as options } from "../transformation/file/options/config";
|
||||
export { default as Plugin } from "../transformation/plugin";
|
||||
export { default as Transformer } from "../transformation/transformer";
|
||||
export { default as Pipeline } from "../transformation/pipeline";
|
||||
export { default as traverse } from "babel-traverse";
|
||||
export { default as buildExternalHelpers } from "../tools/build-external-helpers";
|
||||
export { version } from "../../package";
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ import isFunction from "lodash/lang/isFunction";
|
||||
import sourceMap from "source-map";
|
||||
import generate from "babel-generator";
|
||||
import codeFrame from "babel-code-frame";
|
||||
import shuffle from "lodash/collection/shuffle";
|
||||
import defaults from "lodash/object/defaults";
|
||||
import includes from "lodash/collection/includes";
|
||||
import traverse from "babel-traverse";
|
||||
@ -19,10 +20,6 @@ import * as util from "../../util";
|
||||
import path from "path";
|
||||
import * as t from "babel-types";
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
|
||||
export default class File {
|
||||
constructor(opts = {}, pipeline) {
|
||||
this.pipeline = pipeline;
|
||||
@ -57,10 +54,6 @@ export default class File {
|
||||
|
||||
hub = new Hub(this);
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
|
||||
static helpers = [
|
||||
"inherits",
|
||||
"defaults",
|
||||
@ -100,17 +93,9 @@ export default class File {
|
||||
"interop-require"
|
||||
];
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
|
||||
static soloHelpers = [];
|
||||
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
|
||||
initOptions(opts) {
|
||||
opts = new OptionManager(this.log, this.pipeline).init(opts);
|
||||
|
||||
@ -154,18 +139,10 @@ export default class File {
|
||||
return opts;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
|
||||
isLoose(key: string) {
|
||||
return includes(this.opts.loose, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
|
||||
buildTransformers() {
|
||||
var file = this;
|
||||
|
||||
@ -220,10 +197,6 @@ export default class File {
|
||||
this.transformerStack = this.collapseStack(stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
|
||||
collapseStack(_stack) {
|
||||
var stack = [];
|
||||
var ignore = [];
|
||||
@ -245,8 +218,12 @@ export default class File {
|
||||
if (pass.plugin.metadata.group === group) {
|
||||
mergeStack.push(pass);
|
||||
ignore.push(pass);
|
||||
} else {
|
||||
//break;
|
||||
}
|
||||
}
|
||||
shuffle;
|
||||
//mergeStack = shuffle(mergeStack);
|
||||
|
||||
var visitors = [];
|
||||
for (let pass of (mergeStack: Array)) {
|
||||
@ -260,26 +237,14 @@ export default class File {
|
||||
return stack;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
|
||||
set(key: string, val): any {
|
||||
return this.data[key] = val;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
|
||||
setDynamic(key: string, fn: Function) {
|
||||
this.dynamicData[key] = fn;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
|
||||
get(key: string): any {
|
||||
var data = this.data[key];
|
||||
if (data) {
|
||||
@ -292,20 +257,12 @@ export default class File {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
|
||||
resolveModuleSource(source: string): string {
|
||||
var resolveModuleSource = this.opts.resolveModuleSource;
|
||||
if (resolveModuleSource) source = resolveModuleSource(source, this.opts.filename);
|
||||
return source;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
|
||||
addImport(source: string, name?: string, type?: string): Object {
|
||||
name = name || source;
|
||||
var id = this.dynamicImportIds[name];
|
||||
@ -315,7 +272,7 @@ export default class File {
|
||||
id = this.dynamicImportIds[name] = this.scope.generateUidIdentifier(name);
|
||||
|
||||
var specifiers = [t.importDefaultSpecifier(id)];
|
||||
var declar = t.importDeclaration(specifiers, t.literal(source));
|
||||
var declar = t.importDeclaration(specifiers, t.stringLiteral(source));
|
||||
declar._blockHoist = 3;
|
||||
|
||||
if (type) {
|
||||
@ -334,10 +291,6 @@ export default class File {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
|
||||
attachAuxiliaryComment(node: Object): Object {
|
||||
var beforeComment = this.opts.auxiliaryCommentBefore;
|
||||
if (beforeComment) {
|
||||
@ -360,10 +313,6 @@ export default class File {
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
|
||||
addHelper(name: string): Object {
|
||||
var isSolo = includes(File.soloHelpers, name);
|
||||
|
||||
@ -434,10 +383,6 @@ export default class File {
|
||||
return uid;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
|
||||
errorWithNode(node, msg, Error = SyntaxError) {
|
||||
var err;
|
||||
var loc = node && (node.loc || node._loc);
|
||||
@ -451,10 +396,6 @@ export default class File {
|
||||
return err;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
|
||||
mergeSourceMap(map: Object) {
|
||||
var opts = this.opts;
|
||||
|
||||
@ -477,10 +418,6 @@ export default class File {
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
|
||||
getModuleFormatter(type: string) {
|
||||
if (isFunction(type) || !moduleFormatters[type]) {
|
||||
this.log.deprecate("Custom module formatters are deprecated and will be removed in the next major. Please use Babel plugins instead.");
|
||||
@ -500,10 +437,6 @@ export default class File {
|
||||
return new ModuleFormatter(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
|
||||
parse(code: string) {
|
||||
var opts = this.opts;
|
||||
|
||||
@ -532,10 +465,6 @@ export default class File {
|
||||
return ast;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
|
||||
_addAst(ast) {
|
||||
this.path = NodePath.get({
|
||||
hub: this.hub,
|
||||
@ -548,10 +477,6 @@ export default class File {
|
||||
this.ast = ast;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
|
||||
addAst(ast) {
|
||||
this.log.debug("Start set AST");
|
||||
this._addAst(ast);
|
||||
@ -565,10 +490,6 @@ export default class File {
|
||||
this.log.debug("End module formatter init");
|
||||
}
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
|
||||
transform() {
|
||||
this.call("pre");
|
||||
for (var pass of (this.transformerStack: Array)) {
|
||||
@ -579,10 +500,6 @@ export default class File {
|
||||
return this.generate();
|
||||
}
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
|
||||
wrap(code, callback) {
|
||||
code = code + "";
|
||||
|
||||
@ -626,39 +543,23 @@ export default class File {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
|
||||
addCode(code: string) {
|
||||
code = (code || "") + "";
|
||||
code = this.parseInputSourceMap(code);
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
|
||||
parseCode() {
|
||||
this.parseShebang();
|
||||
var ast = this.parse(this.code);
|
||||
this.addAst(ast);
|
||||
}
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
|
||||
shouldIgnore() {
|
||||
var opts = this.opts;
|
||||
return util.shouldIgnore(opts.filename, opts.ignore, opts.only);
|
||||
}
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
|
||||
call(key: string) {
|
||||
for (var pass of (this.uncollapsedTransformerStack: Array)) {
|
||||
var fn = pass.plugin[key];
|
||||
@ -666,10 +567,6 @@ export default class File {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
|
||||
parseInputSourceMap(code: string) {
|
||||
var opts = this.opts;
|
||||
|
||||
@ -684,10 +581,6 @@ export default class File {
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
|
||||
parseShebang() {
|
||||
var shebangMatch = shebangRegex.exec(this.code);
|
||||
if (shebangMatch) {
|
||||
@ -696,10 +589,6 @@ export default class File {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
|
||||
makeResult({ code, map = null, ast, ignored }) {
|
||||
var result = {
|
||||
metadata: null,
|
||||
@ -725,10 +614,6 @@ export default class File {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
|
||||
generate() {
|
||||
var opts = this.opts;
|
||||
var ast = this.ast;
|
||||
|
||||
@ -186,12 +186,6 @@
|
||||
"shorthand": "k"
|
||||
},
|
||||
|
||||
"auxiliaryComment": {
|
||||
"deprecated": "renamed to auxiliaryCommentBefore",
|
||||
"shorthand": "a",
|
||||
"alias": "auxiliaryCommentBefore"
|
||||
},
|
||||
|
||||
"auxiliaryCommentBefore": {
|
||||
"type": "string",
|
||||
"default": "",
|
||||
@ -211,13 +205,6 @@
|
||||
"description": "uses a reference to `babelHelpers` instead of placing helpers at the top of your code."
|
||||
},
|
||||
|
||||
"metadataUsedHelpers": {
|
||||
"deprecated": "Not required anymore as this is enabled by default",
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"hidden": true
|
||||
},
|
||||
|
||||
"sourceMap": {
|
||||
"alias": "sourceMaps",
|
||||
"hidden": true
|
||||
@ -230,11 +217,6 @@
|
||||
"shorthand": "s"
|
||||
},
|
||||
|
||||
"sourceMapName": {
|
||||
"alias": "sourceMapTarget",
|
||||
"description": "DEPRECATED - Please use sourceMapTarget"
|
||||
},
|
||||
|
||||
"sourceMapTarget": {
|
||||
"type": "string",
|
||||
"description": "set `file` on returned source map"
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import Transformer from "../transformer";
|
||||
import Plugin from "../plugin";
|
||||
import * as types from "babel-types";
|
||||
import * as messages from "babel-messages";
|
||||
@ -8,7 +7,6 @@ import parse from "../../helpers/parse";
|
||||
|
||||
var context = {
|
||||
messages,
|
||||
Transformer,
|
||||
Plugin,
|
||||
types,
|
||||
parse,
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
import Plugin from "./plugin";
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
|
||||
export default class Transformer {
|
||||
constructor(key, obj) {
|
||||
var plugin = {};
|
||||
|
||||
plugin.metadata = obj.metadata;
|
||||
delete obj.metadata;
|
||||
|
||||
plugin.visitor = obj;
|
||||
|
||||
return new Plugin(key, plugin);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user