diff --git a/packages/babel-cli/src/_babel-node.js b/packages/babel-cli/src/_babel-node.js index bc71abb00d..3d0e1f319d 100644 --- a/packages/babel-cli/src/_babel-node.js +++ b/packages/babel-cli/src/_babel-node.js @@ -9,6 +9,8 @@ import vm from "vm"; import "babel-polyfill"; import register from "babel-register"; +import pkg from "../package.json"; + const program = new commander.Command("babel-node"); program.option("-e, --eval [script]", "Evaluate script"); @@ -19,7 +21,6 @@ program.option("-x, --extensions [extensions]", "List of extensions to hook into program.option("-w, --plugins [string]", "", util.list); program.option("-b, --presets [string]", "", util.list); -const pkg = require("../package.json"); program.version(pkg.version); program.usage("[options] [ -e script | script.js ] [arguments]"); program.parse(process.argv); diff --git a/packages/babel-cli/src/babel-node.js b/packages/babel-cli/src/babel-node.js index ee25b5f48a..d92f0e863b 100755 --- a/packages/babel-cli/src/babel-node.js +++ b/packages/babel-cli/src/babel-node.js @@ -3,8 +3,8 @@ * when found, before invoking the "real" _babel-node(1) executable. */ -const getV8Flags = require("v8flags"); -const path = require("path"); +import getV8Flags from "v8flags"; +import path from "path"; let args = [path.join(__dirname, "_babel-node")]; diff --git a/packages/babel-cli/src/babel/dir.js b/packages/babel-cli/src/babel/dir.js index 364e020733..91731f39fe 100644 --- a/packages/babel-cli/src/babel/dir.js +++ b/packages/babel-cli/src/babel/dir.js @@ -1,10 +1,11 @@ -const outputFileSync = require("output-file-sync"); -const slash = require("slash"); -const path = require("path"); -const util = require("./util"); -const fs = require("fs"); +import outputFileSync from "output-file-sync"; +import slash from "slash"; +import path from "path"; +import fs from "fs"; -module.exports = function (commander, filenames) { +import * as util from "./util"; + +export default function (commander, filenames) { function write(src, relative) { // remove extension and then append back on .js relative = relative.replace(/\.(\w*?)$/, "") + ".js"; @@ -88,4 +89,4 @@ module.exports = function (commander, filenames) { }); }); } -}; +} diff --git a/packages/babel-cli/src/babel/file.js b/packages/babel-cli/src/babel/file.js index e143be1a39..73b5ef14fc 100644 --- a/packages/babel-cli/src/babel/file.js +++ b/packages/babel-cli/src/babel/file.js @@ -1,11 +1,12 @@ -const convertSourceMap = require("convert-source-map"); -const sourceMap = require("source-map"); -const slash = require("slash"); -const path = require("path"); -const util = require("./util"); -const fs = require("fs"); +import convertSourceMap from "convert-source-map"; +import sourceMap from "source-map"; +import slash from "slash"; +import path from "path"; +import fs from "fs"; -module.exports = function (commander, filenames, opts) { +import * as util from "./util"; + +export default function (commander, filenames, opts) { if (commander.sourceMaps === "inline") { opts.sourceMaps = true; } @@ -176,4 +177,4 @@ module.exports = function (commander, filenames, opts) { } else { stdin(); } -}; +} diff --git a/packages/babel-cli/src/babel/index.js b/packages/babel-cli/src/babel/index.js index 194254bf61..2a5f4f9cd6 100755 --- a/packages/babel-cli/src/babel/index.js +++ b/packages/babel-cli/src/babel/index.js @@ -1,12 +1,16 @@ #!/usr/bin/env node -const fs = require("fs"); -const commander = require("commander"); -const kebabCase = require("lodash/kebabCase"); -const options = require("babel-core").options; -const util = require("babel-core").util; -const uniq = require("lodash/uniq"); -const glob = require("glob"); +import fs from "fs"; +import commander from "commander"; +import kebabCase from "lodash/kebabCase"; +import { options, util, version } from "babel-core"; +import uniq from "lodash/uniq"; +import glob from "glob"; + +import dirCommand from "./dir"; +import fileCommand from "./file"; + +import pkg from "../../package.json"; Object.keys(options).forEach(function (key) { const option = options[key]; @@ -45,8 +49,7 @@ commander.option("-D, --copy-files", "When compiling a directory copy over non-c commander.option("-q, --quiet", "Don't log anything"); /* eslint-enable max-len */ -const pkg = require("../../package.json"); -commander.version(pkg.version + " (babel-core " + require("babel-core").version + ")"); +commander.version(pkg.version + " (babel-core " + version + ")"); commander.usage("[options] "); commander.parse(process.argv); @@ -103,7 +106,7 @@ if (errors.length) { // -const opts = exports.opts = {}; +export const opts = {}; Object.keys(options).forEach(function (key) { const opt = options[key]; @@ -118,12 +121,5 @@ if (opts.only) { opts.only = util.arrayify(opts.only, util.regexify); } -let fn; - -if (commander.outDir) { - fn = require("./dir"); -} else { - fn = require("./file"); -} - -fn(commander, filenames, exports.opts); +const fn = commander.outDir ? dirCommand : fileCommand; +fn(commander, filenames, opts); diff --git a/packages/babel-cli/src/babel/util.js b/packages/babel-cli/src/babel/util.js index 7cdff17222..e92b09c671 100644 --- a/packages/babel-cli/src/babel/util.js +++ b/packages/babel-cli/src/babel/util.js @@ -1,11 +1,11 @@ -const commander = require("commander"); -const defaults = require("lodash/defaults"); -const readdir = require("fs-readdir-recursive"); -const index = require("./index"); -const babel = require("babel-core"); -const util = require("babel-core").util; -const path = require("path"); -const fs = require("fs"); +import commander from "commander"; +import defaults from "lodash/defaults"; +import readdir from "fs-readdir-recursive"; +import * as babel from "babel-core"; +import path from "path"; +import fs from "fs"; + +import * as index from "./index"; export function chmod(src, dest) { fs.chmodSync(dest, fs.statSync(src).mode); @@ -13,16 +13,16 @@ export function chmod(src, dest) { export function readdirFilter(filename) { return readdir(filename).filter(function (filename) { - return util.canCompile(filename); + return babel.util.canCompile(filename); }); } export { readdir }; -export const canCompile = util.canCompile; +export const canCompile = babel.util.canCompile; export function shouldIgnore(loc) { - return util.shouldIgnore(loc, index.opts.ignore, index.opts.only); + return babel.util.shouldIgnore(loc, index.opts.ignore, index.opts.only); } export function addSourceMappingUrl(code, loc) { diff --git a/packages/babel-core/src/transformation/file/options/config.js b/packages/babel-core/src/transformation/file/options/config.js index dbc60c6043..80e8bf7a00 100644 --- a/packages/babel-core/src/transformation/file/options/config.js +++ b/packages/babel-core/src/transformation/file/options/config.js @@ -1,6 +1,6 @@ /* eslint max-len: "off" */ -module.exports = { +export default { filename: { type: "filename", description: "filename to use when reading from stdin - this will be used in source-maps, errors etc", diff --git a/packages/babel-core/src/transformation/file/options/removed.js b/packages/babel-core/src/transformation/file/options/removed.js index cb0077cb92..6fea5223a8 100644 --- a/packages/babel-core/src/transformation/file/options/removed.js +++ b/packages/babel-core/src/transformation/file/options/removed.js @@ -1,6 +1,6 @@ /* eslint max-len: "off" */ -module.exports = { +export default { "auxiliaryComment": { "message": "Use `auxiliaryCommentBefore` or `auxiliaryCommentAfter`" }, diff --git a/packages/babel-generator/src/generators/index.js b/packages/babel-generator/src/generators/index.js new file mode 100644 index 0000000000..61db3d68ec --- /dev/null +++ b/packages/babel-generator/src/generators/index.js @@ -0,0 +1,10 @@ +export * from "./template-literals"; +export * from "./expressions"; +export * from "./statements"; +export * from "./classes"; +export * from "./methods"; +export * from "./modules"; +export * from "./types"; +export * from "./flow"; +export * from "./base"; +export * from "./jsx"; diff --git a/packages/babel-generator/src/generators/statements.js b/packages/babel-generator/src/generators/statements.js index e1492ad77c..f6291e0165 100644 --- a/packages/babel-generator/src/generators/statements.js +++ b/packages/babel-generator/src/generators/statements.js @@ -219,14 +219,14 @@ export function DebuggerStatement() { this.semicolon(); } -function variableDeclarationIdent() { +function variableDeclarationIndent() { // "let " or "var " indentation. this.token(","); this.newline(); if (this.endsWith("\n")) for (let i = 0; i < 4; i++) this.space(true); } -function constDeclarationIdent() { +function constDeclarationIndent() { // "const " indentation. this.token(","); this.newline(); @@ -262,7 +262,7 @@ export function VariableDeclaration(node: Object, parent: Object) { let separator; if (hasInits) { - separator = node.kind === "const" ? constDeclarationIdent : variableDeclarationIdent; + separator = node.kind === "const" ? constDeclarationIndent : variableDeclarationIndent; } // diff --git a/packages/babel-generator/src/node/index.js b/packages/babel-generator/src/node/index.js index c885f8032b..c3a17cea6c 100644 --- a/packages/babel-generator/src/node/index.js +++ b/packages/babel-generator/src/node/index.js @@ -1,4 +1,4 @@ -import whitespace from "./whitespace"; +import * as whitespace from "./whitespace"; import * as parens from "./parentheses"; import * as t from "babel-types"; diff --git a/packages/babel-generator/src/node/whitespace.js b/packages/babel-generator/src/node/whitespace.js index 1c47e594ec..e55396768b 100644 --- a/packages/babel-generator/src/node/whitespace.js +++ b/packages/babel-generator/src/node/whitespace.js @@ -60,7 +60,7 @@ function isType(node) { * Tests for node types that need whitespace. */ -exports.nodes = { +export const nodes = { /** * Test if AssignmentExpression needs whitespace. @@ -164,10 +164,10 @@ exports.nodes = { * Test if Property or SpreadProperty needs whitespace. */ -exports.nodes.ObjectProperty = -exports.nodes.ObjectTypeProperty = -exports.nodes.ObjectMethod = -exports.nodes.SpreadProperty = function (node: Object, parent): ?WhitespaceObject { +nodes.ObjectProperty = +nodes.ObjectTypeProperty = +nodes.ObjectMethod = +nodes.SpreadProperty = function (node: Object, parent): ?WhitespaceObject { if (parent.properties[0] === node) { return { before: true @@ -179,7 +179,7 @@ exports.nodes.SpreadProperty = function (node: Object, parent): ?WhitespaceObjec * Returns lists from node types that need whitespace. */ -exports.list = { +export const list = { /** * Return VariableDeclaration declarations init properties. @@ -222,7 +222,7 @@ exports.list = { amounts = { after: amounts, before: amounts }; } [type].concat(t.FLIPPED_ALIAS_KEYS[type] || []).forEach(function (type) { - exports.nodes[type] = function () { + nodes[type] = function () { return amounts; }; }); diff --git a/packages/babel-generator/src/printer.js b/packages/babel-generator/src/printer.js index 6d164fc2fe..f5557d54f9 100644 --- a/packages/babel-generator/src/printer.js +++ b/packages/babel-generator/src/printer.js @@ -7,6 +7,8 @@ import * as n from "./node"; import Whitespace from "./whitespace"; import * as t from "babel-types"; +import * as generatorFunctions from "./generators"; + const SCIENTIFIC_NOTATION = /e/i; const ZERO_DECIMAL_INTEGER = /\.0+$/; const NON_DECIMAL_LITERAL = /^0[box]/; @@ -572,22 +574,10 @@ export default class Printer { } } +// Expose the node type functions and helpers on the prototype for easy usage. +Object.assign(Printer.prototype, generatorFunctions); + function commaSeparator() { this.token(","); this.space(); } - -for (const generator of [ - require("./generators/template-literals"), - require("./generators/expressions"), - require("./generators/statements"), - require("./generators/classes"), - require("./generators/methods"), - require("./generators/modules"), - require("./generators/types"), - require("./generators/flow"), - require("./generators/base"), - require("./generators/jsx") -]) { - Object.assign(Printer.prototype, generator); -} diff --git a/packages/babel-plugin-transform-async-functions/src/index.js b/packages/babel-plugin-transform-async-functions/src/index.js index abe7b8a0f7..20eb9f453b 100644 --- a/packages/babel-plugin-transform-async-functions/src/index.js +++ b/packages/babel-plugin-transform-async-functions/src/index.js @@ -1,5 +1,7 @@ +import asyncSyntaxPlugin from "babel-plugin-syntax-async-functions"; + export default function () { return { - inherits: require("babel-plugin-syntax-async-functions") + inherits: asyncSyntaxPlugin, }; } diff --git a/packages/babel-plugin-transform-async-generator-functions/src/index.js b/packages/babel-plugin-transform-async-generator-functions/src/index.js index 3da5e7d19b..de09cfed52 100644 --- a/packages/babel-plugin-transform-async-generator-functions/src/index.js +++ b/packages/babel-plugin-transform-async-generator-functions/src/index.js @@ -1,4 +1,5 @@ import remapAsyncToGenerator from "babel-helper-remap-async-to-generator"; +import syntaxAsyncGenerators from "babel-plugin-syntax-async-generators"; export default function ({ types: t }) { const yieldStarVisitor = { @@ -17,7 +18,7 @@ export default function ({ types: t }) { }; return { - inherits: require("babel-plugin-syntax-async-generators"), + inherits: syntaxAsyncGenerators, visitor: { Function(path, state) { if (!path.node.async || !path.node.generator) return; diff --git a/packages/babel-plugin-transform-async-to-generator/src/index.js b/packages/babel-plugin-transform-async-to-generator/src/index.js index beabecb253..b6c1542dfd 100644 --- a/packages/babel-plugin-transform-async-to-generator/src/index.js +++ b/packages/babel-plugin-transform-async-to-generator/src/index.js @@ -1,8 +1,9 @@ import remapAsyncToGenerator from "babel-helper-remap-async-to-generator"; +import syntaxAsyncFunctions from "babel-plugin-syntax-async-functions"; export default function () { return { - inherits: require("babel-plugin-syntax-async-functions"), + inherits: syntaxAsyncFunctions, visitor: { Function(path, state) { diff --git a/packages/babel-plugin-transform-async-to-module-method/src/index.js b/packages/babel-plugin-transform-async-to-module-method/src/index.js index f9a7706ed1..5ae36b052c 100644 --- a/packages/babel-plugin-transform-async-to-module-method/src/index.js +++ b/packages/babel-plugin-transform-async-to-module-method/src/index.js @@ -1,8 +1,9 @@ import remapAsyncToGenerator from "babel-helper-remap-async-to-generator"; +import syntaxAsyncFunctions from "babel-plugin-syntax-async-functions"; export default function () { return { - inherits: require("babel-plugin-syntax-async-functions"), + inherits: syntaxAsyncFunctions, visitor: { Function(path, state) { diff --git a/packages/babel-plugin-transform-class-properties/src/index.js b/packages/babel-plugin-transform-class-properties/src/index.js index 1873757ee9..e06ea958bf 100644 --- a/packages/babel-plugin-transform-class-properties/src/index.js +++ b/packages/babel-plugin-transform-class-properties/src/index.js @@ -1,5 +1,6 @@ import nameFunction from "babel-helper-function-name"; import template from "babel-template"; +import syntaxClassProperties from "babel-plugin-syntax-class-properties"; export default function ({ types: t }) { const findBareSupers = { @@ -39,7 +40,7 @@ export default function ({ types: t }) { ); return { - inherits: require("babel-plugin-syntax-class-properties"), + inherits: syntaxClassProperties, visitor: { Class(path, state) { diff --git a/packages/babel-plugin-transform-decorators/src/index.js b/packages/babel-plugin-transform-decorators/src/index.js index e05a53e798..3a8aab971f 100644 --- a/packages/babel-plugin-transform-decorators/src/index.js +++ b/packages/babel-plugin-transform-decorators/src/index.js @@ -1,6 +1,7 @@ // Fork of https://github.com/loganfsmyth/babel-plugin-transform-decorators-legacy import template from "babel-template"; +import syntaxDecorators from "babel-plugin-syntax-decorators"; const buildClassDecorator = template(` DECORATOR(CLASS_REF = INNER) || CLASS_REF; @@ -281,7 +282,7 @@ export default function({ types: t }) { } return { - inherits: require("babel-plugin-syntax-decorators"), + inherits: syntaxDecorators, visitor: { ExportDefaultDeclaration(path) { diff --git a/packages/babel-plugin-transform-do-expressions/src/index.js b/packages/babel-plugin-transform-do-expressions/src/index.js index 1354c4ecfa..96cfd8f94d 100644 --- a/packages/babel-plugin-transform-do-expressions/src/index.js +++ b/packages/babel-plugin-transform-do-expressions/src/index.js @@ -1,6 +1,8 @@ +import syntaxDoExpressions from "babel-plugin-syntax-do-expressions"; + export default function () { return { - inherits: require("babel-plugin-syntax-do-expressions"), + inherits: syntaxDoExpressions, visitor: { DoExpression(path) { diff --git a/packages/babel-plugin-transform-es2015-modules-amd/src/index.js b/packages/babel-plugin-transform-es2015-modules-amd/src/index.js index bb9eb42c96..17338358e2 100644 --- a/packages/babel-plugin-transform-es2015-modules-amd/src/index.js +++ b/packages/babel-plugin-transform-es2015-modules-amd/src/index.js @@ -1,4 +1,5 @@ import template from "babel-template"; +import transformCommonjs from "babel-plugin-transform-es2015-modules-commonjs"; const buildDefine = template(` define(MODULE_NAME, [SOURCES], FACTORY); @@ -58,7 +59,7 @@ export default function ({ types: t }) { }; return { - inherits: require("babel-plugin-transform-es2015-modules-commonjs"), + inherits: transformCommonjs, pre() { // source strings diff --git a/packages/babel-plugin-transform-es2015-modules-commonjs/src/index.js b/packages/babel-plugin-transform-es2015-modules-commonjs/src/index.js index 74af212c55..832d1cb9dd 100644 --- a/packages/babel-plugin-transform-es2015-modules-commonjs/src/index.js +++ b/packages/babel-plugin-transform-es2015-modules-commonjs/src/index.js @@ -1,6 +1,7 @@ import { basename, extname } from "path"; import template from "babel-template"; import * as t from "babel-types"; +import transformStrictMode from "babel-plugin-transform-strict-mode"; const buildRequire = template(` require($0); @@ -127,7 +128,7 @@ export default function () { }; return { - inherits: require("babel-plugin-transform-strict-mode"), + inherits: transformStrictMode, visitor: { ThisExpression(path, state) { diff --git a/packages/babel-plugin-transform-es2015-modules-umd/src/index.js b/packages/babel-plugin-transform-es2015-modules-umd/src/index.js index 46405fc0f3..25598c395b 100644 --- a/packages/babel-plugin-transform-es2015-modules-umd/src/index.js +++ b/packages/babel-plugin-transform-es2015-modules-umd/src/index.js @@ -1,5 +1,6 @@ import { basename, extname } from "path"; import template from "babel-template"; +import transformAMD from "babel-plugin-transform-es2015-modules-amd"; const buildPrerequisiteAssignment = template(` GLOBAL_REFERENCE = GLOBAL_REFERENCE || {} @@ -42,7 +43,7 @@ export default function ({ types: t }) { } return { - inherits: require("babel-plugin-transform-es2015-modules-amd"), + inherits: transformAMD, visitor: { Program: { diff --git a/packages/babel-plugin-transform-exponentiation-operator/src/index.js b/packages/babel-plugin-transform-exponentiation-operator/src/index.js index 68d2ef8c69..c58302bb3c 100644 --- a/packages/babel-plugin-transform-exponentiation-operator/src/index.js +++ b/packages/babel-plugin-transform-exponentiation-operator/src/index.js @@ -1,8 +1,9 @@ import build from "babel-helper-builder-binary-assignment-operator-visitor"; +import syntaxExponentiationOperator from "babel-plugin-syntax-exponentiation-operator"; export default function ({ types: t }) { return { - inherits: require("babel-plugin-syntax-exponentiation-operator"), + inherits: syntaxExponentiationOperator, visitor: build({ operator: "**", diff --git a/packages/babel-plugin-transform-export-extensions/src/index.js b/packages/babel-plugin-transform-export-extensions/src/index.js index 5951b9e42d..95de3ef19c 100644 --- a/packages/babel-plugin-transform-export-extensions/src/index.js +++ b/packages/babel-plugin-transform-export-extensions/src/index.js @@ -1,3 +1,5 @@ +import syntaxExportExtensions from "babel-plugin-syntax-export-extensions"; + export default function ({ types: t }) { function build(node, nodes, scope) { const first = node.specifiers[0]; @@ -20,7 +22,7 @@ export default function ({ types: t }) { } return { - inherits: require("babel-plugin-syntax-export-extensions"), + inherits: syntaxExportExtensions, visitor: { ExportNamedDeclaration(path) { diff --git a/packages/babel-plugin-transform-flow-comments/src/index.js b/packages/babel-plugin-transform-flow-comments/src/index.js index 8abf61aa41..9ecad77d06 100644 --- a/packages/babel-plugin-transform-flow-comments/src/index.js +++ b/packages/babel-plugin-transform-flow-comments/src/index.js @@ -1,3 +1,5 @@ +import syntaxFlow from "babel-plugin-syntax-flow"; + export default function ({ types: t }) { function wrapInFlowComment(path, parent) { path.addComment("trailing", generateComment(path, parent)); @@ -12,7 +14,7 @@ export default function ({ types: t }) { } return { - inherits: require("babel-plugin-syntax-flow"), + inherits: syntaxFlow, visitor: { TypeCastExpression(path) { diff --git a/packages/babel-plugin-transform-flow-strip-types/src/index.js b/packages/babel-plugin-transform-flow-strip-types/src/index.js index 4b080f9258..6cbdc999e6 100644 --- a/packages/babel-plugin-transform-flow-strip-types/src/index.js +++ b/packages/babel-plugin-transform-flow-strip-types/src/index.js @@ -1,8 +1,10 @@ +import syntaxFlow from "babel-plugin-syntax-flow"; + export default function ({ types: t }) { const FLOW_DIRECTIVE = "@flow"; return { - inherits: require("babel-plugin-syntax-flow"), + inherits: syntaxFlow, visitor: { Program(path, { file: { ast: { comments } } }) { diff --git a/packages/babel-plugin-transform-function-bind/src/index.js b/packages/babel-plugin-transform-function-bind/src/index.js index 27c20faa1e..db0225ede9 100644 --- a/packages/babel-plugin-transform-function-bind/src/index.js +++ b/packages/babel-plugin-transform-function-bind/src/index.js @@ -1,3 +1,5 @@ +import syntaxFunctionBind from "babel-plugin-syntax-function-bind"; + export default function ({ types: t }) { function getTempId(scope) { let id = scope.path.getData("functionBind"); @@ -29,7 +31,7 @@ export default function ({ types: t }) { } return { - inherits: require("babel-plugin-syntax-function-bind"), + inherits: syntaxFunctionBind, visitor: { CallExpression({ node, scope }) { diff --git a/packages/babel-plugin-transform-object-rest-spread/src/index.js b/packages/babel-plugin-transform-object-rest-spread/src/index.js index 91f7a0c40a..8f9b62f85e 100644 --- a/packages/babel-plugin-transform-object-rest-spread/src/index.js +++ b/packages/babel-plugin-transform-object-rest-spread/src/index.js @@ -1,3 +1,5 @@ +import syntaxObjectRestSpread from "babel-plugin-syntax-object-rest-spread"; + export default function ({ types: t }) { function hasRestProperty(path) { let foundRestProperty = false; @@ -63,7 +65,7 @@ export default function ({ types: t }) { } return { - inherits: require("babel-plugin-syntax-object-rest-spread"), + inherits: syntaxObjectRestSpread, visitor: { // taken from transform-es2015-parameters/src/destructuring.js diff --git a/packages/babel-plugin-transform-regenerator/src/index.js b/packages/babel-plugin-transform-regenerator/src/index.js index e8207160e5..aaf6f168f5 100644 --- a/packages/babel-plugin-transform-regenerator/src/index.js +++ b/packages/babel-plugin-transform-regenerator/src/index.js @@ -1 +1 @@ -module.exports = require("regenerator-transform"); +export { default } from "regenerator-transform"; diff --git a/packages/babel-plugin-transform-runtime/src/definitions.js b/packages/babel-plugin-transform-runtime/src/definitions.js index f6a6e25f44..bc8b733204 100644 --- a/packages/babel-plugin-transform-runtime/src/definitions.js +++ b/packages/babel-plugin-transform-runtime/src/definitions.js @@ -1,4 +1,4 @@ -module.exports = { +export default { builtins: { Symbol: "symbol", Promise: "promise", diff --git a/packages/babel-traverse/src/path/index.js b/packages/babel-traverse/src/path/index.js index c66d0e8482..9bc92df683 100644 --- a/packages/babel-traverse/src/path/index.js +++ b/packages/babel-traverse/src/path/index.js @@ -9,6 +9,19 @@ import Scope from "../scope"; import * as t from "babel-types"; import { path as pathCache } from "../cache"; +// NodePath is split across many files. +import * as NodePath_ancestry from "./ancestry"; +import * as NodePath_inference from "./inference"; +import * as NodePath_replacement from "./replacement"; +import * as NodePath_evaluation from "./evaluation"; +import * as NodePath_conversion from "./conversion"; +import * as NodePath_introspection from "./introspection"; +import * as NodePath_context from "./context"; +import * as NodePath_removal from "./removal"; +import * as NodePath_modification from "./modification"; +import * as NodePath_family from "./family"; +import * as NodePath_comments from "./comments"; + const debug = buildDebug("babel"); export default class NodePath { @@ -151,17 +164,18 @@ export default class NodePath { } } -assign(NodePath.prototype, require("./ancestry")); -assign(NodePath.prototype, require("./inference")); -assign(NodePath.prototype, require("./replacement")); -assign(NodePath.prototype, require("./evaluation")); -assign(NodePath.prototype, require("./conversion")); -assign(NodePath.prototype, require("./introspection")); -assign(NodePath.prototype, require("./context")); -assign(NodePath.prototype, require("./removal")); -assign(NodePath.prototype, require("./modification")); -assign(NodePath.prototype, require("./family")); -assign(NodePath.prototype, require("./comments")); +assign(NodePath.prototype, + NodePath_ancestry, + NodePath_inference, + NodePath_replacement, + NodePath_evaluation, + NodePath_conversion, + NodePath_introspection, + NodePath_context, + NodePath_removal, + NodePath_modification, + NodePath_family, + NodePath_comments); for (const type of (t.TYPES: Array)) { const typeKey = `is${type}`;