Represent helpers as simple modules.

This commit is contained in:
Logan Smyth
2017-05-05 01:01:17 -07:00
parent 0c5fae2faa
commit 158e9fbfd7
26 changed files with 583 additions and 364 deletions

View File

@@ -1,3 +1,3 @@
export default function (arr) {
export default function _toArray(arr) {
return Array.isArray(arr) ? arr : Array.from(arr);
}

View File

@@ -1,6 +1,6 @@
exports.__esModule = true;
exports.default = _default;
exports.default = _toArray;
function _default(arr) {
function _toArray(arr) {
return Array.isArray(arr) ? arr : Array.from(arr);
}

View File

@@ -1,4 +1,4 @@
import _Array$from from "../../core-js/array/from";
export default function (arr) {
export default function _toArray(arr) {
return Array.isArray(arr) ? arr : _Array$from(arr);
}

View File

@@ -1,10 +1,10 @@
exports.__esModule = true;
exports.default = _default;
exports.default = _toArray;
var _from = _interopRequireDefault(require("../core-js/array/from"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _default(arr) {
function _toArray(arr) {
return Array.isArray(arr) ? arr : (0, _from.default)(arr);
}

View File

@@ -104,12 +104,7 @@ function buildRuntimeRewritePlugin(relativePath, helperName) {
}
function buildHelper(helperName, modules, useBuiltIns) {
const helper = helpers.get(helperName);
// avoid an unneccessary TDZ in the easy case
if (helper.type === "FunctionExpression") {
helper.type = "FunctionDeclaration";
}
const tree = t.program([t.exportDefaultDeclaration(helper)]);
const tree = t.program(helpers.get(helperName).nodes);
const transformOpts = makeTransformOpts(modules, useBuiltIns);