Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc fixes + Move babel-core config processing from transformation/file/options into top-level folder #5489

Merged
merged 16 commits into from Mar 21, 2017
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Remove unneeded util.js file.

  • Loading branch information
loganfsmyth committed Mar 16, 2017
commit b71569ff6cd4ee36c01db79017c7ac79f27c175b
@@ -9,7 +9,6 @@ import merge from "../helpers/merge";
import removed from "./removed";
import buildConfigChain from "./build-config-chain";
import path from "path";
import * as util from "../util";

type PluginObject = {
pre?: Function;
@@ -373,7 +372,12 @@ export default class OptionManager {
this.mergeOptions(config);
}
} 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;
}

@@ -11,16 +11,22 @@ import codeFrame from "babel-code-frame";
import traverse from "babel-traverse";
import Store from "../store";
import { parse } from "babylon";
import * as util from "../../util";
import path from "path";
import * as t from "babel-types";
import buildDebug from "debug";

import resolve from "../../helpers/resolve";
import OptionManager from "../../config/option-manager";

import blockHoistPlugin from "../internal-plugins/block-hoist";
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 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);
util.debug(this.opts, "Parse stop");
debug(this.opts, "Parse stop");
return ast;
}

@@ -382,9 +388,9 @@ export default class File extends Store {
}

addAst(ast) {
util.debug(this.opts, "Start set AST");
debug(this.opts, "Start set AST");
this._addAst(ast);
util.debug(this.opts, "End set AST");
debug(this.opts, "End set AST");
}

transform(): BabelFileResult {
@@ -408,13 +414,13 @@ export default class File extends Store {
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
const visitor = traverse.visitors.merge(visitors, passes, this.opts.wrapPluginVisitorMethod);
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) {
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,
this.code);
result.code = _result.code;
result.map = _result.map;

util.debug(this.opts, "Generation end");
debug(this.opts, "Generation end");

if (this.shebang) {
// add back shebang

This file was deleted.

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.