UNPKG

motion

Version:

motion - moving development forward

37 lines (33 loc) 1.23 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = MotionApp; // wraps your app in closure / export function MotionApp(_ref) { let name = _ref.name; return function MotionAppPlugin(_ref2) { let Plugin = _ref2.Plugin; let t = _ref2.types; return new Plugin("motion-transform-app", { visitor: { Program: { exit(node) { // wrap program in commonjs + iife node.body = [t.expressionStatement( // exports["name"] = function(){} t.assignmentExpression('=', t.identifier(`exports["${ name }"]`), //wrapFnName t.functionExpression(null, [t.identifier('Motion'), t.identifier('opts')], t.blockStatement([ // closure (function(Motion) {})(Motion) t.callExpression(t.functionExpression(null, [t.identifier('Motion')], t.blockStatement([].concat(node.body, t.expressionStatement(t.callExpression(t.identifier('Motion.start'), [])))) // end blockStatement ) // end functionExpression , [t.identifier('Motion')]) // end callExpression ]))))]; } } } }); }; } //# sourceMappingURL=app.js.map