`build-config-chain.js` creates an array of options which will be passed to `OptionsManager#mergeOptions`. The advantage of separating it out is that `build-config-chain` has a very minimal dependency list. The eventual intent is to allow the require hook to lazy load only when required. In other words, if no required files ever match the patterns `ignore` / `only` patterns, the bulk of babel-core, and the associated plugins, will never be loaded.
Since nodejs/node@08085c49b6, which will be part of Node.js v6.0,
functions from the `path` core module (like `dirname`) will require
their input to be a string.
Currently, at some points in the code they might be called
with `undefined`; This patch adds `… || ""` so that the input
is always a string.
For `path.dirname` in the babel-core file, this does not change
behaviour, since
`path.dirname(undefined) === path.dirname("") === "."` (where the
first expression is only defined for Node.js ≤ v5.x).
For `path.basename`, this changes the return value, since
`path.basename(undefined) === "undefined"` (on Node.js ≤ v5.x), but
`path.basename("") === ""`. However, it seems reasonable to assume
that, due to the trailing expression in
`path.basename(…) || "stdout"`, the current behaviour is not actually
the intended one.
There are possibly more places in the code base where similar changes
may be neccessary; However, these suffice to make the tests pass
and un-break the build of at least one external project when using
the current Node.js master branch.
I previously tried an approach to scope bindings from var to scope but
it didn't catch all cases. This is evident in this bug:
https://phabricator.babeljs.io/T2892
Where even after transforming a const to a var we still get an error
that it's read-only.
This approach will go through and delete every existing let and const
binding and creates a new one with the kind "var"