Remove unneeded util.js file.
This commit is contained in:
parent
3e2d731d50
commit
b71569ff6c
@ -9,7 +9,6 @@ import merge from "../helpers/merge";
|
|||||||
import removed from "./removed";
|
import removed from "./removed";
|
||||||
import buildConfigChain from "./build-config-chain";
|
import buildConfigChain from "./build-config-chain";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import * as util from "../util";
|
|
||||||
|
|
||||||
type PluginObject = {
|
type PluginObject = {
|
||||||
pre?: Function;
|
pre?: Function;
|
||||||
@ -373,7 +372,12 @@ export default class OptionManager {
|
|||||||
this.mergeOptions(config);
|
this.mergeOptions(config);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
e.message = util.message(opts, e.message);
|
// There are a few case where thrown errors will try to annotate themselves multiple times, so
|
||||||
|
// to keep things simple we just bail out if re-wrapping the message.
|
||||||
|
if (!/^\[BABEL\]/.test(e.message)) {
|
||||||
|
e.message = `[BABEL] ${opts.filename || "unknown"}: ${e.message}`;
|
||||||
|
}
|
||||||
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,9 +11,9 @@ import codeFrame from "babel-code-frame";
|
|||||||
import traverse from "babel-traverse";
|
import traverse from "babel-traverse";
|
||||||
import Store from "../store";
|
import Store from "../store";
|
||||||
import { parse } from "babylon";
|
import { parse } from "babylon";
|
||||||
import * as util from "../../util";
|
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import * as t from "babel-types";
|
import * as t from "babel-types";
|
||||||
|
import buildDebug from "debug";
|
||||||
|
|
||||||
import resolve from "../../helpers/resolve";
|
import resolve from "../../helpers/resolve";
|
||||||
import OptionManager from "../../config/option-manager";
|
import OptionManager from "../../config/option-manager";
|
||||||
@ -21,6 +21,12 @@ import OptionManager from "../../config/option-manager";
|
|||||||
import blockHoistPlugin from "../internal-plugins/block-hoist";
|
import blockHoistPlugin from "../internal-plugins/block-hoist";
|
||||||
import shadowFunctionsPlugin from "../internal-plugins/shadow-functions";
|
import shadowFunctionsPlugin from "../internal-plugins/shadow-functions";
|
||||||
|
|
||||||
|
const babelDebug = buildDebug("babel:file");
|
||||||
|
|
||||||
|
export function debug(opts: Object, msg: string) {
|
||||||
|
babelDebug(`${opts.filename || "unknown"}: ${msg}`);
|
||||||
|
}
|
||||||
|
|
||||||
const shebangRegex = /^#!.*/;
|
const shebangRegex = /^#!.*/;
|
||||||
|
|
||||||
const INTERNAL_PLUGINS = new OptionManager().init({
|
const INTERNAL_PLUGINS = new OptionManager().init({
|
||||||
@ -362,9 +368,9 @@ export default class File extends Store {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
util.debug(this.opts, "Parse start");
|
debug(this.opts, "Parse start");
|
||||||
const ast = parseCode(code, parserOpts || this.parserOpts);
|
const ast = parseCode(code, parserOpts || this.parserOpts);
|
||||||
util.debug(this.opts, "Parse stop");
|
debug(this.opts, "Parse stop");
|
||||||
return ast;
|
return ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -382,9 +388,9 @@ export default class File extends Store {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addAst(ast) {
|
addAst(ast) {
|
||||||
util.debug(this.opts, "Start set AST");
|
debug(this.opts, "Start set AST");
|
||||||
this._addAst(ast);
|
this._addAst(ast);
|
||||||
util.debug(this.opts, "End set AST");
|
debug(this.opts, "End set AST");
|
||||||
}
|
}
|
||||||
|
|
||||||
transform(): BabelFileResult {
|
transform(): BabelFileResult {
|
||||||
@ -408,13 +414,13 @@ export default class File extends Store {
|
|||||||
if (fn) fn.call(pass, this);
|
if (fn) fn.call(pass, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
util.debug(this.opts, "Start transform traverse");
|
debug(this.opts, "Start transform traverse");
|
||||||
|
|
||||||
// merge all plugin visitors into a single visitor
|
// merge all plugin visitors into a single visitor
|
||||||
const visitor = traverse.visitors.merge(visitors, passes, this.opts.wrapPluginVisitorMethod);
|
const visitor = traverse.visitors.merge(visitors, passes, this.opts.wrapPluginVisitorMethod);
|
||||||
traverse(this.ast, visitor, this.scope);
|
traverse(this.ast, visitor, this.scope);
|
||||||
|
|
||||||
util.debug(this.opts, "End transform traverse");
|
debug(this.opts, "End transform traverse");
|
||||||
|
|
||||||
for (const [ plugin, pass ] of passPairs) {
|
for (const [ plugin, pass ] of passPairs) {
|
||||||
const fn = plugin.post;
|
const fn = plugin.post;
|
||||||
@ -543,14 +549,14 @@ export default class File extends Store {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
util.debug(this.opts, "Generation start");
|
debug(this.opts, "Generation start");
|
||||||
|
|
||||||
const _result = gen(ast, opts.generatorOpts ? Object.assign(opts, opts.generatorOpts) : opts,
|
const _result = gen(ast, opts.generatorOpts ? Object.assign(opts, opts.generatorOpts) : opts,
|
||||||
this.code);
|
this.code);
|
||||||
result.code = _result.code;
|
result.code = _result.code;
|
||||||
result.map = _result.map;
|
result.map = _result.map;
|
||||||
|
|
||||||
util.debug(this.opts, "Generation end");
|
debug(this.opts, "Generation end");
|
||||||
|
|
||||||
if (this.shebang) {
|
if (this.shebang) {
|
||||||
// add back shebang
|
// add back shebang
|
||||||
|
|||||||
@ -1,17 +0,0 @@
|
|||||||
import buildDebug from "debug";
|
|
||||||
|
|
||||||
export { inherits, inspect } from "util";
|
|
||||||
|
|
||||||
const debugBabel = buildDebug("babel");
|
|
||||||
|
|
||||||
export function debug(opts: Object, msg: string) {
|
|
||||||
debugBabel(message(opts, msg));
|
|
||||||
}
|
|
||||||
|
|
||||||
export function message(opts: Object, msg: string) {
|
|
||||||
// There are a few case where throws errors will try to annotate themselves multiple times, so
|
|
||||||
// to keep things simple we just bail out if re-wrapping the message.
|
|
||||||
if (/^\[BABEL\]/.test(msg)) return msg;
|
|
||||||
|
|
||||||
return `[BABEL] ${opts.filename || "unknown"}: ${msg}`;
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user