Merge pull request #5489 from loganfsmyth/conf-refactor

Misc fixes + Move babel-core config processing from transformation/file/options into top-level folder
This commit is contained in:
Henry Zhu
2017-03-21 14:12:41 -04:00
committed by GitHub
32 changed files with 235 additions and 200 deletions

View File

@@ -27,7 +27,7 @@
"eslint": "^3.9.0",
"eslint-config-babel": "^6.0.0",
"eslint-plugin-flowtype": "^2.20.0",
"flow-bin": "^0.34.0",
"flow-bin": "^0.41.0",
"gulp": "^3.9.0",
"gulp-babel": "^6.0.0",
"gulp-newer": "^1.0.0",

View File

@@ -1,5 +1,5 @@
import * as babel from "../../../index";
import resolve from "../../../helpers/resolve";
import * as babel from "../index";
import resolve from "./helpers/resolve";
import json5 from "json5";
import path from "path";
import fs from "fs";
@@ -28,6 +28,7 @@ export default function buildConfigChain(opts: Object = {}) {
try {
builder.mergeConfig({
type: "arguments",
options: opts,
alias: "base",
dirname: process.cwd(),
@@ -185,6 +186,7 @@ class ConfigChainBuilder {
if (lines.length) {
this.mergeConfig({
type: "options",
options: { ignore: lines },
alias: loc,
dirname: path.dirname(loc),
@@ -231,6 +233,7 @@ class ConfigChainBuilder {
}
this.mergeConfig({
type: "options",
options,
alias: loc,
dirname: path.dirname(loc),
@@ -240,6 +243,7 @@ class ConfigChainBuilder {
}
mergeConfig({
type,
options,
alias,
loc,
@@ -266,6 +270,7 @@ class ConfigChainBuilder {
delete options.env;
this.mergeConfig({
type,
options: envOpts,
alias: `${alias}.env.${envKey}`,
dirname: dirname,
@@ -273,6 +278,7 @@ class ConfigChainBuilder {
}
this.configs.push({
type,
options,
alias,
loc,

View File

@@ -0,0 +1,30 @@
import type Plugin from "./plugin";
import OptionManager from "./option-manager";
export type ResolvedConfig = {
options: Object,
passes: Array<Array<Plugin>>,
};
/**
* Standard API for loading Babel configuration data. Not for public consumption.
*/
export default function loadConfig(opts: Object): ResolvedConfig|null {
const mergedOpts = new OptionManager().init(opts);
if (!mergedOpts) return null;
let passes = [];
if (mergedOpts.plugins) {
passes.push(mergedOpts.plugins);
}
// With "passPerPreset" enabled there may still be presets in the options.
if (mergedOpts.presets) {
passes = passes.concat(mergedOpts.presets.map((preset) => preset.plugins).filter(Boolean));
}
return {
options: mergedOpts,
passes,
};
}

View File

@@ -1,15 +1,15 @@
import * as context from "../../../index";
import Plugin from "../../plugin";
import * as context from "../index";
import Plugin from "./plugin";
import * as messages from "babel-messages";
import resolvePlugin from "../../../helpers/resolve-plugin";
import resolvePreset from "../../../helpers/resolve-preset";
import resolve from "./helpers/resolve";
import resolvePlugin from "./helpers/resolve-plugin";
import resolvePreset from "./helpers/resolve-preset";
import defaults from "lodash/defaults";
import cloneDeepWith from "lodash/cloneDeepWith";
import merge from "../../../helpers/merge";
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;
@@ -25,6 +25,7 @@ type PluginObject = {
};
type MergeOptions = {
type: "arguments"|"options"|"preset",
options?: Object,
extending?: Object,
alias: string,
@@ -188,6 +189,7 @@ export default class OptionManager {
*/
mergeOptions({
type,
options: rawOpts,
extending: extendingOpts,
alias,
@@ -213,6 +215,23 @@ export default class OptionManager {
dirname = dirname || process.cwd();
loc = loc || alias;
if (type !== "arguments") {
if (opts.filename !== undefined) {
throw new Error(`${alias}.filename is only allowed as a root argument`);
}
if (opts.babelrc !== undefined) {
throw new Error(`${alias}.babelrc is only allowed as a root argument`);
}
}
if (type === "preset") {
if (opts.only !== undefined) throw new Error(`${alias}.only is not supported in a preset`);
if (opts.ignore !== undefined) throw new Error(`${alias}.ignore is not supported in a preset`);
if (opts.extends !== undefined) throw new Error(`${alias}.extends is not supported in a preset`);
if (opts.env !== undefined) throw new Error(`${alias}.env is not supported in a preset`);
}
if (opts.sourceMap !== undefined) {
if (opts.sourceMaps !== undefined) {
throw new Error(`Both ${alias}.sourceMap and .sourceMaps have been set`);
@@ -236,6 +255,26 @@ export default class OptionManager {
}
}
if (opts.parserOpts && typeof opts.parserOpts.parser === "string") {
const parser = resolve(opts.parserOpts.parser, dirname);
if (parser) {
opts.parserOpts.parser = require(parser).parse;
} else {
throw new Error(`Couldn't find parser ${opts.parserOpts.parser} with "parse" method ` +
`relative to directory ${dirname}`);
}
}
if (opts.generatorOpts && typeof opts.generatorOpts.generator === "string") {
const generator = resolve(opts.generatorOpts.generator, dirname);
if (generator) {
opts.generatorOpts.generator = require(generator).print;
} else {
throw new Error(`Couldn't find generator ${opts.generatorOpts.generator} with "print" method ` +
`relative to directory ${dirname}`);
}
}
// resolve plugins
if (opts.plugins) {
if (!Array.isArray(rawOpts.plugins)) throw new Error(`${alias}.plugins should be an array`);
@@ -247,23 +286,22 @@ export default class OptionManager {
if (opts.presets) {
if (!Array.isArray(rawOpts.presets)) throw new Error(`${alias}.presets should be an array`);
// If we're in the "pass per preset" mode, we resolve the presets
// and keep them for further execution to calculate the options.
if (opts.passPerPreset) {
opts.presets = this.resolvePresets(opts.presets, dirname, (preset, presetLoc) => {
this.mergeOptions({
options: preset,
extending: preset,
alias: presetLoc,
loc: presetLoc,
dirname: dirname,
});
opts.presets = this.resolvePresets(opts.presets, dirname, (preset, presetLoc) => {
this.mergeOptions({
type: "preset",
options: preset,
// For `passPerPreset` we merge child options back into the preset object instead of the root.
extending: opts.passPerPreset ? preset : null,
alias: presetLoc,
loc: presetLoc,
dirname: dirname,
});
} else {
// Otherwise, just merge presets options into the main options.
this.mergePresets(opts.presets, dirname);
delete opts.presets;
}
});
// If not passPerPreset, the plugins have all been merged into the parent config so the presets
// list is not needed.
if (!opts.passPerPreset) delete opts.presets;
}
// Merge them into current extending options in case of top-level
@@ -276,21 +314,6 @@ export default class OptionManager {
}
}
/**
* Merges all presets into the main options in case we are not in the
* "pass per preset" mode. Otherwise, options are calculated per preset.
*/
mergePresets(presets: Array<string | Object>, dirname: string) {
this.resolvePresets(presets, dirname, (presetOpts, presetLoc) => {
this.mergeOptions({
options: presetOpts,
alias: presetLoc,
loc: presetLoc,
dirname: path.dirname(presetLoc || ""),
});
});
}
/**
* Resolves presets options which can be either direct object data,
* or a module name to require.
@@ -370,7 +393,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;
}

View File

@@ -1,15 +1,12 @@
import OptionManager from "./file/options/option-manager";
import OptionManager from "./option-manager";
import * as messages from "babel-messages";
import Store from "../store";
import traverse from "babel-traverse";
import clone from "lodash/clone";
const GLOBAL_VISITOR_PROPS = ["enter", "exit"];
export default class Plugin extends Store {
export default class Plugin {
constructor(plugin: Object, key?: string) {
super();
this.initialized = false;
this.raw = Object.assign({}, plugin);
this.key = this.take("name") || key;

View File

@@ -1,23 +0,0 @@
import * as t from "babel-types";
/**
* Normalize an AST.
*
* - Wrap `Program` node with a `File` node.
*/
export default function (
ast: Object,
comments?: Array<Object>,
tokens?: Array<Object>,
) {
if (ast) {
if (ast.type === "Program") {
return t.file(ast, comments || [], tokens || []);
} else if (ast.type === "File") {
return ast;
}
}
throw new Error("Not a valid ast?");
}

View File

@@ -1,17 +1,30 @@
export File from "./transformation/file";
export buildExternalHelpers from "./tools/build-external-helpers";
export resolvePlugin from "./helpers/resolve-plugin";
export resolvePreset from "./helpers/resolve-preset";
export resolvePlugin from "./config/helpers/resolve-plugin";
export resolvePreset from "./config/helpers/resolve-preset";
export { version } from "../package";
export { getEnv } from "./helpers/environment";
export { getEnv } from "./config/helpers/environment";
export * as messages from "babel-messages";
export * as types from "babel-types";
export traverse from "babel-traverse";
export template from "babel-template";
export OptionManager from "./transformation/file/options/option-manager";
import loadConfig from "./config";
export function loadOptions(opts): Object|null {
const config = loadConfig(opts);
return config ? config.options : null;
}
// For easier backward-compatibility, provide an API like the one we exposed in Babel 6.
export class OptionManager {
init(opts) {
return loadOptions(opts);
}
}
export function Plugin(alias) {
throw new Error(`The (${alias}) Babel 5 plugin is being run with Babel 6.`);

View File

@@ -9,23 +9,28 @@ import sourceMap from "source-map";
import generate from "babel-generator";
import codeFrame from "babel-code-frame";
import traverse from "babel-traverse";
import Store from "../../store";
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 loadConfig, { type ResolvedConfig } from "../../config";
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 = [
[blockHoistPlugin],
[shadowFunctionsPlugin],
];
const INTERNAL_PLUGINS = loadConfig({
babelrc: false,
plugins: [ blockHoistPlugin, shadowFunctionsPlugin ],
}).passes[0];
const errorVisitor = {
enter(path, state) {
@@ -38,17 +43,11 @@ const errorVisitor = {
};
export default class File extends Store {
constructor(opts: Object = {}) {
constructor({ options, passes }: ResolvedConfig) {
super();
let passes = [];
if (opts.plugins) passes.push(opts.plugins);
// With "passPerPreset" enabled there may still be presets in the options.
if (opts.presets) passes = passes.concat(opts.presets.map((preset) => preset.plugins).filter(Boolean));
this.pluginPasses = passes;
this.opts = opts;
this.opts = options;
this.parserOpts = {
sourceType: this.opts.sourceType,
@@ -59,7 +58,7 @@ export default class File extends Store {
for (const pluginPairs of passes) {
for (const [ plugin ] of pluginPairs) {
if (plugin.manipulateOptions) {
plugin.manipulateOptions(opts, this.parserOpts, this);
plugin.manipulateOptions(this.opts, this.parserOpts, this);
}
}
}
@@ -340,18 +339,7 @@ export default class File extends Store {
parserOpts = Object.assign({}, this.parserOpts, parserOpts);
if (parserOpts.parser) {
if (typeof parserOpts.parser === "string") {
const dirname = path.dirname(this.opts.filename) || process.cwd();
const parser = resolve(parserOpts.parser, dirname);
if (parser) {
parseCode = require(parser).parse;
} else {
throw new Error(`Couldn't find parser ${parserOpts.parser} with "parse" method ` +
`relative to directory ${dirname}`);
}
} else {
parseCode = parserOpts.parser;
}
parseCode = parserOpts.parser;
parserOpts.parser = {
parse(source) {
@@ -361,9 +349,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;
}
@@ -381,31 +369,43 @@ 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 {
for (const pluginPairs of this.pluginPasses) {
const passPairs = [];
const passes = [];
const visitors = [];
for (const [ plugin, pluginOpts ] of pluginPairs.concat(INTERNAL_PLUGINS)) {
const pass = new PluginPass(this, plugin, pluginOpts);
const pass = new PluginPass(this, plugin.key, pluginOpts);
passPairs.push([ plugin, pass ]);
passes.push(pass);
visitors.push(plugin.visitor);
}
this.call("pre", passes);
util.debug(this.opts, "Start transform traverse");
for (const [ plugin, pass ] of passPairs) {
const fn = plugin.pre;
if (fn) fn.call(pass, this);
}
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");
this.call("post", passes);
debug(this.opts, "End transform traverse");
for (const [ plugin, pass ] of passPairs) {
const fn = plugin.post;
if (fn) fn.call(pass, this);
}
}
return this.generate();
@@ -458,14 +458,6 @@ export default class File extends Store {
this.addAst(ast);
}
call(key: "pre" | "post", pluginPasses: Array<PluginPass>) {
for (const pass of pluginPasses) {
const plugin = pass.plugin;
const fn = plugin[key];
if (fn) fn.call(pass, this);
}
}
parseInputSourceMap(code: string): string {
const opts = this.opts;
@@ -523,27 +515,16 @@ export default class File extends Store {
let gen = generate;
if (opts.generatorOpts && opts.generatorOpts.generator) {
gen = opts.generatorOpts.generator;
if (typeof gen === "string") {
const dirname = path.dirname(this.opts.filename) || process.cwd();
const generator = resolve(gen, dirname);
if (generator) {
gen = require(generator).print;
} else {
throw new Error(`Couldn't find generator ${gen} with "print" method relative ` +
`to directory ${dirname}`);
}
}
}
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

View File

@@ -1,7 +1,6 @@
import Plugin from "../plugin";
import sortBy from "lodash/sortBy";
export default new Plugin({
export default {
/**
* [Please add a description.]
*
@@ -39,4 +38,4 @@ export default new Plugin({
},
},
},
});
};

View File

@@ -1,4 +1,3 @@
import Plugin from "../plugin";
import * as t from "babel-types";
const SUPER_THIS_BOUND = Symbol("super this bound");
@@ -15,7 +14,7 @@ const superVisitor = {
},
};
export default new Plugin({
export default {
name: "internal.shadowFunctions",
visitor: {
@@ -29,7 +28,7 @@ export default new Plugin({
}
},
},
});
};
function shouldShadow(path, shadowPath) {
if (path.is("_forceShadow")) {

View File

@@ -1,25 +1,24 @@
/* global BabelFileResult, BabelFileMetadata */
import fs from "fs";
import normalizeAst from "../helpers/normalize-ast";
import Plugin from "./plugin";
import * as t from "babel-types";
import File from "./file";
import OptionManager from "./file/options/option-manager";
import loadConfig from "../config";
export function analyse(code: string, opts: Object = {}, visitor?: Object): ?BabelFileMetadata {
opts.code = false;
if (visitor) {
opts.plugins = opts.plugins || [];
opts.plugins.push(new Plugin({ visitor }));
opts.plugins.push({ visitor });
}
return transform(code, opts).metadata;
}
export function transform(code: string, opts?: Object): BabelFileResult {
opts = new OptionManager().init(opts);
if (opts === null) return null;
const config = loadConfig(opts);
if (config === null) return null;
const file = new File(opts);
const file = new File(config);
return file.wrap(code, function () {
file.addCode(code);
file.parseCode(code);
@@ -28,12 +27,16 @@ export function transform(code: string, opts?: Object): BabelFileResult {
}
export function transformFromAst(ast: Object, code: string, opts: Object): BabelFileResult {
opts = new OptionManager().init(opts);
if (opts === null) return null;
const config = loadConfig(opts);
if (config === null) return null;
ast = normalizeAst(ast);
if (ast && ast.type === "Program") {
return t.file(ast, [], []);
} else if (!ast || ast.type !== "File") {
throw new Error("Not a valid ast?");
}
const file = new File(opts);
const file = new File(config);
return file.wrap(code, function () {
file.addCode(code);
file.addAst(ast);
@@ -48,15 +51,15 @@ export function transformFile(filename: string, opts?: Object, callback: Functio
}
opts.filename = filename;
opts = new OptionManager().init(opts);
if (opts === null) return callback(null, null);
const config = loadConfig(opts);
if (config === null) return callback(null, null);
fs.readFile(filename, function (err, code) {
let result;
if (!err) {
try {
const file = new File(opts);
const file = new File(config);
result = file.wrap(code, function () {
file.addCode(code);
file.parseCode(code);
@@ -77,11 +80,11 @@ export function transformFile(filename: string, opts?: Object, callback: Functio
export function transformFileSync(filename: string, opts?: Object = {}): string {
opts.filename = filename;
opts = new OptionManager().init(opts);
if (opts === null) return null;
const config = loadConfig(opts);
if (config === null) return null;
const code = fs.readFileSync(filename, "utf8");
const file = new File(opts);
const file = new File(config);
return file.wrap(code, function () {
file.addCode(code);

View File

@@ -1,18 +1,16 @@
import type Plugin from "./plugin";
import Store from "../store";
import Store from "./store";
import File from "./file";
export default class PluginPass extends Store {
constructor(file: File, plugin: Plugin, options: Object = {}) {
constructor(file: File, key: string, options: Object = {}) {
super();
this.plugin = plugin;
this.key = plugin.key;
this.key = key;
this.file = file;
this.opts = options;
}
key: string;
plugin: Plugin;
file: File;
opts: Object;

View File

@@ -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}`;
}

View File

@@ -2,7 +2,7 @@ import * as babel from "../lib/index";
import buildExternalHelpers from "../lib/tools/build-external-helpers";
import sourceMap from "source-map";
import assert from "assert";
import Plugin from "../lib/transformation/plugin";
import Plugin from "../lib/config/plugin";
import generator from "babel-generator";
function assertIgnored(result) {

View File

@@ -1,6 +1,6 @@
import assert from "assert";
import path from "path";
import buildConfigChain from "../lib/transformation/file/options/build-config-chain";
import buildConfigChain from "../lib/config/build-config-chain";
function fixture() {
const args = [__dirname, "fixtures", "config"];
@@ -40,6 +40,7 @@ describe("buildConfigChain", function () {
const expected = [
{
type: "options",
options: {
plugins: [
"extended",
@@ -50,6 +51,7 @@ describe("buildConfigChain", function () {
dirname: fixture(),
},
{
type: "options",
options: {
plugins: [
"root",
@@ -60,6 +62,7 @@ describe("buildConfigChain", function () {
dirname: fixture(),
},
{
type: "options",
options: {
ignore: [
"root-ignore",
@@ -70,6 +73,7 @@ describe("buildConfigChain", function () {
dirname: fixture(),
},
{
type: "arguments",
options: {
filename: fixture("dir1", "src.js"),
},
@@ -89,6 +93,7 @@ describe("buildConfigChain", function () {
const expected = [
{
type: "options",
options: {
ignore: [
"root-ignore",
@@ -99,6 +104,7 @@ describe("buildConfigChain", function () {
dirname: fixture(),
},
{
type: "options",
options: {
plugins: [
"dir2",
@@ -109,6 +115,7 @@ describe("buildConfigChain", function () {
dirname: fixture("dir2"),
},
{
type: "arguments",
options: {
filename: fixture("dir2", "src.js"),
},
@@ -128,6 +135,7 @@ describe("buildConfigChain", function () {
const expected = [
{
type: "options",
options: {
ignore: [
"root-ignore",
@@ -138,6 +146,7 @@ describe("buildConfigChain", function () {
dirname: fixture(),
},
{
type: "options",
options: {
plugins: [
"env-base",
@@ -148,6 +157,7 @@ describe("buildConfigChain", function () {
dirname: fixture("env"),
},
{
type: "arguments",
options: {
filename: fixture("env", "src.js"),
},
@@ -169,6 +179,7 @@ describe("buildConfigChain", function () {
const expected = [
{
type: "options",
options: {
ignore: [
"root-ignore",
@@ -179,6 +190,7 @@ describe("buildConfigChain", function () {
dirname: fixture(),
},
{
type: "options",
options: {
plugins: [
"env-base",
@@ -189,6 +201,7 @@ describe("buildConfigChain", function () {
dirname: fixture("env"),
},
{
type: "options",
options: {
plugins: [
"env-foo",
@@ -199,6 +212,7 @@ describe("buildConfigChain", function () {
dirname: fixture("env"),
},
{
type: "arguments",
options: {
filename: fixture("env", "src.js"),
},
@@ -221,6 +235,7 @@ describe("buildConfigChain", function () {
const expected = [
{
type: "options",
options: {
ignore: [
"root-ignore",
@@ -231,6 +246,7 @@ describe("buildConfigChain", function () {
dirname: fixture(),
},
{
type: "options",
options: {
plugins: [
"env-base",
@@ -241,6 +257,7 @@ describe("buildConfigChain", function () {
dirname: fixture("env"),
},
{
type: "options",
options: {
plugins: [
"env-bar",
@@ -251,6 +268,7 @@ describe("buildConfigChain", function () {
dirname: fixture("env"),
},
{
type: "arguments",
options: {
filename: fixture("env", "src.js"),
},
@@ -273,6 +291,7 @@ describe("buildConfigChain", function () {
const expected = [
{
type: "options",
options: {
plugins: ["pkg-plugin"],
},
@@ -281,6 +300,7 @@ describe("buildConfigChain", function () {
dirname: fixture("pkg"),
},
{
type: "options",
options: {
ignore: ["pkg-ignore"],
},
@@ -289,6 +309,7 @@ describe("buildConfigChain", function () {
dirname: fixture("pkg"),
},
{
type: "arguments",
options: {
filename: fixture("pkg", "src.js"),
},
@@ -308,6 +329,7 @@ describe("buildConfigChain", function () {
const expected = [
{
type: "options",
options: {
ignore: [
"root-ignore",
@@ -318,6 +340,7 @@ describe("buildConfigChain", function () {
dirname: fixture(),
},
{
type: "options",
options: {
plugins: [
"foo",
@@ -329,6 +352,7 @@ describe("buildConfigChain", function () {
dirname: fixture("js-config"),
},
{
type: "arguments",
options: {
filename: fixture("js-config", "src.js"),
},
@@ -348,6 +372,7 @@ describe("buildConfigChain", function () {
const expected = [
{
type: "options",
options: {
ignore: [
"root-ignore",
@@ -358,6 +383,7 @@ describe("buildConfigChain", function () {
dirname: fixture(),
},
{
type: "options",
options: {
plugins: [
"foo",
@@ -369,6 +395,7 @@ describe("buildConfigChain", function () {
dirname: fixture("js-config-default"),
},
{
type: "arguments",
options: {
filename: fixture("js-config-default", "src.js"),
},
@@ -387,6 +414,7 @@ describe("buildConfigChain", function () {
const expected = [
{
type: "options",
options: {
ignore: [
"root-ignore",
@@ -397,6 +425,7 @@ describe("buildConfigChain", function () {
dirname: fixture(),
},
{
type: "options",
options: {
plugins: [
"extended",
@@ -407,6 +436,7 @@ describe("buildConfigChain", function () {
dirname: fixture(),
},
{
type: "options",
options: {
plugins: [
"foo",
@@ -418,6 +448,7 @@ describe("buildConfigChain", function () {
dirname: fixture("js-config-extended"),
},
{
type: "arguments",
options: {
filename: fixture("js-config-extended", "src.js"),
},
@@ -438,6 +469,7 @@ describe("buildConfigChain", function () {
const expected = [
{
type: "options",
options: {
ignore: [
"root-ignore",
@@ -448,6 +480,7 @@ describe("buildConfigChain", function () {
dirname: fixture(),
},
{
type: "options",
options: {
plugins: [
"json",
@@ -458,6 +491,7 @@ describe("buildConfigChain", function () {
dirname: fixture("json-pkg-config-no-babel"),
},
{
type: "arguments",
options: {
filename: fixture("json-pkg-config-no-babel", "src.js"),
},

View File

@@ -1,5 +1,5 @@
import assert from "assert";
import getPossiblePluginNames from "../lib/helpers/get-possible-plugin-names";
import getPossiblePluginNames from "../lib/config/helpers/get-possible-plugin-names";
describe("getPossiblePluginNames", function () {
it("adds the babel-plugin prefix", function() {

View File

@@ -1,5 +1,5 @@
import assert from "assert";
import getPossiblePresetNames from "../lib/helpers/get-possible-preset-names";
import getPossiblePresetNames from "../lib/config/helpers/get-possible-preset-names";
describe("getPossiblePresetNames", function () {
it("adds the babel-preset prefix", function() {

View File

@@ -1,5 +1,5 @@
import assert from "assert";
import OptionManager from "../lib/transformation/file/options/option-manager";
import OptionManager from "../lib/config/option-manager";
import path from "path";
describe("option-manager", () => {

View File

@@ -1,5 +1,5 @@
import { transform } from "../lib/index";
import Plugin from "../lib/transformation/plugin";
import Plugin from "../lib/config/plugin";
import chai from "chai";
describe("traversal path", function () {

View File

@@ -3,10 +3,6 @@ import transformReactJSX from "babel-plugin-transform-react-jsx";
import transformSyntaxJSX from "babel-plugin-syntax-jsx";
import transformReactDisplayName from "babel-plugin-transform-react-display-name";
// These imports not yet used...
// import transformReactJSXSource from "babel-plugin-transform-react-jsx-source";
// import transformReactJSXSelf from "babel-plugin-transform-react-jsx-self";
export default function () {
return {
presets: [
@@ -17,13 +13,5 @@ export default function () {
transformSyntaxJSX,
transformReactDisplayName,
],
env: {
development: {
plugins: [
// transformReactJSXSource,
// transformReactJSXSelf
],
},
},
};
}

View File

@@ -25,7 +25,6 @@ paths.forEach(function (path) {
var helpers = require("babel-helpers");
var babel = require("../../babel-core");
var util = require("../../babel-core/lib/util");
var t = require("../../babel-types");
function relative(filename) {

View File

@@ -1926,9 +1926,9 @@ flat-cache@^1.2.1:
graceful-fs "^4.1.2"
write "^0.2.1"
flow-bin@^0.34.0:
version "0.34.0"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.34.0.tgz#093ed36981e8fafc39d16f0b0878d0968aa80fad"
flow-bin@^0.41.0:
version "0.41.0"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.41.0.tgz#8badac9a19da45004997e599bd316518db489b2e"
for-in@^0.1.5:
version "0.1.6"